twilio-test-toolkit2 3.4.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.
Files changed (55) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +260 -0
  4. data/Rakefile +38 -0
  5. data/lib/twilio-test-toolkit/call_in_progress.rb +56 -0
  6. data/lib/twilio-test-toolkit/call_scope.rb +243 -0
  7. data/lib/twilio-test-toolkit/dsl.rb +15 -0
  8. data/lib/twilio-test-toolkit/version.rb +3 -0
  9. data/lib/twilio-test-toolkit.rb +4 -0
  10. data/spec/dummy/README.rdoc +261 -0
  11. data/spec/dummy/Rakefile +7 -0
  12. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  13. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  14. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  15. data/spec/dummy/app/controllers/twilio_controller.rb +8 -0
  16. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  17. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  18. data/spec/dummy/app/views/layouts/twilio.layout.xml.erb +4 -0
  19. data/spec/dummy/app/views/twilio/test_action.xml.erb +2 -0
  20. data/spec/dummy/app/views/twilio/test_dial_with_action.xml.erb +3 -0
  21. data/spec/dummy/app/views/twilio/test_dial_with_no_action.xml.erb +3 -0
  22. data/spec/dummy/app/views/twilio/test_dial_with_sip.xml +6 -0
  23. data/spec/dummy/app/views/twilio/test_gather_finish_on_asterisk.xml.erb +3 -0
  24. data/spec/dummy/app/views/twilio/test_hangup.xml.erb +1 -0
  25. data/spec/dummy/app/views/twilio/test_play.xml.erb +1 -0
  26. data/spec/dummy/app/views/twilio/test_record.xml +2 -0
  27. data/spec/dummy/app/views/twilio/test_redirect.xml.erb +1 -0
  28. data/spec/dummy/app/views/twilio/test_say.xml.erb +1 -0
  29. data/spec/dummy/app/views/twilio/test_start.xml.erb +5 -0
  30. data/spec/dummy/config/application.rb +59 -0
  31. data/spec/dummy/config/boot.rb +10 -0
  32. data/spec/dummy/config/database.yml +25 -0
  33. data/spec/dummy/config/environment.rb +5 -0
  34. data/spec/dummy/config/environments/development.rb +37 -0
  35. data/spec/dummy/config/environments/production.rb +67 -0
  36. data/spec/dummy/config/environments/test.rb +37 -0
  37. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  38. data/spec/dummy/config/initializers/inflections.rb +15 -0
  39. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  40. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  41. data/spec/dummy/config/initializers/session_store.rb +8 -0
  42. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  43. data/spec/dummy/config/locales/en.yml +5 -0
  44. data/spec/dummy/config/routes.rb +16 -0
  45. data/spec/dummy/config.ru +4 -0
  46. data/spec/dummy/db/schema.rb +16 -0
  47. data/spec/dummy/public/404.html +26 -0
  48. data/spec/dummy/public/422.html +26 -0
  49. data/spec/dummy/public/500.html +25 -0
  50. data/spec/dummy/public/favicon.ico +0 -0
  51. data/spec/dummy/script/rails +6 -0
  52. data/spec/requests/call_scope_spec.rb +388 -0
  53. data/spec/requests/dsl_spec.rb +54 -0
  54. data/spec/spec_helper.rb +20 -0
  55. metadata +226 -0
