spec/integration/delivery_spec.rb in mailstro-0.0.9 vs spec/integration/delivery_spec.rb in mailstro-0.0.10

- old
+ new

@@ -1,45 +1,43 @@ require 'spec_helper' describe 'posting a delivery', :integration do let(:contact_email) { "test@example.com" } - let(:template_name) { :test } - let(:template_data) { { :greeting => "Gday!" } } + let(:email_name) { :test } + let(:data) { { :greeting => "Gday!" } } before do Mailstro.configure do |config| config.api_key = 'lolapi' end end let(:expected_body) {{ - "api_key" => "lolapi", - "contact_email" => "test@example.com", - "template_name" => "test", - "template_data" => { "greeting" => "Gday!" } + "api_key" => "lolapi", + "to" => "test@example.com", + "email_name" => "test", + "data" => { "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( - :to => contact_email, - :template_name => template_name, - :template_data => template_data + response = Mailstro.deliver(email_name, + :to => contact_email, + :data => data ) 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( - :to => contact_email, - :template_name => template_name, - :template_data => template_data + Mailstro.deliver(email_name, + :to => contact_email, + :data => data ) end.to raise_error(Mailstro::Error::AuthorisationError, "api_key not authorised") end end