我有以下内容application_helper_spec.rb
shared_examples_for "some shared process" do
it "displays the value defined by Let" do
puts object.inspect # This should output the value defined by Let
end
end
describe ApplicationHelper do
describe "a_helper_methond" do
describe "some behaviour" do
let(:object) { "foo" }
puts object.inspect # This should output the value defined by Let
it_should_behave_like "some shared process"
end
end
end
但是,当我运行它时,我在两个 put 上都出现了两个错误:
undefined local variable or method `object' for #<Class:0x007f951a3a7b20> (NameError)
为什么?我的模型中有完全相同的代码,并且请求规范运行良好,但在辅助规范中却没有。