streamsend 0.1.2 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,179 @@
1
+ require File.join(File.dirname(__FILE__), "../../../spec_helper")
2
+
3
+ module StreamSend
4
+ module Api
5
+ describe "List" do
6
+ let(:app_host) { "http://test.host" }
7
+ before do
8
+ WebMock.enable!
9
+ stub_http_request(:any, //).to_return(:body => "Page not found.", :status => 404)
10
+
11
+ @username = "scott"
12
+ @password = "topsecret"
13
+ @host = "test.host"
14
+
15
+ xml = <<-XML
16
+ <?xml version="1.0" encoding="UTF-8"?>
17
+ <audiences type="array">
18
+ <audience>
19
+ <id type="integer">2</id>
20
+ </audience>
21
+ </audiences>
22
+ XML
23
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences.xml").to_return(:body => xml)
24
+ StreamSend::Api::List.stub(:audience_id).and_return(2)
25
+
26
+ StreamSend::Api.configure(@username, @password, @host)
27
+ end
28
+
29
+ after do
30
+ WebMock.disable!
31
+ end
32
+
33
+ describe ".audience_id" do
34
+ it "returns the id of the first audience" do
35
+ StreamSend::Api::List.audience_id.should == 2
36
+ end
37
+ end
38
+
39
+ describe ".all" do
40
+ describe "with lists" do
41
+ before(:each) do
42
+ xml = <<-XML
43
+ <?xml version="1.0" encoding="UTF-8"?>
44
+ <lists type="array">
45
+ <list>
46
+ <active-people-count type="integer">11</active-people-count>
47
+ <checked-by-default type="boolean" nil="true"></checked-by-default>
48
+ <created-at type="datetime">2012-01-14T18:11:50Z</created-at>
49
+ <deleted-at type="datetime" nil="true"></deleted-at>
50
+ <description nil="true"></description>
51
+ <id type="integer">42</id>
52
+ <inactive-people-count type="integer">0</inactive-people-count>
53
+ <name>First list</name>
54
+ <pending-people-count type="integer">0</pending-people-count>
55
+ <public type="boolean" nil="true"></public>
56
+ <status type="enum">idle</status>
57
+ <unsubscribed-people-count type="integer">0</unsubscribed-people-count>
58
+ <updated-at type="datetime">2012-01-14T18:11:50Z</updated-at>
59
+ <audience-id type="integer">2</audience-id>
60
+ </list>
61
+ </lists>
62
+ XML
63
+
64
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/lists.xml").to_return(:body => xml)
65
+ end
66
+
67
+ it "should return array of one list object" do
68
+ lists = StreamSend::Api::List.all
69
+ lists.size.should == 1
70
+
71
+ lists.first.should be_instance_of(StreamSend::Api::List)
72
+ lists.first.id.should == 42
73
+ lists.first.name.should == "First list"
74
+ lists.first.created_at.should == Time.parse("2012-01-14T18:11:50Z")
75
+ end
76
+ end
77
+
78
+ describe "with no lists" do
79
+ before(:each) do
80
+ xml = <<-XML
81
+ <?xml version="1.0" encoding="UTF-8"?>
82
+ <lists type="array"/>
83
+ XML
84
+
85
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/lists.xml").to_return(:body => xml)
86
+ end
87
+
88
+ it "should return an empty array" do
89
+ StreamSend::Api::List.all.should == []
90
+ end
91
+ end
92
+
93
+ describe "with invalid audience" do
94
+ before(:each) do
95
+ xml = <<-XML
96
+ <?xml version="1.0" encoding="UTF-8"?>
97
+ <people type="array"/>
98
+ XML
99
+
100
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/99/people.xml").to_return(:body => xml)
101
+ end
102
+
103
+ it "should raise an exception" do
104
+ lambda { StreamSend::Api::List.all }.should raise_error
105
+ end
106
+ end
107
+ end
108
+
109
+ describe ".find" do
110
+ describe "with matching list" do
111
+ before(:each) do
112
+ xml = <<-XML
113
+ <?xml version="1.0" encoding="UTF-8"?>
114
+ <list>
115
+ <active-people-count type="integer">11</active-people-count>
116
+ <checked-by-default type="boolean" nil="true"></checked-by-default>
117
+ <created-at type="datetime">2012-01-14T18:11:50Z</created-at>
118
+ <deleted-at type="datetime" nil="true"></deleted-at>
119
+ <description nil="true"></description>
120
+ <id type="integer">42</id>
121
+ <inactive-people-count type="integer">0</inactive-people-count>
122
+ <name>First list</name>
123
+ <pending-people-count type="integer">0</pending-people-count>
124
+ <public type="boolean" nil="true"></public>
125
+ <status type="enum">idle</status>
126
+ <unsubscribed-people-count type="integer">0</unsubscribed-people-count>
127
+ <updated-at type="datetime">2012-01-14T18:11:50Z</updated-at>
128
+ <audience-id type="integer">2</audience-id>
129
+ </list>
130
+ XML
131
+
132
+ stub_http_request(:get, /audiences\/2\/lists\/42.xml/).with(:id => "42").to_return(:body => xml)
133
+ end
134
+
135
+ it "should return list" do
136
+ list = StreamSend::Api::List.find(42)
137
+
138
+ list.should be_instance_of(StreamSend::Api::List)
139
+ list.id.should == 42
140
+ list.name.should == "First list"
141
+ list.created_at.should == Time.parse("2012-01-14T18:11:50Z")
142
+ end
143
+ end
144
+
145
+ describe "with no matching list" do
146
+ before(:each) do
147
+ xml = <<-XML
148
+ <?xml version="1.0" encoding="UTF-8"?>
149
+ <lists type="array"\>
150
+ XML
151
+
152
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/people.xml?email_address=bad.email@gmail.com").to_return(:status => 404)
153
+ end
154
+
155
+ it "should return throw an exception" do
156
+ lambda {
157
+ StreamSend::Api::List.find(-1)
158
+ }.should raise_error
159
+ end
160
+ end
161
+
162
+ describe "with invalid audience" do
163
+ before(:each) do
164
+ xml = <<-XML
165
+ <?xml version="1.0" encoding="UTF-8"?>
166
+ <people type="array"\>
167
+ XML
168
+
169
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/99/people.xml?email_address=bad.email@gmail.com").to_return(:body => xml)
170
+ end
171
+
172
+ it "should raise an exception" do
173
+ lambda { StreamSend::Api::List.find("scott@gmail.com") }.should raise_error
174
+ end
175
+ end
176
+ end
177
+ end
178
+ end
179
+ end
@@ -0,0 +1,24 @@
1
+ require File.join(File.dirname(__FILE__), "../../../spec_helper")
2
+
3
+ module StreamSend
4
+ module Api
5
+ describe "Resource" do
6
+ describe "with missing method" do
7
+ before(:each) do
8
+ @resource = StreamSend::Api::Resource.new({"name" => "scott"})
9
+ end
10
+
11
+ it "should return value" do
12
+ @resource.name.should == "scott"
13
+ end
14
+ end
15
+
16
+ describe "#id" do
17
+ it "should return id" do
18
+ StreamSend::Api::Resource.new({"id" => 99}).id.should == 99
19
+ end
20
+ end
21
+
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,274 @@
1
+ require File.join(File.dirname(__FILE__), "../../../spec_helper")
2
+ require "ostruct"
3
+
4
+ module StreamSend
5
+ module Api
6
+ describe "Subscriber" do
7
+ before do
8
+ WebMock.enable!
9
+ stub_http_request(:any, //).to_return(:body => "Page not found.", :status => 404)
10
+
11
+ @username = "scott"
12
+ @password = "topsecret"
13
+ @host = "test.host"
14
+
15
+ xml = <<-XML
16
+ <?xml version="1.0" encoding="UTF-8"?>
17
+ <audiences type="array">
18
+ <audience>
19
+ <id type="integer">2</id>
20
+ </audience>
21
+ </audiences>
22
+ XML
23
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences.xml").to_return(:body => xml)
24
+
25
+ StreamSend::Api.configure(@username, @password, @host)
26
+ end
27
+
28
+ after do
29
+ WebMock.disable!
30
+ end
31
+
32
+ describe ".audience_id" do
33
+ it "should return the id of the first audience" do
34
+ StreamSend::Api::Subscriber.audience_id.should == 2
35
+ end
36
+ end
37
+
38
+ describe ".clear_audience" do
39
+ it "allows the audience_id to be retrieved again" do
40
+ @resource = StreamSend::Api::Resource.new({"name" => "jeff"})
41
+ StreamSend::Api.should_receive(:get).with("/audiences.xml").and_return(OpenStruct.new(:parsed_response => { "audiences" => [{"id" => 2}] }))
42
+ StreamSend::Api::Resource.audience_id.should == 2
43
+ StreamSend::Api.should_receive(:get).with("/audiences.xml").and_return(OpenStruct.new(:parsed_response => { "audiences" => [{"id" => 1}] }))
44
+ StreamSend::Api::Resource.audience_id.should == 2
45
+ StreamSend::Api::Resource.clear_audience
46
+ StreamSend::Api::Resource.audience_id.should == 1
47
+ end
48
+ end
49
+
50
+ describe ".all" do
51
+ describe "with subscribers" do
52
+ before(:each) do
53
+ xml = <<-XML
54
+ <?xml version="1.0" encoding="UTF-8"?>
55
+ <people type="array">
56
+ <person>
57
+ <id type="integer">2</id>
58
+ <email-address>scott@gmail.com</email-address>
59
+ <created-at type="datetime">2009-09-18T01:27:05Z</created-at>
60
+ </person>
61
+ </people>
62
+ XML
63
+
64
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/people.xml").to_return(:body => xml)
65
+ end
66
+
67
+ it "should return array of one subscriber object" do
68
+ subscribers = StreamSend::Api::Subscriber.all
69
+ subscribers.size.should == 1
70
+
71
+ subscribers.first.should be_instance_of(StreamSend::Api::Subscriber)
72
+ subscribers.first.id.should == 2
73
+ subscribers.first.email_address.should == "scott@gmail.com"
74
+ subscribers.first.created_at.should == Time.parse("2009-09-18T01:27:05Z")
75
+ end
76
+ end
77
+
78
+ describe "with no subscribers" do
79
+ before(:each) do
80
+ xml = <<-XML
81
+ <?xml version="1.0" encoding="UTF-8"?>
82
+ <people type="array"/>
83
+ XML
84
+
85
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/people.xml").to_return(:body => xml)
86
+ end
87
+
88
+ it "should return an empty array" do
89
+ StreamSend::Api::Subscriber.all.should == []
90
+ end
91
+ end
92
+
93
+ describe "with invalid audience" do
94
+ before(:each) do
95
+ xml = <<-XML
96
+ <?xml version="1.0" encoding="UTF-8"?>
97
+ <people type="array"/>
98
+ XML
99
+
100
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/99/people.xml").to_return(:body => xml)
101
+ end
102
+
103
+ it "should raise an exception" do
104
+ lambda { StreamSend::Api::Subscriber.all }.should raise_error
105
+ end
106
+ end
107
+ end
108
+
109
+ describe ".find" do
110
+ describe "with matching subscriber" do
111
+ before(:each) do
112
+ xml = <<-XML
113
+ <?xml version="1.0" encoding="UTF-8"?>
114
+ <people type="array">
115
+ <person>
116
+ <id type="integer">2</id>
117
+ <email-address>scott@gmail.com</email-address>
118
+ <created-at type="datetime">2009-09-18T01:27:05Z</created-at>
119
+ </person>
120
+ </people>
121
+ XML
122
+
123
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/2/people.xml?email_address=scott@gmail.com").to_return(:body => xml)
124
+ end
125
+
126
+ it "should return subscriber" do
127
+ subscriber = StreamSend::Api::Subscriber.find("scott@gmail.com")
128
+
129
+ subscriber.should be_instance_of(StreamSend::Api::Subscriber)
130
+ subscriber.id.should == 2
131
+ subscriber.email_address.should == "scott@gmail.com"
132
+ subscriber.created_at.should == Time.parse("2009-09-18T01:27:05Z")
133
+ end
134
+ end
135
+
136
+ describe "with invalid audience" do
137
+ before(:each) do
138
+ xml = <<-XML
139
+ <?xml version="1.0" encoding="UTF-8"?>
140
+ <people type="array"\>
141
+ XML
142
+
143
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/99/people.xml?email_address=bad.email@gmail.com").to_return(:body => xml)
144
+ end
145
+
146
+ it "should raise an exception" do
147
+ lambda { StreamSend::Api::Subscriber.find("scott@gmail.com") }.should raise_error
148
+ end
149
+ end
150
+ end
151
+
152
+ describe ".create" do
153
+ describe "with valid subscriber parameters" do
154
+ describe "with no existing subscribers using the given email address" do
155
+ before(:each) do
156
+ stub_http_request(:post, /audiences\/2\/people.xml/).with(:person => {"email_address" => "foo@bar.com", "first_name" => "JoeBob"}).to_return(:body => "", :headers => {"location" => "http://test.host/audiences/2/people/1"}, :status => 201)
157
+ end
158
+
159
+ it "should return the new subscriber's id" do
160
+ subscriber_id = StreamSend::Api::Subscriber.create({"email_address" => "foo@bar.com", "first_name" => "JoeBob"})
161
+
162
+ subscriber_id.should_not be_nil
163
+ subscriber_id.should == 1
164
+ end
165
+ end
166
+
167
+ describe "with an existing subscriber using the given email address" do
168
+ before(:each) do
169
+ stub_http_request(:post, /audiences\/2\/people.xml/).with(:person => {"email_address" => "foo@bar.com", "first_name" => "JoeBob"}).to_return(:body => "<error>Email address has already been taken<error>")
170
+ end
171
+
172
+ it "should raise an exception" do
173
+ lambda {
174
+ subscriber_id = StreamSend::Api::Subscriber.create({"email_address" => "foo@bar.com", "first_name" => "JoeBob"})
175
+ }.should raise_error
176
+ end
177
+ end
178
+ end
179
+
180
+ describe "with invalid subscriber parameters" do
181
+ before(:each) do
182
+ stub_http_request(:post, /audiences\/2\/people.xml/).with({"email_address" => "foo.com", "first_name" => "JoeBob"}).to_return(:body => "<error>Email address does not appear to be valid</error>")
183
+ end
184
+
185
+ it "should raise an exception" do
186
+ lambda {
187
+ subscriber_id = StreamSend::Api::Subscriber.create({"email_address" => "foo@bar.com", "first_name" => "JoeBob"})
188
+ }.should raise_error
189
+ end
190
+ end
191
+ end
192
+
193
+ describe "#show" do
194
+ describe "with valid subscriber instance" do
195
+ before(:each) do
196
+ xml = <<-XML
197
+ <?xml version="1.0" encoding="UTF-8"?>
198
+ <person>
199
+ <id type="integer">2</id>
200
+ <email-address>scott@gmail.com</email-address>
201
+ <created-at type="datetime">2009-09-18T01:27:05Z</created-at>
202
+ <first-name>Scott</first-name>
203
+ <last-name>Albertson</last-name>
204
+ </person>
205
+ XML
206
+
207
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/audiences/1/people/2.xml").to_return(:body => xml)
208
+ end
209
+
210
+ it "should return subscriber" do
211
+ subscriber = StreamSend::Api::Subscriber.new({"id" => 2, "audience_id" => 1}).show
212
+
213
+ subscriber.should be_instance_of(StreamSend::Api::Subscriber)
214
+ subscriber.id.should == 2
215
+ subscriber.email_address.should == "scott@gmail.com"
216
+ subscriber.created_at.should == Time.parse("2009-09-18T01:27:05Z")
217
+ subscriber.first_name.should == "Scott"
218
+ subscriber.last_name.should == "Albertson"
219
+ end
220
+ end
221
+
222
+ describe "with invalid subscriber instance" do
223
+ it "should raise exception" do
224
+ lambda { StreamSend::Api::Subscriber.new({"id" => 99, "audience_id" => 1}).show }.should raise_error
225
+ end
226
+ end
227
+
228
+ describe "with invalid audience" do
229
+ it "should raise exception" do
230
+ lambda { StreamSend::Api::Subscriber.new({"id" => 2}).show }.should raise_error
231
+ end
232
+ end
233
+ end
234
+
235
+ describe "#activate" do
236
+ before(:each) do
237
+ stub_http_request(:post, "http://#{@username}:#{@password}@#{@host}/audiences/1/people/2/activate.xml").to_return(:body => nil)
238
+ end
239
+
240
+ describe "with valid subscriber" do
241
+ it "should be successful" do
242
+ response = StreamSend::Api::Subscriber.new({"id" => 2, "audience_id" => 1}).activate
243
+ response.should be_true
244
+ end
245
+ end
246
+
247
+ describe "with invalid subscriber" do
248
+ it "should raise exception" do
249
+ lambda { StreamSend::Api::Subscriber.new({"id" => 99, "audience_id" => 1}).activate }.should raise_error
250
+ end
251
+ end
252
+ end
253
+
254
+ describe "#unsubscribe" do
255
+ before(:each) do
256
+ stub_http_request(:post, "http://#{@username}:#{@password}@#{@host}/audiences/1/people/2/unsubscribe.xml").to_return(:body => nil)
257
+ end
258
+
259
+ describe "with valid subscriber" do
260
+ it "should be successful" do
261
+ response = StreamSend::Api::Subscriber.new({"id" => 2, "audience_id" => 1}).unsubscribe
262
+ response.should be_true
263
+ end
264
+ end
265
+
266
+ describe "with invalid subscriber" do
267
+ it "should raise exception" do
268
+ lambda { StreamSend::Api::Subscriber.new({"id" => 99, "audience_id" => 1}).unsubscribe }.should raise_error
269
+ end
270
+ end
271
+ end
272
+ end
273
+ end
274
+ end
@@ -0,0 +1,149 @@
1
+ require File.join(File.dirname(__FILE__), "../../../spec_helper")
2
+ require "webmock"
3
+ require "active_support/core_ext/hash"
4
+
5
+ module StreamSend
6
+ module Api
7
+ describe "User" do
8
+ let(:app_host) { "http://test.host" }
9
+
10
+ before do
11
+ WebMock.enable!
12
+ @username = "jeff"
13
+ @password = "topsecret"
14
+ @host = "test.host"
15
+ StreamSend::Api.configure(@username, @password, @host)
16
+ end
17
+
18
+ after do
19
+ WebMock.disable!
20
+ end
21
+
22
+ describe "#all" do
23
+ describe "with two users" do
24
+ before do
25
+ users = <<-XML
26
+ <?xml version="1.0" encoding="UTF-8"?>
27
+ <users type="array">
28
+ <user>
29
+ <administrator type="boolean">true</administrator>
30
+ <title>Administrator</title>
31
+ <last-name>User</last-name>
32
+ <updated-at type="datetime">2012-11-29T17:14:55-08:00</updated-at>
33
+ <may-export type="boolean">true</may-export>
34
+ <id type="integer">1</id>
35
+ <email-address>admin@streamsend.com</email-address>
36
+ <first-name>Admin</first-name>
37
+ <company-name>Not Random BS</company-name>
38
+ <created-at type="datetime">2012-11-29T17:14:55-08:00</created-at>
39
+ </user>
40
+
41
+ <user>
42
+ <administrator type="boolean">false</administrator>
43
+ <title>regular user</title>
44
+ <last-name>User2</last-name>
45
+ <updated-at type="datetime">2012-11-29T17:14:55-08:00</updated-at>
46
+ <may-export type="boolean">true</may-export>
47
+ <id type="integer">1</id>
48
+ <email-address>joe@streamsend.com</email-address>
49
+ <first-name>Joe</first-name>
50
+ <company-name>Not Random BS</company-name>
51
+ <created-at type="datetime">2012-11-29T17:14:55-08:00</created-at>
52
+ </user>
53
+ </users>
54
+ XML
55
+
56
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/users.xml").to_return(:body => users)
57
+ end
58
+
59
+ it "should return an array of two users" do
60
+ users = StreamSend::Api::User.all
61
+ users.size.should == 2
62
+ end
63
+
64
+ it "should return an array with the two users" do
65
+ users = StreamSend::Api::User.all
66
+ users.first.id.should == 1
67
+ end
68
+ end
69
+
70
+ describe "with no users" do
71
+ before do
72
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/users.xml").to_return(:body => "Page not found.", :status => 404)
73
+ end
74
+
75
+ it "should raise an error" do
76
+ lambda do
77
+ users = StreamSend::Api::User.all
78
+ end.should raise_error
79
+ end
80
+
81
+ end
82
+ end
83
+
84
+ describe "#show" do
85
+ describe "with a single user" do
86
+ before do
87
+ xml = <<-XML
88
+ <?xml version="1.0" encoding="UTF-8"?>
89
+ <user>
90
+ <id>2</id>
91
+ <email-address>john2@example.com</email-address>
92
+ <first-name>John2</first-name>
93
+ <last-name>Doe</last-name>
94
+ </user>
95
+ XML
96
+ stub_http_request(:get, "http://#{@username}:#{@password}@#{@host}/users/2.xml").to_return(:body => xml)
97
+ end
98
+
99
+ it "returns the user" do
100
+ user = StreamSend::Api::User.show(2)
101
+ user.id.should == "2"
102
+ user.first_name.should == "John2"
103
+ end
104
+ end
105
+
106
+ describe "with an invalid user" do
107
+ before do
108
+ stub_http_request(:post, "http://#{@username}:#{@password}@#{@host}/users/2.xml").to_return(:body => "Page not found.")
109
+ end
110
+
111
+ it "should raise an error" do
112
+ lambda do
113
+ user = StreamSend::Api::User.show(30)
114
+ end.should raise_error
115
+ end
116
+ end
117
+ end
118
+
119
+ describe ".create" do
120
+ describe "with valid user parameters" do
121
+ describe "with an existing users" do
122
+ before(:each) do
123
+ stub_http_request(:post, /accounts\/1\/users.xml/).with(:person => {"email_address" => "foo@bar.com", "first_name" => "JoeBob"}).to_return(:body => "", :headers => {"location" => "http://test.host/accounts/2/users/1"}, :status => 201)
124
+ end
125
+
126
+ it "should return the new user's id" do
127
+ user_id = StreamSend::Api::User.create({"account_id" => 1, "email_address" => "foo@bar.com", "first_name" => "JoeBob"})
128
+
129
+ user_id.should_not be_nil
130
+ user_id.should == 1
131
+ end
132
+ end
133
+ end
134
+
135
+ describe "with invalid user parameters" do
136
+ before(:each) do
137
+ stub_http_request(:post, "/account/1/users.xml").with(:person => {"email_address" => "foo@bar.com", "first_name" => "JoeBob"}).to_return(:status => 422)
138
+ end
139
+
140
+ it "should raise an error" do
141
+ lambda do
142
+ user_id = StreamSend::Api::User.create({"account_id" => 1, "email_address" => "foo@bar.com", "first_name" => "JoeBob"})
143
+ end.should raise_error
144
+ end
145
+ end
146
+ end
147
+ end
148
+ end
149
+ end
@@ -0,0 +1,31 @@
1
+ require "spec_helper"
2
+
3
+ describe StreamSend::Api do
4
+ describe ".configure" do
5
+ let( :test_host ) { "http://host.example.com" }
6
+ let( :test_user ) { "John+Carter@example.com" }
7
+ let( :test_password ) { "this-is-a-really-secure-password" }
8
+
9
+ it "should set username" do
10
+ StreamSend::Api.configure( test_user, test_password )
11
+ StreamSend::Api.default_options[:basic_auth][:username].should == test_user
12
+ end
13
+
14
+ it "should set password" do
15
+ StreamSend::Api.configure( test_user, test_password )
16
+ StreamSend::Api.default_options[:basic_auth][:password].should == test_password
17
+ end
18
+
19
+ context "host" do
20
+ it "sets the host when specified" do
21
+ StreamSend::Api.configure( test_user, test_password, test_host )
22
+ StreamSend::Api.base_uri.should == test_host
23
+ end
24
+
25
+ it "uses the default host when not specified" do
26
+ StreamSend::Api.configure( test_user, test_password )
27
+ StreamSend::Api.base_uri.should == "http://app.streamsend.com"
28
+ end
29
+ end
30
+ end
31
+ end
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,17 @@
1
1
  require 'uri'
2
2
  require 'rspec/expectations'
3
- require 'webmock/rspec'
3
+ require "vcr"
4
+ require "webmock/rspec"
4
5
 
5
6
  require File.join(File.dirname(__FILE__), "../lib/streamsend")
7
+
8
+ VCR.configure do |c|
9
+ c.default_cassette_options = { :record => :new_episodes }
10
+ c.cassette_library_dir = 'spec/integration/fixtures/vcr_cassettes'
11
+ c.hook_into :webmock
12
+ c.debug_logger = File.open("logfile.log", "w")
13
+ c.filter_sensitive_data("<STREAMSEND_PASSWORD>") do
14
+ ENV['STREAMSEND_PASSWORD']
15
+ end
16
+ end
17
+