這裏是我的部分代碼:導軌 - 水豚不會處理ERB
<% @birds.each do |bird| %>
<p>
<%= "#{bird.name} , #{bird.genus} #{bird.species}"%>
</p>
<% end %>
這裏是我的RSpec的代碼,測試網頁:
let(:bird) { FactoryGirl.create(:bird) }
before { visit birds_path }
it { should have_text("#{bird.name}") }
該測試失敗:
Failure/Error: it { should have_text("#{bird.name}") }
expected #has_text?("Bird_1") to return true, got false
有誰知道爲什麼發生這種情況,以及如何解決這個問題? 謝謝
你可以使用'save_and_open_page'來調試出錯的地方 - https://gist.github.com/zhengjia/428105#file-capybara-cheat-sheet-L55 –
它說'未定義的局部變量或方法'save_and_open_page'' – SalmonKiller