Skip to content

Commit

Permalink
add spec coverage for the ResponseError message
Browse files Browse the repository at this point in the history
  • Loading branch information
glennr committed Jun 16, 2017
1 parent 43121b9 commit ec2fad4
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions spec/webpush_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,19 @@
}
end

it 'sets the error message to be the host + stringified response' do
stub_request(:post, expected_endpoint).
to_return(status: 401, body: "Oh snap", headers: {})

host = URI.parse(expected_endpoint).host

expect { subject }.to raise_error { |error|
expect(error.message).to eq(
"host: #{host}, #<Net::HTTPUnauthorized 401 readbody=true>\nbody:\nOh snap"
)
}
end

it 'raises exception on error by default' do
stub_request(:post, expected_endpoint).to_raise(StandardError)

Expand Down

0 comments on commit ec2fad4

Please sign in to comment.