如何将黄瓜与铁轨分开运行?

时间:2018-09-29 16:30:17

标签: ruby-on-rails cucumber

嗨,我正在使用Rails 5和ruby 2.5.1进行ROR项目。我在黄瓜上写过测试用例。当我运行黄瓜时,它在本地运行,即它根据本地代码提供输出,但我想测试远程API。如何在不依赖于本地Rails代码的情况下测试远程API?我尝试如下提到远程URL:

When(/^I send a GET request to receipt details$/) do
  @url = "http://example.com/api/receipts"
end

Then(/^the json response should have main receipt status complete$/) do
  header 'login-token', @login_token
  header 'user-id', @user_id
  response = get @url
  response_body = JSON response.body
  @id = response_body['data']['id']
  expect(response_body['data']['attributes']['status']).to eq('complete')
end

但是它仍然检查本地路由'/ api / receipts'。它不调用URL。 请帮助我,谢谢。

0 个答案:

没有答案