Skip to content

Instantly share code, notes, and snippets.

@cavalle
Created May 11, 2010 22:38
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save cavalle/397977 to your computer and use it in GitHub Desktop.
Save cavalle/397977 to your computer and use it in GitHub Desktop.
# This works with steak 0.3.x and rspec 1.x
# For steak --pre and rspec 2 see this fork: http://gist.github.com/448487
# Put this code in acceptance_helper.rb or better in a new file spec/acceptance/support/javascript.rb
Spec::Runner.configure do |config|
config.before(:each) do
Capybara.current_driver = :selenium if options[:js]
end
config.after(:each) do
Capybara.use_default_driver if options[:js]
end
end
#...
scenario "Scenario that needs Javascript", :js => true do
#...
end
scenario "Scenario that doesn't need Javascript" do
#...
end
@Papipo
Copy link

Papipo commented Jun 22, 2010

¿How can I use this with Rspec 2?

Rspec.configure do |config|
  config.before(:each) do
    Capybara.current_driver = :selenium if options[:js]
  end
[...]

I don't have an options() method :-(

@cavalle
Copy link
Author

cavalle commented Jun 22, 2010

Never tried with RSpec 2, but you may find this post useful:

http://blog.davidchelimsky.net/2010/06/14/filtering-examples-in-rspec-2/

@Papipo
Copy link

Papipo commented Jun 22, 2010

Yeah, I've seen that one, but it only talks about using example metadata to filter spec execution. I am looking at Rspec2 source code, I'll post anything I find about this issue here.

@Papipo
Copy link

Papipo commented Jun 22, 2010

I have found the solution and forked your gist. Thanks for your input!

@kristianmandrup
Copy link

Please provide a link to the final solution to this issue. I also want to use "tags" with Steak and RSpec 2 :)

@bebanjo
Copy link

bebanjo commented Aug 15, 2010

Papipo forked this gist and posted there his solution (see the forks section at the top right of this page):

Direct link: http://gist.github.com/448487

@kristianmandrup
Copy link

Thanks :)

@guilleiguaran
Copy link

Looks like that isn't required anymore: http://jeffkreeftmeijer.com/2011/capybara-ate-swinger/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment