경로를 방문하여 해당 페이지에서 새 대화를 만드는 rspec 테스트를 실행 중입니다. 그러나, 나는 분명히 visit conversations_path
을 명시 했음에도 불구하고 왜 내가 아래에 오류가 발생하는지 이해할 수 없다. 오류 메시지에 기록 된 link_to 문은 내 루트 경로에서 발견됩니다.Rspec + Capybara 웹킷 : 테스트에 명시된 경로로 연결되지 않음 대신 루트 경로 구문이 감지 됨
루트 경로에서 link_to 코드를 제거하면 테스트가 통과됩니다.
conversation_spec.rb
describe "Conversation" do
let!(:user) { FactoryGirl.create(:user) }
let!(:other_user) { FactoryGirl.create(:friend) }
before do
login_as(user, :scope => :user)
end
describe 'index' do
before do
visit conversations_path
end
it 'can be reached successfully' do
expect(page.status_code).to eq(200)
end
it "create a new conversation", **js: true** do
visit conversations_path
expect(current_path).to eq(conversations_path)
click_on "Compose"
expect(page).to have_css('.new_message_head')
end
end
실패 : featured_article
이 전무이기 때문에 당신이 테스트에 대한 기사를 작성하지 않았기 때문에
1) Conversation index create a new conversation
Failure/Error: <h4><%= link_to featured_article.title, article_path(featured_article) %></h4>
ActionView::Template::Error:
undefined method `title' for nil:NilClass