开发者

rails3, rspec2 ActiveRecord#changes error in specs

开发者 https://www.devze.com 2023-03-07 06:47 出处:网络
I\'m upgrading my rails 2 app to rails 3. I use rspec, shoulda and factory girl in the test suite. One particular pattern is causing an error I\'m having a really hard time both researching and solvi

I'm upgrading my rails 2 app to rails 3. I use rspec, shoulda and factory girl in the test suite.

One particular pattern is causing an error I'm having a really hard time both researching and solving.

  # cart controller spec
  @cart = Factory.build(:car开发者_Python百科t, :payment_status => "authorized", :user_id => @user.id)
  2.times { Factory(:cart_item, :cart => @cart) }

And I get this spec failure:

changes is defined by ActiveRecord
./spec/controllers/cart_controller_spec.rb:41
./spec/controllers/cart_controller_spec.rb:41:in `times'
./spec/controllers/cart_controller_spec.rb:41

calling the #times method is safe ( no error are thrown when I just put 2.times { puts "hi" } ) but I'm not able to see how #changes is being invoked here.


Do you have a column called 'changes'? I suspect it's clashing with ActiveRecord, you may need to rename it.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号