将 shoulda 宏与 RSpec 一起使用
我正在尝试在 RSpec 中使用 shoulda 宏,但遇到了一些问题。
我已经完成了以下操作:
spec_helper.rb:
require 'shoulda/active_record/macros'
Spec::Runner.configure do |config|
...
config.include(Shoulda::ActiveRecord::Macros, :type => :model)
spec / models / foo_spec.rb:
describe Foo do
it { should_have_instance_methods( :save ) } # just for example
end
这给我带来了失败:
未定义的方法'get_options!'对于#
I'm trying to use the shoulda macros within RSpec and am having some problems.
I've done the following:
spec_helper.rb:
require 'shoulda/active_record/macros'
Spec::Runner.configure do |config|
...
config.include(Shoulda::ActiveRecord::Macros, :type => :model)
spec/models/foo_spec.rb:
describe Foo do
it { should_have_instance_methods( :save ) } # just for example
end
Which gives me a failure with:
undefined method 'get_options!' for #<Spec::Rails::Example::ModelExampleGroup::Subclass_1:0xb714046c>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
只是语法:
not:
but
(注意下划线)
just syntax:
not:
but
(note the underscores)
我不是 100% 确定与 RSpec 的集成,但是您是否将在上下文中调用 should_have_instance_methods 的块包装起来? IIRC 中的所有 should 语句都需要围绕它们的上下文。
I am not 100% sure about the integration with RSpec, but did you wrap the chunk where you call should_have_instance_methods in a context? IIRC all should statements from shoulda require a context wrapped around them.