未定义的方法`get'为#

时间:2014-08-07 11:27:47

标签: ruby-on-rails ruby ruby-on-rails-3 ruby-on-rails-4 rspec

我的测试规范

it "can find an account" do 
    get "/account/#{@acc.id}", {}, {"Accept" => "application/json"}
  end

当我尝试运行我的rspec时,我收到以下错误。

Failure/Error: get "/account/#{@acc.id}", {}, {"Accept" => "application/json"}
     NoMethodError:
       undefined method `get' for #<RSpec::ExampleGroups::Account_2:0x00000004a6d430>

另外,当我在find方法中传递时,我如何将另一个params authorization传递给我的get方法。

Account.find(id: @acc.id, authorization: @token);

1 个答案:

答案 0 :(得分:3)

方法get仅在测试控制器时可用。使用新的rspec,您需要明确告诉您正在测试的内容:

describe MyController, type: :controller do