【发布时间】:2017-11-01 14:55:18
【问题描述】:
我正在运行访问路径并在该页面上创建新对话的 rspec 测试。但是,即使我已明确说明visit conversations_path,我也无法理解为什么会出现以下错误。错误信息中写的link_to语句是在我的根路径下找到的。
当我从根路径中删除 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
失败:
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
【问题讨论】:
标签: rspec capybara capybara-webkit