Sha256: 8faabef8e73a9d53c4b04c4b5191f9aee4fa794f2feb716b15d87a6b09aae32e
Contents?: true
Size: 1.12 KB
Versions: 1
Compression:
Stored size: 1.12 KB
Contents
require 'spec_helper' describe 'posting a delivery', :integration do let(:template_name) { :test } let(:contact_email) { "test@example.com" } let(:payload) { { :greeting => "Gday!" } } before do Mailstro.configure do |config| config.api_key = 'lolapi' end end let(:expected_body) {{ "api_key" => "lolapi", "template_name" => "test", "contact_email" => "test@example.com", "payload" => { "greeting" => "Gday!" } }} it "succesfully submits a delivery to mailstro" do stub_request(:post, "https://api.mailstroapp.com/v1/deliveries"). with(:body => expected_body).to_return(:status => 200, :body => fixture("response.json")) response = Mailstro.deliver(template_name, contact_email, payload) response['success'].should == true end it "raises an error if the api key is not authorized" do stub_request(:post, "https://api.mailstroapp.com/v1/deliveries"). to_return(:status => 401) expect do Mailstro.deliver(template_name, contact_email, payload) end.to raise_error(Mailstro::Error::AuthorisationError, "api_key not authorised") end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
mailstro-0.0.5 | spec/integration/delivery_spec.rb |