テスト出力に動的データを含めたいと思います。
このようなテストを書くと、「it should have '' things」と出力されます。
rspec のマジックと ruby のブロックをクロージャーとして混同しているようです。
ブロック外のメソッドで count に固執することはできますが、それはハックのようです。
ポインタはありますか?
describe 'things' do
before :all do
@count = 3
end
it "should have #{@count} things" do
#....
page.should have_content("entries: #{@count}")
end
end
上記のようなテストを書くと、「it should have '' things」と出力されます。
編集:別のより具体的な例
describe 'things' do
before :all do
@thing = FactoryGirl.create(:thing)
end
it "should display a thing with name #{@thing.name} " do
#....
page.should have_css("h1", text: @thing.name)
end
end