Bruno Quaresma
Bruno Quaresma

Reputation: 10707

RSPEC - PUT request return error 405

i have this test

describe 'PUT #start' do
  before do
    put :start, abtest_id: @variation.abtest.id.to_s,
                variation_id: @variation.id.to_s, format: 'json'
  end

  it "shoud return HTTP 200 status code" do
    expect(response.response_code).to eql(200)
  end
end

This is the response

Failure/Error: expect(response.response_code).to eql(200)

   expected: 200
        got: 405

   (compared using eql?)

I can't make put request with rspec. Someone would have an alternative to test it?

Upvotes: 1

Views: 265

Answers (1)

Andy Waite
Andy Waite

Reputation: 11076

405 means 'Method Not Allowed', for example, the endpoint accepts POST requests but not PUT requests.

Without seeing the implementation, it's impossible to know whether the problem is in the spec or in the endpoint being tested.

Upvotes: 2

Related Questions