twilio-test-toolkit 1.0.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.
- data/MIT-LICENSE +20 -0
- data/README.md +223 -0
- data/Rakefile +38 -0
- data/lib/twilio-test-toolkit.rb +4 -0
- data/lib/twilio-test-toolkit/call_in_progress.rb +48 -0
- data/lib/twilio-test-toolkit/call_scope.rb +163 -0
- data/lib/twilio-test-toolkit/dsl.rb +12 -0
- data/lib/twilio-test-toolkit/version.rb +3 -0
- data/spec/dummy/README.rdoc +261 -0
- data/spec/dummy/Rakefile +7 -0
- data/spec/dummy/app/assets/javascripts/application.js +15 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +3 -0
- data/spec/dummy/app/controllers/twilio_controller.rb +8 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/app/views/layouts/twilio.layout.xml.erb +4 -0
- data/spec/dummy/app/views/twilio/testaction.xml.erb +2 -0
- data/spec/dummy/app/views/twilio/testdial.xml.erb +1 -0
- data/spec/dummy/app/views/twilio/testhangup.xml.erb +1 -0
- data/spec/dummy/app/views/twilio/testredirect.xml.erb +1 -0
- data/spec/dummy/app/views/twilio/testsay.xml.erb +1 -0
- data/spec/dummy/app/views/twilio/teststart.xml.erb +5 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +59 -0
- data/spec/dummy/config/boot.rb +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +67 -0
- data/spec/dummy/config/environments/test.rb +37 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/inflections.rb +15 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +7 -0
- data/spec/dummy/config/initializers/session_store.rb +8 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +5 -0
- data/spec/dummy/config/routes.rb +11 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +1475 -0
- data/spec/dummy/public/404.html +26 -0
- data/spec/dummy/public/422.html +26 -0
- data/spec/dummy/public/500.html +25 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/script/rails +6 -0
- data/spec/requests/call_scope_spec.rb +258 -0
- data/spec/requests/dsl_spec.rb +46 -0
- data/spec/spec_helper.rb +20 -0
- metadata +224 -0
| @@ -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,258 @@ | |
| 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(teststart_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 == teststart_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(testredirect_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?(teststart_twilio_index_path).should be_true
         | 
| 57 | 
            +
                    @call.has_redirect_to?(teststart_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 == teststart_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 == testredirect_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 == teststart_twilio_index_path
         | 
| 82 | 
            +
                  end
         | 
| 83 | 
            +
                end
         | 
| 84 | 
            +
                
         | 
| 85 | 
            +
                describe "failure" do
         | 
| 86 | 
            +
                  before(:each) do
         | 
| 87 | 
            +
                    # Initiate a call that's not on a redirect - various calls will fail
         | 
| 88 | 
            +
                    @call = ttt_call(testsay_twilio_index_path, @our_number, @their_number)        
         | 
| 89 | 
            +
                  end
         | 
| 90 | 
            +
                  
         | 
| 91 | 
            +
                  it "should have the right value for has_redirect?" do
         | 
| 92 | 
            +
                    @call.should_not have_redirect
         | 
| 93 | 
            +
                  end
         | 
| 94 | 
            +
                  
         | 
| 95 | 
            +
                  it "should have the right values for has_redirect_to?" do
         | 
| 96 | 
            +
                    @call.has_redirect_to?("http://foo").should be_false
         | 
| 97 | 
            +
                    @call.has_redirect_to?(teststart_twilio_index_path).should be_false
         | 
| 98 | 
            +
                    @call.has_redirect_to?(teststart_twilio_index_path + ".xml").should be_false
         | 
| 99 | 
            +
                  end
         | 
| 100 | 
            +
                  
         | 
| 101 | 
            +
                  it "should raise an error on follow_redirect" do
         | 
| 102 | 
            +
                    lambda {@call.follow_redirect}.should raise_error
         | 
| 103 | 
            +
                  end
         | 
| 104 | 
            +
                  
         | 
| 105 | 
            +
                  it "should raise an error on follow_redirect!" do
         | 
| 106 | 
            +
                    lambda {@call.follow_redirect!}.should raise_error
         | 
| 107 | 
            +
                  end
         | 
| 108 | 
            +
                end
         | 
| 109 | 
            +
              end
         | 
| 110 | 
            +
              
         | 
| 111 | 
            +
              describe "say" do
         | 
| 112 | 
            +
                before(:each) do
         | 
| 113 | 
            +
                  @call = ttt_call(testsay_twilio_index_path, @our_number, @their_number)
         | 
| 114 | 
            +
                end
         | 
| 115 | 
            +
                
         | 
| 116 | 
            +
                it "should have the expected say methods" do
         | 
| 117 | 
            +
                  @call.should respond_to(:has_say?)
         | 
| 118 | 
            +
                end
         | 
| 119 | 
            +
                
         | 
| 120 | 
            +
                it "should have the right values for has_say?" do
         | 
| 121 | 
            +
                  @call.has_say?("Blah blah").should be_false
         | 
| 122 | 
            +
                  @call.has_say?("This is a say page.").should be_true
         | 
| 123 | 
            +
                  @call.has_say?("This is").should be_true      # Partial match
         | 
| 124 | 
            +
                end
         | 
| 125 | 
            +
              end
         | 
| 126 | 
            +
              
         | 
| 127 | 
            +
              describe "dial" do
         | 
| 128 | 
            +
                before(:each) do
         | 
| 129 | 
            +
                  @call = ttt_call(testdial_twilio_index_path, @our_number, @their_number)
         | 
| 130 | 
            +
                end
         | 
| 131 | 
            +
             | 
| 132 | 
            +
                it "should have the expected dial methods" do
         | 
| 133 | 
            +
                  @call.should respond_to(:has_dial?)
         | 
| 134 | 
            +
                end
         | 
| 135 | 
            +
             | 
| 136 | 
            +
                it "should have the right values for has_dial?" do
         | 
| 137 | 
            +
                  @call.has_dial?("911").should be_false
         | 
| 138 | 
            +
                  @call.has_dial?("18001234567").should be_true
         | 
| 139 | 
            +
                  @call.has_dial?("12345").should be_true     # Partial match
         | 
| 140 | 
            +
                end
         | 
| 141 | 
            +
              end
         | 
| 142 | 
            +
              
         | 
| 143 | 
            +
              describe "hangup" do
         | 
| 144 | 
            +
                describe "success" do
         | 
| 145 | 
            +
                  before(:each) do
         | 
| 146 | 
            +
                    @call = ttt_call(testhangup_twilio_index_path, @our_number, @their_number)
         | 
| 147 | 
            +
                  end
         | 
| 148 | 
            +
             | 
| 149 | 
            +
                  it "should have the expected hangup methods" do
         | 
| 150 | 
            +
                    @call.should respond_to(:has_hangup?)
         | 
| 151 | 
            +
                  end
         | 
| 152 | 
            +
                  
         | 
| 153 | 
            +
                  it "should have the right value for has_hangup?" do
         | 
| 154 | 
            +
                    @call.should have_hangup
         | 
| 155 | 
            +
                  end
         | 
| 156 | 
            +
                end
         | 
| 157 | 
            +
                
         | 
| 158 | 
            +
                describe "failure" do
         | 
| 159 | 
            +
                  before(:each) do
         | 
| 160 | 
            +
                    @call = ttt_call(teststart_twilio_index_path, @our_number, @their_number)
         | 
| 161 | 
            +
                  end
         | 
| 162 | 
            +
             | 
| 163 | 
            +
                  it "should have the right value for has_hangup?" do
         | 
| 164 | 
            +
                    @call.should_not have_hangup
         | 
| 165 | 
            +
                  end
         | 
| 166 | 
            +
                end
         | 
| 167 | 
            +
              end
         | 
| 168 | 
            +
              
         | 
| 169 | 
            +
              describe "gather" do
         | 
| 170 | 
            +
                describe "success" do
         | 
| 171 | 
            +
                  before(:each) do
         | 
| 172 | 
            +
                    @call = ttt_call(teststart_twilio_index_path, @our_number, @their_number)
         | 
| 173 | 
            +
                  end
         | 
| 174 | 
            +
             | 
| 175 | 
            +
                  it "should have the expected gather methods" do
         | 
| 176 | 
            +
                    @call.should respond_to(:has_gather?)
         | 
| 177 | 
            +
                    @call.should respond_to(:within_gather)
         | 
| 178 | 
            +
                    @call.should respond_to(:gather?)
         | 
| 179 | 
            +
                    @call.should respond_to(:gather_action)
         | 
| 180 | 
            +
                    @call.should respond_to(:press)
         | 
| 181 | 
            +
                  end
         | 
| 182 | 
            +
                  
         | 
| 183 | 
            +
                  it "should have the right value for has_gather?" do
         | 
| 184 | 
            +
                    @call.has_gather?.should be_true
         | 
| 185 | 
            +
                  end
         | 
| 186 | 
            +
                  
         | 
| 187 | 
            +
                  it "should have the right value for gather?" do
         | 
| 188 | 
            +
                    # Although we have a gather, the current call scope is not itself a gather, so this returns false.
         | 
| 189 | 
            +
                    @call.gather?.should be_false
         | 
| 190 | 
            +
                  end
         | 
| 191 | 
            +
                  
         | 
| 192 | 
            +
                  it "should fail on gather-scoped methods outside of a gather scope" do
         | 
| 193 | 
            +
                    lambda {@call.gather_action}.should raise_error
         | 
| 194 | 
            +
                    lambda {@call.press "1234"}.should raise_error
         | 
| 195 | 
            +
                  end
         | 
| 196 | 
            +
                  
         | 
| 197 | 
            +
                  it "should gather" do
         | 
| 198 | 
            +
                    # We should not have a say that's contained within a gather.
         | 
| 199 | 
            +
                    @call.should_not have_say("Please enter some digits.")
         | 
| 200 | 
            +
                    
         | 
| 201 | 
            +
                    # Now enter the gather block.
         | 
| 202 | 
            +
                    @call.within_gather do |gather|
         | 
| 203 | 
            +
                      # We should have a say here
         | 
| 204 | 
            +
                      gather.should have_say("Please enter some digits.")
         | 
| 205 | 
            +
                      
         | 
| 206 | 
            +
                      # We should be in a gather
         | 
| 207 | 
            +
                      gather.gather?.should be_true
         | 
| 208 | 
            +
                      # And we should have an action
         | 
| 209 | 
            +
                      gather.gather_action.should == testaction_twilio_index_path
         | 
| 210 | 
            +
                      
         | 
| 211 | 
            +
                      # And we should have the right root call
         | 
| 212 | 
            +
                      gather.root_call.should == @call
         | 
| 213 | 
            +
                      
         | 
| 214 | 
            +
                      # Press some digits.
         | 
| 215 | 
            +
                      gather.press "98765"
         | 
| 216 | 
            +
                    end
         | 
| 217 | 
            +
                    
         | 
| 218 | 
            +
                    # This should update the path
         | 
| 219 | 
            +
                    @call.current_path.should == testaction_twilio_index_path
         | 
| 220 | 
            +
                    
         | 
| 221 | 
            +
                    # This view says the digits we pressed - make sure
         | 
| 222 | 
            +
                    @call.should have_say "You entered 98765"
         | 
| 223 | 
            +
                  end
         | 
| 224 | 
            +
                  
         | 
| 225 | 
            +
                  it "should gather without a press" do
         | 
| 226 | 
            +
                    @call.within_gather do |gather|
         | 
| 227 | 
            +
                      # Do nothing
         | 
| 228 | 
            +
                    end
         | 
| 229 | 
            +
                    
         | 
| 230 | 
            +
                    # We should still be on the same page
         | 
| 231 | 
            +
                    @call.current_path.should == teststart_twilio_index_path
         | 
| 232 | 
            +
                  end
         | 
| 233 | 
            +
                end
         | 
| 234 | 
            +
                
         | 
| 235 | 
            +
                describe "failure" do
         | 
| 236 | 
            +
                  before(:each) do
         | 
| 237 | 
            +
                    @call = ttt_call(testsay_twilio_index_path, @our_number, @their_number)
         | 
| 238 | 
            +
                  end
         | 
| 239 | 
            +
                  
         | 
| 240 | 
            +
                  it "should have the right value for has_gather?" do
         | 
| 241 | 
            +
                    @call.has_gather?.should be_false
         | 
| 242 | 
            +
                  end
         | 
| 243 | 
            +
                  
         | 
| 244 | 
            +
                  it "should have the right value for gather?" do
         | 
| 245 | 
            +
                    @call.gather?.should be_false
         | 
| 246 | 
            +
                  end
         | 
| 247 | 
            +
                  
         | 
| 248 | 
            +
                  it "should fail on within_gather if there is no gather" do
         | 
| 249 | 
            +
                    lambda {@call.within_gather do |gather|; end}.should raise_error
         | 
| 250 | 
            +
                  end
         | 
| 251 | 
            +
                  
         | 
| 252 | 
            +
                  it "should fail on gather-scoped methods outside of a gather scope" do
         | 
| 253 | 
            +
                    lambda {@call.gather_action}.should raise_error
         | 
| 254 | 
            +
                    lambda {@call.press "1234"}.should raise_error
         | 
| 255 | 
            +
                  end
         | 
| 256 | 
            +
                end
         | 
| 257 | 
            +
              end
         | 
| 258 | 
            +
            end
         | 
| @@ -0,0 +1,46 @@ | |
| 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(teststart_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 have the right properties" do
         | 
| 24 | 
            +
                    @call.initial_path.should == teststart_twilio_index_path
         | 
| 25 | 
            +
                    @call.from_number.should == @our_number
         | 
| 26 | 
            +
                    @call.to_number.should == @their_number
         | 
| 27 | 
            +
                    @call.is_machine.should be_false
         | 
| 28 | 
            +
                  end      
         | 
| 29 | 
            +
                end
         | 
| 30 | 
            +
                
         | 
| 31 | 
            +
                describe "with a sid and machine override" do
         | 
| 32 | 
            +
                  before(:each) do
         | 
| 33 | 
            +
                    @mysid = "1234567"
         | 
| 34 | 
            +
                    @call = ttt_call(teststart_twilio_index_path, @our_number, @their_number, @mysid, true)                
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
                  
         | 
| 37 | 
            +
                  it "should have the right sid" do
         | 
| 38 | 
            +
                    @call.sid.should == @mysid
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                  
         | 
| 41 | 
            +
                  it "should be a machine call" do        
         | 
| 42 | 
            +
                    @call.is_machine.should be_true
         | 
| 43 | 
            +
                  end
         | 
| 44 | 
            +
                end
         | 
| 45 | 
            +
              end
         | 
| 46 | 
            +
            end
         | 
    
        data/spec/spec_helper.rb
    ADDED
    
    | @@ -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
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,224 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: twilio-test-toolkit
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 1.0.0
         | 
| 5 | 
            +
              prerelease: 
         | 
| 6 | 
            +
            platform: ruby
         | 
| 7 | 
            +
            authors:
         | 
| 8 | 
            +
            - Jack Nichols
         | 
| 9 | 
            +
            autorequire: 
         | 
| 10 | 
            +
            bindir: bin
         | 
| 11 | 
            +
            cert_chain: []
         | 
| 12 | 
            +
            date: 2012-09-18 00:00:00.000000000 Z
         | 
| 13 | 
            +
            dependencies:
         | 
| 14 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 15 | 
            +
              name: capybara
         | 
| 16 | 
            +
              requirement: &70202198013720 !ruby/object:Gem::Requirement
         | 
| 17 | 
            +
                none: false
         | 
| 18 | 
            +
                requirements:
         | 
| 19 | 
            +
                - - ! '>='
         | 
| 20 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 21 | 
            +
                    version: '0'
         | 
| 22 | 
            +
              type: :runtime
         | 
| 23 | 
            +
              prerelease: false
         | 
| 24 | 
            +
              version_requirements: *70202198013720
         | 
| 25 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 26 | 
            +
              name: uuidtools
         | 
| 27 | 
            +
              requirement: &70202198012440 !ruby/object:Gem::Requirement
         | 
| 28 | 
            +
                none: false
         | 
| 29 | 
            +
                requirements:
         | 
| 30 | 
            +
                - - ! '>='
         | 
| 31 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 32 | 
            +
                    version: '0'
         | 
| 33 | 
            +
              type: :runtime
         | 
| 34 | 
            +
              prerelease: false
         | 
| 35 | 
            +
              version_requirements: *70202198012440
         | 
| 36 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 37 | 
            +
              name: rails
         | 
| 38 | 
            +
              requirement: &70202198010560 !ruby/object:Gem::Requirement
         | 
| 39 | 
            +
                none: false
         | 
| 40 | 
            +
                requirements:
         | 
| 41 | 
            +
                - - ~>
         | 
| 42 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 43 | 
            +
                    version: 3.2.8
         | 
| 44 | 
            +
              type: :development
         | 
| 45 | 
            +
              prerelease: false
         | 
| 46 | 
            +
              version_requirements: *70202198010560
         | 
| 47 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 48 | 
            +
              name: sqlite3
         | 
| 49 | 
            +
              requirement: &70202198009080 !ruby/object:Gem::Requirement
         | 
| 50 | 
            +
                none: false
         | 
| 51 | 
            +
                requirements:
         | 
| 52 | 
            +
                - - ! '>='
         | 
| 53 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 54 | 
            +
                    version: '0'
         | 
| 55 | 
            +
              type: :development
         | 
| 56 | 
            +
              prerelease: false
         | 
| 57 | 
            +
              version_requirements: *70202198009080
         | 
| 58 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 59 | 
            +
              name: sqlite3-ruby
         | 
| 60 | 
            +
              requirement: &70202198007920 !ruby/object:Gem::Requirement
         | 
| 61 | 
            +
                none: false
         | 
| 62 | 
            +
                requirements:
         | 
| 63 | 
            +
                - - ! '>='
         | 
| 64 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 65 | 
            +
                    version: '0'
         | 
| 66 | 
            +
              type: :development
         | 
| 67 | 
            +
              prerelease: false
         | 
| 68 | 
            +
              version_requirements: *70202198007920
         | 
| 69 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 70 | 
            +
              name: rspec
         | 
| 71 | 
            +
              requirement: &70202198006760 !ruby/object:Gem::Requirement
         | 
| 72 | 
            +
                none: false
         | 
| 73 | 
            +
                requirements:
         | 
| 74 | 
            +
                - - ! '>='
         | 
| 75 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 76 | 
            +
                    version: '0'
         | 
| 77 | 
            +
              type: :development
         | 
| 78 | 
            +
              prerelease: false
         | 
| 79 | 
            +
              version_requirements: *70202198006760
         | 
| 80 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 81 | 
            +
              name: rspec-rails
         | 
| 82 | 
            +
              requirement: &70202198005700 !ruby/object:Gem::Requirement
         | 
| 83 | 
            +
                none: false
         | 
| 84 | 
            +
                requirements:
         | 
| 85 | 
            +
                - - ! '>='
         | 
| 86 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 87 | 
            +
                    version: '0'
         | 
| 88 | 
            +
              type: :development
         | 
| 89 | 
            +
              prerelease: false
         | 
| 90 | 
            +
              version_requirements: *70202198005700
         | 
| 91 | 
            +
            - !ruby/object:Gem::Dependency
         | 
| 92 | 
            +
              name: jquery-rails
         | 
| 93 | 
            +
              requirement: &70202198004940 !ruby/object:Gem::Requirement
         | 
| 94 | 
            +
                none: false
         | 
| 95 | 
            +
                requirements:
         | 
| 96 | 
            +
                - - ! '>='
         | 
| 97 | 
            +
                  - !ruby/object:Gem::Version
         | 
| 98 | 
            +
                    version: '0'
         | 
| 99 | 
            +
              type: :development
         | 
| 100 | 
            +
              prerelease: false
         | 
| 101 | 
            +
              version_requirements: *70202198004940
         | 
| 102 | 
            +
            description: Better integration tests for apps that use Twilio
         | 
| 103 | 
            +
            email:
         | 
| 104 | 
            +
            - jack@jmongol.com
         | 
| 105 | 
            +
            executables: []
         | 
| 106 | 
            +
            extensions: []
         | 
| 107 | 
            +
            extra_rdoc_files: []
         | 
| 108 | 
            +
            files:
         | 
| 109 | 
            +
            - lib/twilio-test-toolkit/call_in_progress.rb
         | 
| 110 | 
            +
            - lib/twilio-test-toolkit/call_scope.rb
         | 
| 111 | 
            +
            - lib/twilio-test-toolkit/dsl.rb
         | 
| 112 | 
            +
            - lib/twilio-test-toolkit/version.rb
         | 
| 113 | 
            +
            - lib/twilio-test-toolkit.rb
         | 
| 114 | 
            +
            - MIT-LICENSE
         | 
| 115 | 
            +
            - Rakefile
         | 
| 116 | 
            +
            - README.md
         | 
| 117 | 
            +
            - spec/dummy/app/assets/javascripts/application.js
         | 
| 118 | 
            +
            - spec/dummy/app/assets/stylesheets/application.css
         | 
| 119 | 
            +
            - spec/dummy/app/controllers/application_controller.rb
         | 
| 120 | 
            +
            - spec/dummy/app/controllers/twilio_controller.rb
         | 
| 121 | 
            +
            - spec/dummy/app/helpers/application_helper.rb
         | 
| 122 | 
            +
            - spec/dummy/app/views/layouts/application.html.erb
         | 
| 123 | 
            +
            - spec/dummy/app/views/layouts/twilio.layout.xml.erb
         | 
| 124 | 
            +
            - spec/dummy/app/views/twilio/testaction.xml.erb
         | 
| 125 | 
            +
            - spec/dummy/app/views/twilio/testdial.xml.erb
         | 
| 126 | 
            +
            - spec/dummy/app/views/twilio/testhangup.xml.erb
         | 
| 127 | 
            +
            - spec/dummy/app/views/twilio/testredirect.xml.erb
         | 
| 128 | 
            +
            - spec/dummy/app/views/twilio/testsay.xml.erb
         | 
| 129 | 
            +
            - spec/dummy/app/views/twilio/teststart.xml.erb
         | 
| 130 | 
            +
            - spec/dummy/config/application.rb
         | 
| 131 | 
            +
            - spec/dummy/config/boot.rb
         | 
| 132 | 
            +
            - spec/dummy/config/database.yml
         | 
| 133 | 
            +
            - spec/dummy/config/environment.rb
         | 
| 134 | 
            +
            - spec/dummy/config/environments/development.rb
         | 
| 135 | 
            +
            - spec/dummy/config/environments/production.rb
         | 
| 136 | 
            +
            - spec/dummy/config/environments/test.rb
         | 
| 137 | 
            +
            - spec/dummy/config/initializers/backtrace_silencers.rb
         | 
| 138 | 
            +
            - spec/dummy/config/initializers/inflections.rb
         | 
| 139 | 
            +
            - spec/dummy/config/initializers/mime_types.rb
         | 
| 140 | 
            +
            - spec/dummy/config/initializers/secret_token.rb
         | 
| 141 | 
            +
            - spec/dummy/config/initializers/session_store.rb
         | 
| 142 | 
            +
            - spec/dummy/config/initializers/wrap_parameters.rb
         | 
| 143 | 
            +
            - spec/dummy/config/locales/en.yml
         | 
| 144 | 
            +
            - spec/dummy/config/routes.rb
         | 
| 145 | 
            +
            - spec/dummy/config.ru
         | 
| 146 | 
            +
            - spec/dummy/db/test.sqlite3
         | 
| 147 | 
            +
            - spec/dummy/log/test.log
         | 
| 148 | 
            +
            - spec/dummy/public/404.html
         | 
| 149 | 
            +
            - spec/dummy/public/422.html
         | 
| 150 | 
            +
            - spec/dummy/public/500.html
         | 
| 151 | 
            +
            - spec/dummy/public/favicon.ico
         | 
| 152 | 
            +
            - spec/dummy/Rakefile
         | 
| 153 | 
            +
            - spec/dummy/README.rdoc
         | 
| 154 | 
            +
            - spec/dummy/script/rails
         | 
| 155 | 
            +
            - spec/requests/call_scope_spec.rb
         | 
| 156 | 
            +
            - spec/requests/dsl_spec.rb
         | 
| 157 | 
            +
            - spec/spec_helper.rb
         | 
| 158 | 
            +
            homepage: https://github.com/jmongol/twilio-test-toolkit
         | 
| 159 | 
            +
            licenses:
         | 
| 160 | 
            +
            - MIT
         | 
| 161 | 
            +
            post_install_message: 
         | 
| 162 | 
            +
            rdoc_options: []
         | 
| 163 | 
            +
            require_paths:
         | 
| 164 | 
            +
            - lib
         | 
| 165 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 166 | 
            +
              none: false
         | 
| 167 | 
            +
              requirements:
         | 
| 168 | 
            +
              - - ! '>='
         | 
| 169 | 
            +
                - !ruby/object:Gem::Version
         | 
| 170 | 
            +
                  version: '0'
         | 
| 171 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 172 | 
            +
              none: false
         | 
| 173 | 
            +
              requirements:
         | 
| 174 | 
            +
              - - ! '>='
         | 
| 175 | 
            +
                - !ruby/object:Gem::Version
         | 
| 176 | 
            +
                  version: '0'
         | 
| 177 | 
            +
            requirements: []
         | 
| 178 | 
            +
            rubyforge_project: 
         | 
| 179 | 
            +
            rubygems_version: 1.8.15
         | 
| 180 | 
            +
            signing_key: 
         | 
| 181 | 
            +
            specification_version: 3
         | 
| 182 | 
            +
            summary: Better integration tests for apps that use Twilio
         | 
| 183 | 
            +
            test_files:
         | 
| 184 | 
            +
            - spec/dummy/app/assets/javascripts/application.js
         | 
| 185 | 
            +
            - spec/dummy/app/assets/stylesheets/application.css
         | 
| 186 | 
            +
            - spec/dummy/app/controllers/application_controller.rb
         | 
| 187 | 
            +
            - spec/dummy/app/controllers/twilio_controller.rb
         | 
| 188 | 
            +
            - spec/dummy/app/helpers/application_helper.rb
         | 
| 189 | 
            +
            - spec/dummy/app/views/layouts/application.html.erb
         | 
| 190 | 
            +
            - spec/dummy/app/views/layouts/twilio.layout.xml.erb
         | 
| 191 | 
            +
            - spec/dummy/app/views/twilio/testaction.xml.erb
         | 
| 192 | 
            +
            - spec/dummy/app/views/twilio/testdial.xml.erb
         | 
| 193 | 
            +
            - spec/dummy/app/views/twilio/testhangup.xml.erb
         | 
| 194 | 
            +
            - spec/dummy/app/views/twilio/testredirect.xml.erb
         | 
| 195 | 
            +
            - spec/dummy/app/views/twilio/testsay.xml.erb
         | 
| 196 | 
            +
            - spec/dummy/app/views/twilio/teststart.xml.erb
         | 
| 197 | 
            +
            - spec/dummy/config/application.rb
         | 
| 198 | 
            +
            - spec/dummy/config/boot.rb
         | 
| 199 | 
            +
            - spec/dummy/config/database.yml
         | 
| 200 | 
            +
            - spec/dummy/config/environment.rb
         | 
| 201 | 
            +
            - spec/dummy/config/environments/development.rb
         | 
| 202 | 
            +
            - spec/dummy/config/environments/production.rb
         | 
| 203 | 
            +
            - spec/dummy/config/environments/test.rb
         | 
| 204 | 
            +
            - spec/dummy/config/initializers/backtrace_silencers.rb
         | 
| 205 | 
            +
            - spec/dummy/config/initializers/inflections.rb
         | 
| 206 | 
            +
            - spec/dummy/config/initializers/mime_types.rb
         | 
| 207 | 
            +
            - spec/dummy/config/initializers/secret_token.rb
         | 
| 208 | 
            +
            - spec/dummy/config/initializers/session_store.rb
         | 
| 209 | 
            +
            - spec/dummy/config/initializers/wrap_parameters.rb
         | 
| 210 | 
            +
            - spec/dummy/config/locales/en.yml
         | 
| 211 | 
            +
            - spec/dummy/config/routes.rb
         | 
| 212 | 
            +
            - spec/dummy/config.ru
         | 
| 213 | 
            +
            - spec/dummy/db/test.sqlite3
         | 
| 214 | 
            +
            - spec/dummy/log/test.log
         | 
| 215 | 
            +
            - spec/dummy/public/404.html
         | 
| 216 | 
            +
            - spec/dummy/public/422.html
         | 
| 217 | 
            +
            - spec/dummy/public/500.html
         | 
| 218 | 
            +
            - spec/dummy/public/favicon.ico
         | 
| 219 | 
            +
            - spec/dummy/Rakefile
         | 
| 220 | 
            +
            - spec/dummy/README.rdoc
         | 
| 221 | 
            +
            - spec/dummy/script/rails
         | 
| 222 | 
            +
            - spec/requests/call_scope_spec.rb
         | 
| 223 | 
            +
            - spec/requests/dsl_spec.rb
         | 
| 224 | 
            +
            - spec/spec_helper.rb
         |