次のビューがありますが、ビューの仕様では適切に特定できません。
ファイル: "products / index.html.haml"
#products
= render @products
そして、これは私のビューの仕様です:
require 'spec_helper'
describe "products/index.html.haml" do
let(:products) {[mock_model(Product)]}
before do
stub_template "products/product.html.haml" => ""
render
end
it "should render the products" do
rendered.should have_selector(#products) do
rendered.should render_template products
end
end
ここでの問題は、have_selectorがブロックを受け入れないため、パーシャルが#productsdiv内にレンダリングされていることを表明する方法がないことです。CapybaraマッチャーはView仕様内では機能しないため、どちらでも使用できません。
この問題も参照してください:https ://github.com/rspec/rspec-rails/issues/387