失败/错误期望(响应).to render_template(index)nomethoderror:assert_template已被提取到gem

时间:2016-05-14 02:56:53

标签: ruby-on-rails rspec

require 'rails_helper'

describe StaticPagesController, :type => :controller do
  context "GET #index" do
    before do
      get :index
    end

    it "responds successfully with an HTTP 200 status code" do
      expect(response).to be_success
      expect(response).to have_http_status(200)
    end

    it "renders the index template" do
      expect(response).to render_template("index")
    end
  end

end

错误

enter image description here

1 个答案:

答案 0 :(得分:4)

我认为错误是非常自我解释的。

assignsassert_template已从rails中提取到单独的rails-controller-testing宝石中。您是否已将该宝石添加到Gemfile

请致电rails-controller-testing获取更多信息。