Hi all, Below is my model action. def activate! self.update_attribute(:active, true) end
here is spec/models/user_spec.rb describe User do before(:each) do @user=User.new(:email=>'k...@gmail.com',:password='1234'....,) end This is my spec. it "should activate the user" do @user.activate! @user.active.should be_true end but it gives error like "#23000Duplicate entry 'kk...@gmail.com Insert INTO (...) Values(...)". It should do update not Insert. But when i try call it with a new instance of user (with no values assigned to any user attribute) then it works. i.e. it "should activate the user" do @user_1=User.new @user_1.activate! @user_1.active.should be_true end I think i have to erase all the User attributes from "before (:each)" and only assigned it in Examples which required it. am i right ? Thanks -- Posted via http://www.ruby-forum.com/. _______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users