spec/constantcontact/services/contact_service_spec.rb in constantcontact-2.0.0 vs spec/constantcontact/services/contact_service_spec.rb in constantcontact-2.0.1
- old
+ new
@@ -5,16 +5,20 @@
# Copyright (c) 2013 Constant Contact. All rights reserved.
require 'spec_helper'
describe ConstantContact::Services::ContactService do
+ before(:each) do
+ @request = double('http request', :user => nil, :password => nil, :url => 'http://example.com', :redirection_history => nil)
+ end
+
describe "#get_contacts" do
it "returns an array of contacts" do
json = load_file('contacts_response.json')
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
- response = RestClient::Response.create(json, net_http_resp, {})
+ response = RestClient::Response.create(json, net_http_resp, {}, @request)
RestClient.stub(:get).and_return(response)
contacts = ConstantContact::Services::ContactService.get_contacts()
contact = contacts.results[0]
contacts.should be_kind_of(ConstantContact::Components::ResultSet)
@@ -25,11 +29,11 @@
describe "#get_contact" do
it "returns a contact" do
json = load_file('contact_response.json')
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
- response = RestClient::Response.create(json, net_http_resp, {})
+ response = RestClient::Response.create(json, net_http_resp, {}, @request)
RestClient.stub(:get).and_return(response)
contact = ConstantContact::Services::ContactService.get_contact(1)
contact.should be_kind_of(ConstantContact::Components::Contact)
end
@@ -38,11 +42,11 @@
describe "#add_contact" do
it "adds a contact" do
json = load_file('contact_response.json')
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
- response = RestClient::Response.create(json, net_http_resp, {})
+ response = RestClient::Response.create(json, net_http_resp, {}, @request)
RestClient.stub(:post).and_return(response)
new_contact = ConstantContact::Components::Contact.create(JSON.parse(json))
contact = ConstantContact::Services::ContactService.add_contact(new_contact)
contact.should be_kind_of(ConstantContact::Components::Contact)
@@ -53,11 +57,11 @@
describe "#delete_contact" do
it "deletes a contact" do
contact_id = 196
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
- response = RestClient::Response.create('', net_http_resp, {})
+ response = RestClient::Response.create('', net_http_resp, {}, @request)
RestClient.stub(:delete).and_return(response)
result = ConstantContact::Services::ContactService.delete_contact(contact_id)
result.should be_true
end
@@ -66,11 +70,11 @@
describe "#delete_contact_from_lists" do
it "deletes a contact" do
contact_id = 196
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
- response = RestClient::Response.create('', net_http_resp, {})
+ response = RestClient::Response.create('', net_http_resp, {}, @request)
RestClient.stub(:delete).and_return(response)
result = ConstantContact::Services::ContactService.delete_contact_from_lists(contact_id)
result.should be_true
end
@@ -80,11 +84,11 @@
it "deletes a contact" do
contact_id = 196
list_id = 1
net_http_resp = Net::HTTPResponse.new(1.0, 204, 'No Content')
- response = RestClient::Response.create('', net_http_resp, {})
+ response = RestClient::Response.create('', net_http_resp, {}, @request)
RestClient.stub(:delete).and_return(response)
result = ConstantContact::Services::ContactService.delete_contact_from_list(contact_id, list_id)
result.should be_true
end
@@ -93,10 +97,10 @@
describe "#update_contact" do
it "updates a contact" do
json = load_file('contact_response.json')
net_http_resp = Net::HTTPResponse.new(1.0, 200, 'OK')
- response = RestClient::Response.create(json, net_http_resp, {})
+ response = RestClient::Response.create(json, net_http_resp, {}, @request)
RestClient.stub(:put).and_return(response)
contact = ConstantContact::Components::Contact.create(JSON.parse(json))
result = ConstantContact::Services::ContactService.update_contact(contact)
result.should be_kind_of(ConstantContact::Components::Contact)
\ No newline at end of file