0
我想測試我的主頁。鏈接本身不應該。 爲什麼不是真的?Rails RSpec - 測試時有錯誤have_link
規格/特徵/ main_pages_spec.rb
require 'spec_helper'
RSpec.describe "main pages", :type => :features do
subject { page }
...
context "root page" do
it "should have the link 'Home'" do
visit root_path
expect(page).to have_link('Home', href: '#')
end
end
...
end
應用/視圖/ main_pages/home.html.erb
...
<%=link_to("Home", "#") %>
...
=>
main pages root page should have the link 'Home'
Failure/Error: expect(page).to have_link('Home', href: '#')
expected #has_link?("Home", {:href=>"#"}) to return true, got false
# ./spec/features/main_pages_spec.rb:11:in `block (3 levels) in <top (required)>'
UPDATE: 誰都可以幫幫我?
是什麼在你的routes.rb? – 2015-04-03 06:23:58
@AndreyTurkin根'main_pages#home' – 2015-04-03 06:25:39