@@ -0,0 +1,5 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Add new mime types for use in respond_to blocks:
4
+ # Mime::Type.register "text/richtext", :rtf
5
+ # Mime::Type.register_alias "text/html", :iphone
@@ -0,0 +1,7 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ # Your secret key for verifying the integrity of signed cookies.
4
+ # If you change this key, all old signed cookies will become invalid!
5
+ # Make sure the secret is at least 30 characters and all random,
6
+ # no regular words or you'll be exposed to dictionary attacks.
7
+ Dummy::Application.config.secret_token = 'a97e0b618b2e11a39b0c155d46c6f8e0f15a17edcd595e3baca48956a204ef15d988fd26274e0180192058ad8cbb9df002f6341acb8e92075798ea4e278d6561'
@@ -0,0 +1,8 @@
1
+ # Be sure to restart your server when you modify this file.
2
+
3
+ Dummy::Application.config.session_store :cookie_store, key: '_dummy_session'
4
+
5
+ # Use the database for sessions instead of the cookie-based default,
6
+ # which shouldn't be used to store highly confidential information
7
+ # (create the session table with "rails generate session_migration")
8
+ # Dummy::Application.config.session_store :active_record_store
@@ -0,0 +1,14 @@
1
+ # Be sure to restart your server when you modify this file.
2
+ #
3
+ # This file contains settings for ActionController::ParamsWrapper which
4
+ # is enabled by default.
5
+
6
+ # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
+ ActiveSupport.on_load(:action_controller) do
8
+ wrap_parameters format: [:json]
9
+ end
10
+
11
+ # Disable root element in JSON by default.
12
+ ActiveSupport.on_load(:active_record) do
13
+ self.include_root_in_json = false
14
+ end
@@ -0,0 +1,5 @@
1
+ # Sample localization file for English. Add more files in this directory for other locales.
2
+ # See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
3
+
4
+ en:
5
+ hello: "Hello world"
@@ -0,0 +1,16 @@
1
+ Dummy::Application.routes.draw do
2
+ resources :twilio do
3
+ get "test_start", :on => :collection
4
+ post "test_start", :on => :collection
5
+ post "test_action", :on => :collection
6
+ post "test_gather_finish_on_asterisk", :on => :collection
7
+ post "test_hangup", :on => :collection
8
+ post "test_dial_with_no_action", :on => :collection
9
+ post "test_dial_with_action", :on => :collection
10
+ post "test_dial_with_sip", :on => :collection
11
+ post "test_redirect", :on => :collection
12
+ post "test_say", :on => :collection
13
+ post "test_play", :on => :collection
14
+ post "test_record", :on => :collection
15
+ end
16
+ end
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require ::File.expand_path('../config/environment', __FILE__)
4
+ run Dummy::Application
@@ -0,0 +1,16 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended to check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(:version => 0) do
15
+
16
+ end
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,388 @@
1
+ require 'spec_helper'
2
+
3
+ describe TwilioTestToolkit::CallScope do
4
+ before(:each) do
5
+ @our_number = "2065551212"
6
+ @their_number = "2065553434"
7
+ end
8
+
9
+ describe "basics" do
10
+ before(:each) do
11
+ @call = ttt_call(test_start_twilio_index_path, @our_number, @their_number)
12
+ end
13
+
14
+ it "should be a CallScope" do
15
+ @call.should be_a(TwilioTestToolkit::CallScope)
16
+ end
17
+
18
+ it "should have the informational methods" do
19
+ @call.should respond_to(:current_path)
20
+ @call.should respond_to(:response_xml)
21
+ end
22
+
23
+ it "should have the right path" do
24
+ @call.current_path.should == test_start_twilio_index_path
25
+ end
26
+
27
+ it "should have a response xml value" do
28
+ @call.response_xml.should_not be_blank
29
+ end
30
+
31
+ it "should have the right root call" do
32
+ @call.should respond_to(:root_call)
33
+ @call.root_call.should == @call
34
+ end
35
+ end
36
+
37
+ describe "redirect" do
38
+ describe "success" do
39
+ before(:each) do
40
+ @call = ttt_call(test_redirect_twilio_index_path, @our_number, @their_number)
41
+ end
42
+
43
+ it "should have the redirect methods" do
44
+ @call.should respond_to(:has_redirect?)
45
+ @call.should respond_to(:has_redirect_to?)
46
+ @call.should respond_to(:follow_redirect)
47
+ @call.should respond_to(:follow_redirect!)
48
+ end
49
+
50
+ it "should have the right value for has_redirect?" do
51
+ @call.should have_redirect
52
+ end
53
+
54
+ it "should have the right values for has_redirect_to?" do
55
+ @call.has_redirect_to?("http://foo").should be_false
56
+ @call.has_redirect_to?(test_start_twilio_index_path).should be_true
57
+ @call.has_redirect_to?(test_start_twilio_index_path + ".xml").should be_true # Should force normalization
58
+ end
59
+
60
+ it "should follow the redirect (immutable version)" do
61
+ # follow_redirect returns a new CallScope
62
+ newcall = @call.follow_redirect
63
+
64
+ # Make sure it followed
65
+ newcall.current_path.should == test_start_twilio_index_path
66
+
67
+ # And is not the same call
68
+ newcall.response_xml.should_not == @call.response_xml
69
+ # But it's linked
70
+ newcall.root_call.should == @call
71
+
72
+ # And we did not modify the original call
73
+ @call.current_path.should == test_redirect_twilio_index_path
74
+ end
75
+
76
+ it "should follow the redirect (mutable version)" do
77
+ # follow_redirect! modifies the CallScope
78
+ @call.follow_redirect!
79
+
80
+ # Make sure it followed
81
+ @call.current_path.should == test_start_twilio_index_path
82
+ end
83
+
84
+ it "should submit default params on follow_redirect" do
85
+ default_request_params = {
86
+ :format => :xml,
87
+ :From => "2065551212",
88
+ :Digits => "",
89
+ :To => "2065553434",
90
+ :AnsweredBy => "human",
91
+ :CallStatus => "in-progress"
92
+ }
93
+ Capybara.current_session.driver
94
+ .should_receive(:post)
95
+ .with("/twilio/test_start", hash_including(default_request_params))
96
+ .and_call_original
97
+
98
+ @call.follow_redirect
99
+ end
100
+
101
+ it "should consider options for follow_redirect!" do
102
+ Capybara.current_session.driver
103
+ .should_receive(:post)
104
+ .with("/twilio/test_start", hash_including(:CallStatus => "completed"))
105
+ .and_call_original
106
+
107
+ @call.follow_redirect!(call_status: "completed")
108
+ end
109
+
110
+ it "should consider options for follow_redirect" do
111
+ Capybara.current_session.driver
112
+ .should_receive(:post)
113
+ .with("/twilio/test_start", hash_including(:CallStatus => "completed"))
114
+ .and_call_original
115
+
116
+ @call.follow_redirect(call_status: "completed")
117
+ end
118
+ end
119
+
120
+ describe "failure" do
121
+ before(:each) do
122
+ # Initiate a call that's not on a redirect - various calls will fail
123
+ @call = ttt_call(test_say_twilio_index_path, @our_number, @their_number)
124
+ end
125
+
126
+ it "should have the right value for has_redirect?" do
127
+ @call.should_not have_redirect
128
+ end
129
+
130
+ it "should have the right values for has_redirect_to?" do
131
+ @call.has_redirect_to?("http://foo").should be_false
132
+ @call.has_redirect_to?(test_start_twilio_index_path).should be_false
133
+ @call.has_redirect_to?(test_start_twilio_index_path + ".xml").should be_false
134
+ end
135
+
136
+ it "should raise an error on follow_redirect" do
137
+ lambda {@call.follow_redirect}.should raise_error
138
+ end
139
+
140
+ it "should raise an error on follow_redirect!" do
141
+ lambda {@call.follow_redirect!}.should raise_error
142
+ end
143
+ end
144
+ end
145
+
146
+ describe "say" do
147
+ before(:each) do
148
+ @call = ttt_call(test_say_twilio_index_path, @our_number, @their_number)
149
+ end
150
+
151
+ it "should have the expected say methods" do
152
+ @call.should respond_to(:has_say?)
153
+ end
154
+
155
+ it "should have the right values for has_say?" do
156
+ @call.has_say?("Blah blah").should be_false
157
+ @call.has_say?("This is a say page.").should be_true
158
+ @call.has_say?("This is").should be_true # Partial match
159
+ end
160
+ end
161
+
162
+ describe "play" do
163
+ before(:each) do
164
+ @call = ttt_call(test_play_twilio_index_path, @our_number, @their_number)
165
+ end
166
+
167
+ it "should have the expected say play methods" do
168
+ @call.should respond_to(:has_play?)
169
+ end
170
+
171
+ it "should have the right values for has_say?" do
172
+ @call.has_play?("/path/to/a/different/audio/clip.mp3").should be_false
173
+ @call.has_play?("/path/to/an/audio/clip.mp3").should be_true
174
+ @call.has_play?("clip.mp3").should be_false
175
+ end
176
+ end
177
+
178
+ describe "dial" do
179
+ before(:each) do
180
+ @call = ttt_call(test_dial_with_action_twilio_index_path, @our_number, @their_number)
181
+ end
182
+
183
+ it "should have the expected dial methods" do
184
+ @call.should respond_to(:has_dial?)
185
+ end
186
+
187
+ it "should have the right values for has_dial?" do
188
+ @call.has_dial?("911").should be_false
189
+ @call.has_dial?("18001234567").should be_true
190
+ @call.has_dial?("12345").should be_true # Partial match
191
+ end
192
+
193
+ it "should not match the dial action if there isn't one" do
194
+ @call = ttt_call(test_dial_with_no_action_twilio_index_path, @our_number, @their_number)
195
+
196
+ @call.has_action_on_dial?("http://example.org:3000/call_me_back").should eq false
197
+ end
198
+
199
+ it "should match the action on dial if there is one" do
200
+ @call.has_action_on_dial?("http://example.org:3000/call_me_back").should be_true
201
+ end
202
+
203
+ it "should not match the action on dial if it's different than the one specified" do
204
+ @call.has_action_on_dial?("http://example.org:3000/dont_call").should be_false
205
+ end
206
+
207
+ it "should dial a sip peer with the correct structure" do
208
+ @call = ttt_call(test_dial_with_sip_twilio_index_path, @our_number, @their_number)
209
+ @call.within_dial do |dial|
210
+ dial.has_sip?.should be_true
211
+ dial.within_sip do |sip|
212
+ sip.has_uri?("18885551234@sip.foo.bar").should be_true
213
+ sip.has_username_on_uri?("foo").should be_true
214
+ sip.has_password_on_uri?("bar").should be_true
215
+ end
216
+ end
217
+ end
218
+ end
219
+
220
+ describe "hangup" do
221
+ describe "success" do
222
+ before(:each) do
223
+ @call = ttt_call(test_hangup_twilio_index_path, @our_number, @their_number)
224
+ end
225
+
226
+ it "should have the expected hangup methods" do
227
+ @call.should respond_to(:has_hangup?)
228
+ end
229
+
230
+ it "should have the right value for has_hangup?" do
231
+ @call.should have_hangup
232
+ end
233
+ end
234
+
235
+ describe "failure" do
236
+ before(:each) do
237
+ @call = ttt_call(test_start_twilio_index_path, @our_number, @their_number)
238
+ end
239
+
240
+ it "should have the right value for has_hangup?" do
241
+ @call.should_not have_hangup
242
+ end
243
+ end
244
+ end
245
+
246
+ describe "gather" do
247
+ describe "success" do
248
+ before(:each) do
249
+ @call = ttt_call(test_start_twilio_index_path, @our_number, @their_number)
250
+ end
251
+
252
+ it "should have the expected gather methods" do
253
+ @call.should respond_to(:has_gather?)
254
+ @call.should respond_to(:within_gather)
255
+ @call.should respond_to(:gather?)
256
+ @call.should respond_to(:gather_action)
257
+ @call.should respond_to(:press)
258
+ end
259
+
260
+ it "should have the right value for has_gather?" do
261
+ @call.has_gather?.should be_true
262
+ end
263
+
264
+ it "should have the right value for gather?" do
265
+ # Although we have a gather, the current call scope is not itself a gather, so this returns false.
266
+ @call.gather?.should be_false
267
+ end
268
+
269
+ it "should fail on gather-scoped methods outside of a gather scope" do
270
+ lambda {@call.gather_action}.should raise_error
271
+ lambda {@call.press "1234"}.should raise_error
272
+ end
273
+
274
+ it "should gather" do
275
+ # We should not have a say that's contained within a gather.
276
+ @call.should_not have_say("Please enter some digits.")
277
+
278
+ # Now enter the gather block.
279
+ @call.within_gather do |gather|
280
+ # We should have a say here
281
+ gather.should have_say("Please enter some digits.")
282
+
283
+ # We should be in a gather
284
+ gather.gather?.should be_true
285
+ # And we should have an action
286
+ gather.gather_action.should == test_action_twilio_index_path
287
+
288
+ # And we should have the right root call
289
+ gather.root_call.should == @call
290
+
291
+ # Press some digits.
292
+ gather.press "98765"
293
+ end
294
+
295
+ # This should update the path
296
+ @call.current_path.should == test_action_twilio_index_path
297
+
298
+ # This view says the digits we pressed - make sure
299
+ @call.should have_say "You entered 98765."
300
+ end
301
+
302
+ it "should gather without a press" do
303
+ @call.within_gather do |gather|
304
+ # Do nothing
305
+ end
306
+
307
+ # We should still be on the same page
308
+ @call.current_path.should == test_start_twilio_index_path
309
+ end
310
+
311
+ it "should respond to the default finish key of hash" do
312
+ @call.within_gather do |gather|
313
+ gather.press "98765#"
314
+ end
315
+ @call.should have_say "You entered 98765."
316
+ end
317
+ end
318
+
319
+ describe "with finishOnKey specified" do
320
+ before(:each) do
321
+ @call = ttt_call(test_gather_finish_on_asterisk_twilio_index_path, @our_number, @their_number)
322
+ end
323
+
324
+ it "should strip the finish key from the digits" do
325
+ @call.within_gather do |gather|
326
+ gather.press "98765*"
327
+ end
328
+
329
+ @call.should have_say "You entered 98765."
330
+ end
331
+
332
+ it "should still accept the digits without a finish key (due to timeout)" do
333
+ @call.within_gather do |gather|
334
+ gather.press "98765"
335
+ end
336
+
337
+ @call.should have_say "You entered 98765."
338
+ end
339
+
340
+ end
341
+
342
+ describe "failure" do
343
+ before(:each) do
344
+ @call = ttt_call(test_say_twilio_index_path, @our_number, @their_number)
345
+ end
346
+
347
+ it "should have the right value for has_gather?" do
348
+ @call.has_gather?.should be_false
349
+ end
350
+
351
+ it "should have the right value for gather?" do
352
+ @call.gather?.should be_false
353
+ end
354
+
355
+ it "should fail on within_gather if there is no gather" do
356
+ lambda {@call.within_gather do |gather|; end}.should raise_error
357
+ end
358
+
359
+ it "should fail on gather-scoped methods outside of a gather scope" do
360
+ lambda {@call.gather_action}.should raise_error
361
+ lambda {@call.press "1234"}.should raise_error
362
+ end
363
+ end
364
+ end
365
+
366
+ describe "record" do
367
+ before(:each) do
368
+ @call = ttt_call(test_record_twilio_index_path, @our_number, @their_number)
369
+ end
370
+
371
+ it "should have the expected say record methods" do
372
+ @call.should respond_to(:has_record?)
373
+ end
374
+
375
+ it "should have the right action for record" do
376
+ @call.has_action_on_record?("http://example.org:3000/record_this_call").should be_true
377
+ end
378
+
379
+ it "should have the right maxLength for record" do
380
+ @call.has_max_length_on_record?("20").should be_true
381
+ end
382
+
383
+ it "should have the right finishOnKey for record" do
384
+ @call.has_finish_on_key_on_record?("*").should be_true
385
+ end
386
+ end
387
+ end
388
+
@@ -0,0 +1,54 @@
1
+ require 'spec_helper'
2
+
3
+ describe TwilioTestToolkit::DSL do
4
+ before(:each) do
5
+ @our_number = "2065551212"
6
+ @their_number = "2065553434"
7
+ end
8
+
9
+ describe "ttt_call" do
10
+ describe "basics" do
11
+ before(:each) do
12
+ @call = ttt_call(test_start_twilio_index_path, @our_number, @their_number)
13
+ end
14
+
15
+ it "should assign the call" do
16
+ @call.should_not be_nil
17
+ end
18
+
19
+ it "should have a sid" do
20
+ @call.sid.should_not be_blank
21
+ end
22
+
23
+ it "should default the method to post" do
24
+ @call.http_method.should == :post
25
+ end
26
+
27
+ it "should have the right properties" do
28
+ @call.initial_path.should == test_start_twilio_index_path
29
+ @call.from_number.should == @our_number
30
+ @call.to_number.should == @their_number
31
+ @call.is_machine.should be_false
32
+ end
33
+ end
34
+
35
+ describe "with a sid, method and machine override" do
36
+ before(:each) do
37
+ @mysid = "1234567"
38
+ @call = ttt_call(test_start_twilio_index_path, @our_number, @their_number, :call_sid => @mysid, :is_machine => true, :method => :get)
39
+ end
40
+
41
+ it "should have the right sid" do
42
+ @call.sid.should == @mysid
43
+ end
44
+
45
+ it "should be a machine call" do
46
+ @call.is_machine.should be_true
47
+ end
48
+
49
+ it "should be a get call" do
50
+ @call.http_method.should == :get
51
+ end
52
+ end
53
+ end
54
+ end
@@ -0,0 +1,20 @@
1
+ # Configure Rails Environment
2
+ ENV["RAILS_ENV"] = "test"
3
+
4
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
5
+ require "rails/test_help"
6
+
7
+ Rails.backtrace_cleaner.remove_silencers!
8
+
9
+ require 'rspec/rails'
10
+
11
+ # Set up capybara integration
12
+ require 'capybara/rspec'
13
+ require 'capybara/rails'
14
+
15
+ # Our gem
16
+ require 'twilio-test-toolkit'
17
+
18
+ RSpec.configure do |config|
19
+ config.include TwilioTestToolkit::DSL, :type => :request
20
+ end