ruby on rails - Cucumber + Webrat doesn't submit forms? -
i'm new cucumber , totally lost why integration test failing. have following scenarios:
scenario: user changes profile given have account when change profile profile should saved scenario: user changes login given have account when change login information account should changed
and these step definitions:
given /^i have account$/ @user = factory.create(:user) visit login_path fill_in "email", :with => @user.email fill_in "password", :with => 'secret' click_button "sign in" end when /^i change profile$/ visit edit_user_profile_path(@user) fill_in "first name", :with => "john" fill_in "last name", :with => "doe" click_button "update profile" end /^my profile should saved$/ @user.profile.first_name.should == "john" @user.profile.last_name.should == "doe" end when /^i change login information$/ visit edit_user_path(@user) fill_in "email", :with => "foo@example.com" click_button "update login information" end /^my account should changed$/ @user.email.should == "foo@example.com" end
and fail "then" condition on both scenarios message:
# scenario 1 expected: "john" got: "test1" (using ==) (rspec::expectations::expectationnotmeterror) # scenario 1 expected: "foo@example.com" got: "test2@example.com" (using ==) (rspec::expectations::expectationnotmeterror)
so, in both cases factory information still present after submitting form update user login or profile. however, if test in real browser works perfectly. so, why test failing???
thanks help!
@user variable lives inside cucumber code block. not changed. changed in test database record. check changed indeed have visit page user name displayed.
(just in real life test)
Comments
Post a Comment