I am using Ruby on Rails 3.2.2, cucumber-rails-1.3.0, rspec-rails-2.8.1 and capybara-1.1.2 with the Selenium driver. I have an issue about concurrency on running JavaScript scenarios (supposed that my case is related to a concurrency issue).
In my .feature
file I have:
Feature: ...
...
@javascript
Scenario: ...
Given ...
When I log out
Then I should be redirected to the home page
In my step definition .rb
file I have:
Then /^I should be redirected to the home page$/ do
current_path.should == root_path
end
When I run the cucumber
command line in the Terminal window so to run tests, I get this error:
$ cucumber
Using the default profile...
Feature: ...
...
@javascript
Scenario: ...
...
When I log out
Then I should be redirected to the home page
expected: "/"
got: "/user" (using ==) (RSpec::Expectations::ExpectationNotMetError)
...
However if in my step definition .rb
file I use
Then /^I should be redirected to the home page$/ do
sleep(1)
current_path.should == root_path
end
it works as expected: all tests pass.
So, even if the problem seems to be solved, there is a better way to handle my issue? if so, what is the "right"/"common used" solution (maybe using some Capybara API)?