spec/unit/mailgun_spec.rb in mailgun-ruby-1.0.1 vs spec/unit/mailgun_spec.rb in mailgun-ruby-1.0.2

- old
+ new

@@ -1,24 +1,16 @@ require 'spec_helper' -module Mailgun - class Client - def initialize(api_key, api_host="api.mailgun.net", api_version="v2") - @http_client = Mailgun::UnitClient::new(api_key, api_host, api_version) - end - end -end - describe 'Mailgun instantiation' do it 'instantiates an HttpClient object' do - expect {@mg_obj = Mailgun::Client.new("Fake-API-Key")}.not_to raise_error + expect {@mg_obj = Mailgun::UnitClient.new("messages")}.not_to raise_error end end describe 'The method send_message()' do before(:each) do - @mg_obj = Mailgun::Client.new("Fake-API-Key") + @mg_obj = Mailgun::UnitClient.new("messages") @domain = "test.com" @list_address = "mylist@test.com" @member_address = "subscribee@test.com" end @@ -36,58 +28,58 @@ 'to' => 'bob@example.com', 'subject' => 'Test', 'text' => 'Test Data'} result = @mg_obj.send_message("testdomain.com", data) - result.to_hash! + result.to_h! result.body.should include("message") result.body.should include("id") end it 'opens the message MIME and sends the MIME message.' do data = {'to' => 'joe@test.com', 'message' => 'Sample Data/mime.txt'} result = @mg_obj.send_message("testdomain.com", data) - result.to_hash! + result.to_h! result.body.should include("message") result.body.should include("id") end end describe 'The method post()' do before(:each) do - @mg_obj = Mailgun::Client.new("Fake-API-Key") + @mg_obj = Mailgun::UnitClient.new("messages") @domain = "test.com" end it 'in this case, sends a simple message.' do data = {'from' => 'joe@test.com', 'to' => 'bob@example.com', 'subject' => 'Test', 'text' => 'Test Data'} result = @mg_obj.post("#{@domain}/messages", data) - result.to_hash! + result.to_h! result.body.should include("message") result.body.should include("id") end end describe 'The method put()' do before(:each) do - @mg_obj = Mailgun::Client.new("Fake-API-Key") + @mg_obj = Mailgun::UnitClient.new("lists") @domain = "test.com" @list_address = "mylist@test.com" @member_address = "subscribee@test.com" end it 'in this case, updates a member with the attributes in data.' do data = {'subscribed' => false, 'name' => 'Foo Bar'} result = @mg_obj.put("lists/#{@list_address}/members#{@member_address}", data) - result.to_hash! + result.to_h! result.body.should include("member") result.body["member"].should include("vars") result.body["member"]["vars"].should include("age") result.body["member"].should include("name") result.body["member"].should include("subscribed") @@ -97,33 +89,33 @@ end describe 'The method get()' do before(:each) do - @mg_obj = Mailgun::Client.new("Fake-API-Key") + @mg_obj = Mailgun::UnitClient.new("bounces") @domain = "test.com" end it 'in this case, obtains a list of bounces for the domain, limit of 5, skipping the first 10.' do query_string = {'skip' => '10', 'limit' => '5'} result = @mg_obj.get("#{@domain}/bounces", query_string) - result.to_hash! + result.to_h! result.body.should include("total_count") result.body.should include("items") end end describe 'The method delete()' do before(:each) do - @mg_obj = Mailgun::Client.new("Fake-API-Key") + @mg_obj = Mailgun::UnitClient.new("campaigns") @domain = "test.com" end it 'issues a generic delete request.' do result = @mg_obj.delete("#{@domain}/campaigns/ABC123") - result.to_hash! + result.to_h! result.body.should include("message") result.body.should include("id") end end