Sha256: dee3d32496f4d573d020a40fcce09ab08c2f7c613f8703086f3cd279a8195b07

Contents?: true

Size: 814 Bytes

Versions: 1

Compression:

Stored size: 814 Bytes

Contents

require 'spec_helper'
require 'howitzer/mailgun/client'
require 'howitzer/exceptions'

RSpec.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 { is_expected.to eq("{\"foo\":\"bar\"}")}
  end
  describe '#code' do
    subject { Mailgun::Response.new(response).code }
    it { is_expected.to eq(201)}
  end
  describe '#to_h' do
    subject { Mailgun::Response.new(response).to_h }
    context 'when possible parse body' do
      it { is_expected.to eq({'foo' => 'bar'})}
    end
    context 'when impossible parse body' do
      let(:body) { "123" }
      it do
        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.1.1 spec/unit/lib/mailgun/response_spec.rb