[rspec-users] Cucumber model expectations fail to find newly created users

Hubert Lepicki lists at ruby-forum.com
Sun Jan 4 14:13:57 EST 2009

Hi guys,

I have strange problem with getting model expectations to work with
Cucumber. My setup is that I use Cucumber + Webrat (Selenium backend).

Story I test is registering user on site. Cucumber runs story perfectly
fine, and I see it fills in form, sends it, I even see proper "You have
successfully registered" message at the end. However, as a last element
of story I want to make sure the user was really created in database -
and this fails.

I have definition of following step:

Then /^should exist exactly "(.*)" users$/ do |cnt, state|
  User.count.should == cnt.to_i

However, it always complains that there are 0 users, when expected X.

What is even more stranger, when I log into console, and do User.count,
I get proper number of users - they were actually created during running
a story!

Any ideas?
Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list