How do you change the testing default driver for a Cucumber test in Capybara?

capybara, cucumber, ruby-on-rails

Solution

In cucumber, I've done this in two steps:

In `/features/support/env.rb`, place the following line:

Capybara.javascript_driver = :webkit

Then in the cucumber feature, just before the specific scenario, add `@javascript` just before the scenario -- like this:

@javascript
Scenario: Successful sign in - with no flash message if using current firefox
When I'm using a current version of Firefox
When I visit the practitioner home page with "jane.doe@example.com"'s token
Then I should be signed in as practitioner "Jane Doe"
And I should be on the practitioner activities welcome page
And I should not see a flash message warning me I have an unsupported browser

This tells cucumber to use the `javascript` driver when it runs that particular scenario.

This is how I've done this using Capybara Webkit -- I'm sure other drivers are similar.

Problem

In the documentation provided by Capybara, you can change the default_driver on a specific test group: ``` describe 'some stuff which requires js', :js => true do it 'will use the default js driver' it 'will switch to one specific driver', :driver => :selenium end ``` What if I wanted to do this for a specific cucumber test group? How would I add those parameters? ``` When /^I do something$/ do fill_in "a_text_box", :with => "stuff" fill_in "another_text_box", :with => "another_thing" end ``` Thanks!

Original source