所以我想用Rspec和Factory Girl來測試一些視圖,但我不知道如何正確指定工廠視圖。我在網上看到的所有信息都使用了stubbing,儘管stubbing沒問題,但我仍想保持rspec的一致性。使用Rspec視圖的工廠女孩
我想爲一個版本模型使用工廠,並在呈現頁面時將其與頁面關聯,但我所考慮的一切似乎都已被破壞。這裏有一個排序荒謬的例子中:
require 'spec_helper'
describe "catalog/editions/rationale.html.haml" do
before do
@edition = Factory.create(:edition)
assign(:editions, @edition)
render :action => 'rationale', :id => @edition
end
context "GET rationale" do
it "should not have the preamble to the United States constitution" do
rendered.should_not contain(/We the People of the United States/)
end
end
end
在此,我試圖改變渲染:行動=>「理由」,:ID => @edition只是渲染,以及其他類似的調整,以渲染動作。我只是不知道在哪裏開始工廠幫助查看。任何幫助將不勝感激。
版本:
的Rails 3.0.10
RSpec的2.7
Factory_Girl 2.2
您能否詳細說明問題的具體內容?測試失敗的地方在哪裏? – jaredonline
另外,您使用的是Rails,FactoryGirl和RSpec的版本? – jaredonline