Hey,
I am writing a simple cucumber feature for a Rails app to test if the
webrat+selenium integration was successful:
Scenario: Successful log in
Given the user “pepito” exists # (1)
And the user “pepito” is active
When I go to the login page
And I fill in “login” with “pepito”
And I fill in “password” with “secret”
And I press “submit” # (2)
Then I should see a confirmation message
Now I think I managed to set up the architecture all right (using sep.
setup files for plain and javascript -selenium- features as described
here:
http://wiki.github.com/aslakhellesoy/cucumber/setting-up-selenium).
The problem is that the “Then I should see a confirmation message”
fails.
I put a breakpoint at (2) to investigate the problem. I’ve found that:
- the user is succesfully created (User.first in a rails console
gives back pepito) - I can log in successfully from the console (User.authenticate
(“pepito”, “secret”) gives back the user meaning successful
authentication. - The login and password fields are correctly filled with the values
(checking that in the launched FF browser) - If I manually submit the form at the breakpoint, it also fails to
log in, so it’s not that the "And I press “submit” step does something
other than submitting the form. - the users table in the database that selenium uses is empty.
(mysql> select * from users;
Empty set (0.00 sec) ). That surprises me a bit since in theory
selenium does not use transactional fixtures so the record should
appear right away after (1) runs.
Here are my cucumber config file(s):
I run the feature like this:
cucumber -r features/support/env.rb -r features/support/enhanced.rb -r
features/step_definitions features/enhanced/login.feature
And these are the setup steps to create and activate the user:
Given /^the user “(.*)” exists$/ do |login_name|
User.find_by_login(login_name) || Factory
(:user_with_password, :login => login_name)
end
Given /^the user “(.*)” is active$/ do |login_name|
User.find_by_login(login_name).activate!
end
I also see in the log that the form is submitted with the correct
parameters.
Please let me know if you see what I am missing or what I should do
differently.
Thank you,
Balint