モデル製品があり、それを でレンダリングし<%= render @products %>
ます。を含むテンプレート _product.html.erb があります<%= link_to product.name, product %>
。開発環境のブラウザーでこのページにアクセスすると、製品が表示されます。
現在、キュウリを実行していますが、製品が表示されません。
次のように、FactoryGirl を使用して "given" で製品を作成します。
Given(/^(\d+) products are created$/) do |n|
n.to_i.times do
create(:product)
end
end
Then I visit my page and in "then I check it like this"
Then(/^I should see paginated products$/) do
puts Product.all
puts page.body
products = Product.all
products[0..9].each do |product|
page.should have_selector "a", text: product.name
end
end
put Product.all は有効な製品を印刷しますが、put page.body はレンダリングされた製品なしで私のページを印刷します。
ここに私のenv.rbファイルがあります:
require 'cucumber/rails'
World FactoryGirl::Syntax::Methods
ActionController::Base.allow_rescue = false
Cucumber::Rails::World.use_transactional_fixtures = true
Cucumber::Rails::Database.javascript_strategy = :truncation
カピバラがテンプレートをレンダリングしないのはなぜですか?
ありがとう
アップデート:
私の製品はputs Product.all
印刷されます<%= @products.count %>
が、私の見解ではテスト用に 0 が表示されます。変...