test/subscriber_test.rb in createsend-0.1.1 vs test/subscriber_test.rb in createsend-0.2.0

- old
+ new

@@ -4,17 +4,17 @@ context "when an api caller is authenticated" do setup do @api_key = '123123123123123123123' CreateSend.api_key @api_key @list_id = "d98h2938d9283d982u3d98u88" - @subscriber = Subscriber.new @list_id, "subscriber@example.com" + @subscriber = CreateSend::Subscriber.new @list_id, "subscriber@example.com" end should "get a subscriber by list id and email address" do email = "subscriber@example.com" stub_get(@api_key, "subscribers/#{@list_id}.json?email=#{CGI.escape(email)}", "subscriber_details.json") - subscriber = Subscriber.get @list_id, email + subscriber = CreateSend::Subscriber.get @list_id, email subscriber.EmailAddress.should == email subscriber.Name.should == "Subscriber One" subscriber.Date.should == "2010-10-25 10:28:00" subscriber.State.should == "Active" subscriber.CustomFields.size.should == 3 @@ -22,29 +22,29 @@ subscriber.CustomFields.first.Value.should == 'http://example.com' end should "add a subscriber without custom fields" do stub_post(@api_key, "subscribers/#{@list_id}.json", "add_subscriber.json") - email_address = Subscriber.add @list_id, "subscriber@example.com", "Subscriber", [], true + email_address = CreateSend::Subscriber.add @list_id, "subscriber@example.com", "Subscriber", [], true email_address.should == "subscriber@example.com" end should "add a subscriber with custom fields" do stub_post(@api_key, "subscribers/#{@list_id}.json", "add_subscriber.json") custom_fields = [ { :Key => 'website', :Value => 'http://example.com/' } ] - email_address = Subscriber.add @list_id, "subscriber@example.com", "Subscriber", custom_fields, true + email_address = CreateSend::Subscriber.add @list_id, "subscriber@example.com", "Subscriber", custom_fields, true email_address.should == "subscriber@example.com" end should "import many subscribers at once" do stub_post(@api_key, "subscribers/#{@list_id}/import.json", "import_subscribers.json") subscribers = [ { :EmailAddress => "example+1@example.com", :Name => "Example One" }, { :EmailAddress => "example+2@example.com", :Name => "Example Two" }, { :EmailAddress => "example+3@example.com", :Name => "Example Three" }, ] - import_result = Subscriber.import @list_id, subscribers, true + import_result = CreateSend::Subscriber.import @list_id, subscribers, true import_result.FailureDetails.size.should == 0 import_result.TotalUniqueEmailsSubmitted.should == 3 import_result.TotalExistingSubscribers.should == 0 import_result.TotalNewSubscribers.should == 3 import_result.DuplicateEmailsInSubmission.size.should == 0 @@ -56,10 +56,10 @@ subscribers = [ { :EmailAddress => "example+1@example", :Name => "Example One" }, { :EmailAddress => "example+2@example.com", :Name => "Example Two" }, { :EmailAddress => "example+3@example.com", :Name => "Example Three" }, ] - import_result = Subscriber.import @list_id, subscribers, true + import_result = CreateSend::Subscriber.import @list_id, subscribers, true import_result.FailureDetails.size.should == 1 import_result.FailureDetails.first.EmailAddress.should == "example+1@example" import_result.FailureDetails.first.Code.should == 1 import_result.FailureDetails.first.Message.should == "Invalid Email Address" import_result.TotalUniqueEmailsSubmitted.should == 3 \ No newline at end of file