RSPEC - PUT请求返回错误405

时间:2015-05-05 17:19:45

标签: api testing rspec put

我有这个测试

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

这是回复

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

   expected: 200
        got: 405

   (compared using eql?)

我无法使用rspec发出请求。有人可以选择测试吗?

1 个答案:

答案 0 :(得分:2)

405表示“方法不允许”,例如,端点接受POST请求但不接受PUT请求。

如果没有看到实现,就无法知道问题是在规范中还是在被测试的端点中。

相关问题