Rails3、rspec2 ActiveRecord#规格中的更改错误
我正在将 Rails 2 应用程序升级到 Rails 3。我在测试套件中使用 rspec、shoulda 和 Factory Girl。
一种特定的模式导致了一个错误,我在研究和解决方面都遇到了很大的困难。
# cart controller spec
@cart = Factory.build(:cart, :payment_status => "authorized", :user_id => @user.id)
2.times { Factory(:cart_item, :cart => @cart) }
我得到了这个规范失败:
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
调用 #times 方法是安全的(当我输入 2.times { put "hi" }
时不会抛出任何错误),但我不知道如何 #此处正在调用更改。
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(:cart, :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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有一个名为“更改”的专栏吗?我怀疑它与 ActiveRecord 冲突,您可能需要重命名它。
Do you have a column called 'changes'? I suspect it's clashing with ActiveRecord, you may need to rename it.