私は私の中に次のものを持っています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
ただし、これを実行すると、両方のプットで 2 つのエラーが発生します。
undefined local variable or method `object' for #<Class:0x007f951a3a7b20> (NameError)
なんで?モデルとリクエスト仕様にまったく同じコードがあり、正常に動作しますが、ヘルパー仕様では動作しません。