我正在测试一些服务
require 'spec_helper'
feature 'MyAPIService' do
before do
stub_request(:get, "http://my_app.com/persisted_session").
with(headers: {'Accept'=>'*/*', 'User-Agent'=>'Ruby'}).
to_return(status: 200, body: 's', headers: {})
end
it 'checks if session persist' do
uri = URI('http://my_app.com/persisted_session')
response = Net::HTTP.get(uri)
expect(response.status).to be_success
end
end
我想测试状态并解析xml体。但是我收到了错误
1) MyAPIService checks if session persist
Failure/Error: expect(response).to be_success
NoMethodError:
undefined method `success?' for "s":String
答案 0 :(得分:0)
您希望expect(response).to be_success
代替expect(response.status).to be_success