[rspec-users] [cucumber] webrat+selenium integration problem: record not saved to database?
balint.erdi at gmail.com
Mon Mar 23 13:14:58 EDT 2009
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.
The problem is that the "Then I should see a confirmation message"
I put a breakpoint at (2) to investigate the problem. I've found that:
1. the user is succesfully created (User.first in a rails console
gives back pepito)
2. I can log in successfully from the console (User.authenticate
("pepito", "secret") gives back the user meaning successful
3. The login and password fields are correctly filled with the values
(checking that in the launched FF browser)
4. 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.
5. 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
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)
Given /^the user "(.*)" is active$/ do |login_name|
I also see in the log that the form is submitted with the correct
Please let me know if you see what I am missing or what I should do
More information about the rspec-users