Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using the RSpec before suite hook with a tag

I'm trying to use the Rspec before(:suite) hook with a tag like so:

  config.before(:suite, :selenium => true) do
    #magical awesomeness
  end

but Rspec doesn't seem to respect the tag and runs the code I only want to run with : selenium => true regardless.

The weird part is that I'm doing a very similar thing with the :each hook as well and that seems to work fine:

  config.around(:each, :selenium => true) do |example|
    Capybara.using_wait_time(10) do
      Capybara.using_driver(:selenium) do
        example.run
      end
    end
  end

Anyone know what I'm doing wrong?

like image 545
Ganesh Shankar Avatar asked Feb 06 '12 10:02

Ganesh Shankar


1 Answers

This should work:

if config.inclusion_filter[:selenium]
  config.before(:suite) do
    #magical awesomeness
  end
end
like image 96
Yuriy Kharchenko Avatar answered Sep 20 '22 13:09

Yuriy Kharchenko