samedi 2 avril 2016

Getting undefined method `get' for #

Rails 4.2.5, rspec-rails 3.0.2

I want to test my API. So I created requests directory inside /spec. There is a file called projects_spec.rb

Here is the code:

describe 'Projects API' do
  describe 'GET /projects' do
    it 'should return 401 HTTP code' do
      get '/api/v1/projects'
      expect(response.status).to eq(401)
    end
  end
end

And when I run this test I'm getting NoMethodError: undefined method `get' for #RSpec::ExampleGroups::ProjectsAPI::GETProjects:0x007fee73ad9b48>

What's wrong? I have config.infer_spec_type_from_file_location! in rails_helper.rb

Aucun commentaire:

Enregistrer un commentaire