I am testing some service
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
I want to test status and parsed xml body. But I got an error
1) MyAPIService checks if session persist
Failure/Error: expect(response).to be_success
NoMethodError:
undefined method `success?' for "s":String
You want
expect(response).to be_success
instead ofexpect(response.status).to be_success