Rspec失败了所需的密钥:[:id]

时间:2015-09-09 13:35:49

标签: ruby-on-rails rspec capybara rspec-rails

当我运行我的规范时,我得到以下内容。

enter image description here

为什么会这样?我只是想确保我在ProjectsController中的show动作。

规范

require 'spec_helper'

describe "Creating projects" do
  it "can create a project" do
    visit '/'

    click_link 'New Project'
    fill_in 'Name', with: 'TextMate2'
    fill_in 'Description', with: 'A text-editor for OS X'

    click_button 'Create Project'
    expect(page).to have_content('Project has been created.')

    project = Project.where(name: "TextMate 2").first
    expect(page.current_url).to eql(project_url(project))

    title = "TextMate 2 - Projects - Ticketee"
    expect(page).to have_title(title)
  end

控制器

  def show
    @project = Project.find(params[:id])
  end

查看

<h2><%= @project.name %></h2>

0 个答案:

没有答案