Sha256: 70d927b573c7d6b1ae3e06e0643c36ce13b8ca4e65030cb0a55cec210a7e51de
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'spec_helper' require 'howitzer/mailgun/client' describe Mailgun::Client do let(:mg_obj) { Mailgun::Client.new("Fake-API-Key") } describe ".new" do subject { mg_obj } it { expect { subject }.not_to raise_error } end describe "#get" do let(:query_string){ {'skip' => '10', 'limit' => '5'} } subject { mg_obj.get("test.com/bounces", query_string) } context "when simulation of client" do before do expect(RestClient::Resource).to receive(:new).once { Mailgun::UnitClient::new('Fake-API-Key', 'api.mailgun.net', 'v2') } end it do expect(subject.body).to include("total_count") expect(subject.body).to include("items") end end context "when real client" do let(:resource) { double } before do allow(resource).to receive('[]'){ resource } allow(resource).to receive(:get).and_raise(StandardError, '401 Unauthorized: Forbidden') allow(RestClient::Resource).to receive(:new) { resource } end it do expect(log).to receive(:error).with(Howitzer::CommunicationError, '401 Unauthorized: Forbidden').once.and_call_original expect { subject }.to raise_error(Howitzer::CommunicationError) end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
howitzer-1.0.2 | spec/unit/lib/mailgun/client_spec.rb |