Sha256: 219791d5dcaecd4d1dd1f5b5006d5e01e14380ea378ba093a2b5fcf82e4720c7
Contents?: true
Size: 940 Bytes
Versions: 1
Compression:
Stored size: 940 Bytes
Contents
require 'spec_helper' require 'howitzer/mailgun/client' require 'howitzer/exceptions' describe Mailgun::Response do let(:body) { {foo: 'bar'}.to_json } let(:response) { double(:response, body: body, code: 201)} describe "#body" do subject { Mailgun::Response.new(response).body } it { expect(subject).to eq("{\"foo\":\"bar\"}")} end describe "#code" do subject { Mailgun::Response.new(response).code } it { expect(subject).to eq(201)} end describe "#to_h" do subject { Mailgun::Response.new(response).to_h } context "when possible parse body" do it { expect(subject).to eq({"foo"=>"bar"})} end context "when impossible parse body" do let(:body) { '123' } it do expect(log).to receive(:error).with(Howitzer::ParseError, "757: unexpected token at '123'").once.and_call_original expect { subject }.to raise_error(Howitzer::ParseError) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
howitzer-1.0.2 | spec/unit/lib/mailgun/response_spec.rb |