我有以下视图,我无法在视图规范中正确指定:
文件:“产品/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 不接受块,因此无法断言部分呈现在 #products div 内。由于 Capybara 匹配器在 View 规范中不起作用,因此您也不能在其中使用。