rspec-rayo 0.1.14
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/.document +5 -0
 - data/.gitignore +17 -0
 - data/.rspec +3 -0
 - data/Gemfile +3 -0
 - data/LICENSE.txt +20 -0
 - data/README.md +72 -0
 - data/Rakefile +22 -0
 - data/lib/rspec-rayo/rayo/call.rb +135 -0
 - data/lib/rspec-rayo/rayo/driver.rb +110 -0
 - data/lib/rspec-rayo/rayo/matchers/ask.rb +60 -0
 - data/lib/rspec-rayo/rayo/matchers/call_control.rb +105 -0
 - data/lib/rspec-rayo/rayo/matchers/conference.rb +73 -0
 - data/lib/rspec-rayo/rayo/matchers/dtmf.rb +21 -0
 - data/lib/rspec-rayo/rayo/matchers/input.rb +60 -0
 - data/lib/rspec-rayo/rayo/matchers/join.rb +56 -0
 - data/lib/rspec-rayo/rayo/matchers/output.rb +15 -0
 - data/lib/rspec-rayo/rayo/matchers/recording.rb +32 -0
 - data/lib/rspec-rayo/rayo/matchers/say.rb +15 -0
 - data/lib/rspec-rayo/rayo/matchers/transfer.rb +31 -0
 - data/lib/rspec-rayo/rayo/matchers.rb +138 -0
 - data/lib/rspec-rayo/tropo1/driver.rb +51 -0
 - data/lib/rspec-rayo/version.rb +3 -0
 - data/lib/rspec-rayo.rb +7 -0
 - data/rspec-rayo.gemspec +31 -0
 - data/spec/rspec-rayo/rayo/matchers/ask_spec.rb +43 -0
 - data/spec/rspec-rayo/rayo/matchers/call_control_spec.rb +83 -0
 - data/spec/rspec-rayo/rayo/matchers/conference_spec.rb +54 -0
 - data/spec/rspec-rayo/rayo/matchers/dtmf_spec.rb +16 -0
 - data/spec/rspec-rayo/rayo/matchers/input_spec.rb +43 -0
 - data/spec/rspec-rayo/rayo/matchers/join_spec.rb +33 -0
 - data/spec/rspec-rayo/rayo/matchers/output_spec.rb +23 -0
 - data/spec/rspec-rayo/rayo/matchers/say_spec.rb +23 -0
 - data/spec/rspec-rayo/rayo/matchers/transfer_spec.rb +23 -0
 - data/spec/rspec-rayo/rayo/matchers_spec.rb +30 -0
 - data/spec/spec_helper.rb +8 -0
 - metadata +193 -0
 
| 
         @@ -0,0 +1,60 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_successful_input_event do
         
     | 
| 
      
 2 
     | 
    
         
            +
              chain :with_utterance do |utterance|
         
     | 
| 
      
 3 
     | 
    
         
            +
                @utterance = utterance
         
     | 
| 
      
 4 
     | 
    
         
            +
              end
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              chain :with_interpretation do |interpretation|
         
     | 
| 
      
 7 
     | 
    
         
            +
                @interpretation = interpretation
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 11 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Component::Input::Complete::Success
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @error = "The utterance was not correct. Expected '#{@utterance}', got '#{event.reason.utterance}'" if @utterance && event.reason.utterance != @utterance
         
     | 
| 
      
 14 
     | 
    
         
            +
                  @error = "The interpretation was not correct. Expected '#{@interpretation}', got '#{event.reason.interpretation}'" if @interpretation && event.reason.interpretation != @interpretation
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
              end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 19 
     | 
    
         
            +
                "The input event was not valid: #{@error}"
         
     | 
| 
      
 20 
     | 
    
         
            +
              end
         
     | 
| 
      
 21 
     | 
    
         
            +
             
     | 
| 
      
 22 
     | 
    
         
            +
              description do
         
     | 
| 
      
 23 
     | 
    
         
            +
                "be a valid successful input event".tap do |d|
         
     | 
| 
      
 24 
     | 
    
         
            +
                  d << " with utterance '#{@utterance}'" if @utterance
         
     | 
| 
      
 25 
     | 
    
         
            +
                  d << " with interpretation '#{@interpretation}'" if @interpretation
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
            end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_input_noinput_event do
         
     | 
| 
      
 31 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 32 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 33 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Component::Input::Complete::NoInput
         
     | 
| 
      
 34 
     | 
    
         
            +
                end
         
     | 
| 
      
 35 
     | 
    
         
            +
              end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 38 
     | 
    
         
            +
                "The input event was not valid: #{@error}"
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              description do
         
     | 
| 
      
 42 
     | 
    
         
            +
                "be a valid noinput input event"
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
            end
         
     | 
| 
      
 45 
     | 
    
         
            +
             
     | 
| 
      
 46 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_input_nomatch_event do
         
     | 
| 
      
 47 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 48 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 49 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Component::Input::Complete::NoMatch
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
              end
         
     | 
| 
      
 52 
     | 
    
         
            +
             
     | 
| 
      
 53 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 54 
     | 
    
         
            +
                "The input event was not valid: #{@error}"
         
     | 
| 
      
 55 
     | 
    
         
            +
              end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
              description do
         
     | 
| 
      
 58 
     | 
    
         
            +
                "be a valid nomatch input event"
         
     | 
| 
      
 59 
     | 
    
         
            +
              end
         
     | 
| 
      
 60 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,56 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_joined_event do
         
     | 
| 
      
 2 
     | 
    
         
            +
              chain :with_other_call_id do |other_call_id|
         
     | 
| 
      
 3 
     | 
    
         
            +
                @other_call_id = other_call_id
         
     | 
| 
      
 4 
     | 
    
         
            +
              end
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
      
 6 
     | 
    
         
            +
              chain :with_mixer_id do |mixer_id|
         
     | 
| 
      
 7 
     | 
    
         
            +
                @mixer_id = mixer_id
         
     | 
| 
      
 8 
     | 
    
         
            +
              end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 11 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Joined do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @error = "The other call ID was not correct. Expected '#{@other_call_id}', got '#{event.other_call_id}'" if @other_call_id && event.other_call_id != @other_call_id
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @error = "The mixer ID was not correct. Expected '#{@mixer_id}', got '#{event.mixer_id}'" if @mixer_id && event.mixer_id != @mixer_id
         
     | 
| 
      
 14 
     | 
    
         
            +
                end
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 18 
     | 
    
         
            +
                "The joined event was not valid: #{@error}"
         
     | 
| 
      
 19 
     | 
    
         
            +
              end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              description do
         
     | 
| 
      
 22 
     | 
    
         
            +
                "be a valid joined event".tap do |d|
         
     | 
| 
      
 23 
     | 
    
         
            +
                  d << " with other call ID '#{@other_call_id}'" if @other_call_id
         
     | 
| 
      
 24 
     | 
    
         
            +
                  d << " with mixer ID '#{@mixer_id}'" if @mixer_id
         
     | 
| 
      
 25 
     | 
    
         
            +
                end
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
            end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_unjoined_event do
         
     | 
| 
      
 30 
     | 
    
         
            +
              chain :with_other_call_id do |other_call_id|
         
     | 
| 
      
 31 
     | 
    
         
            +
                @other_call_id = other_call_id
         
     | 
| 
      
 32 
     | 
    
         
            +
              end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              chain :with_mixer_id do |mixer_id|
         
     | 
| 
      
 35 
     | 
    
         
            +
                @mixer_id = mixer_id
         
     | 
| 
      
 36 
     | 
    
         
            +
              end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 39 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Unjoined do
         
     | 
| 
      
 40 
     | 
    
         
            +
                  @error = "The other call ID was not correct. Expected '#{@other_call_id}', got '#{event.other_call_id}'" if @other_call_id && event.other_call_id != @other_call_id
         
     | 
| 
      
 41 
     | 
    
         
            +
                  @error = "The mixer ID was not correct. Expected '#{@mixer_id}', got '#{event.mixer_id}'" if @mixer_id && event.mixer_id != @mixer_id
         
     | 
| 
      
 42 
     | 
    
         
            +
                end
         
     | 
| 
      
 43 
     | 
    
         
            +
              end
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 46 
     | 
    
         
            +
                "The unjoined event was not valid: #{@error}"
         
     | 
| 
      
 47 
     | 
    
         
            +
              end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
              description do
         
     | 
| 
      
 50 
     | 
    
         
            +
                "be a valid unjoined event".tap do |d|
         
     | 
| 
      
 51 
     | 
    
         
            +
                  d << " with other call ID '#{@other_call_id}'" if @other_call_id
         
     | 
| 
      
 52 
     | 
    
         
            +
                  d << " with mixer ID '#{@mixer_id}'" if @mixer_id
         
     | 
| 
      
 53 
     | 
    
         
            +
                end
         
     | 
| 
      
 54 
     | 
    
         
            +
              end
         
     | 
| 
      
 55 
     | 
    
         
            +
            end
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_output_event do
         
     | 
| 
      
 2 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 3 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 4 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Component::Output::Complete::Success
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 9 
     | 
    
         
            +
                "The output event was not valid: #{@error}"
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              description do
         
     | 
| 
      
 13 
     | 
    
         
            +
                "be a valid successful output event"
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,32 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_complete_recording_event do
         
     | 
| 
      
 2 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 3 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 4 
     | 
    
         
            +
                  match_type event.recording, Punchblock::Component::Record::Recording
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 9 
     | 
    
         
            +
                "The recording event was not valid: #{@error}"
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              description do
         
     | 
| 
      
 13 
     | 
    
         
            +
                "be a valid complete recording event"
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_stopped_recording_event do
         
     | 
| 
      
 18 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 19 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 20 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Event::Complete::Stop
         
     | 
| 
      
 21 
     | 
    
         
            +
                  match_type event.recording, Punchblock::Component::Record::Recording
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
              end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 26 
     | 
    
         
            +
                "The recording event was not valid: #{@error}"
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              description do
         
     | 
| 
      
 30 
     | 
    
         
            +
                "be a valid stopped recording event"
         
     | 
| 
      
 31 
     | 
    
         
            +
              end
         
     | 
| 
      
 32 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,15 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_say_event do
         
     | 
| 
      
 2 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 3 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 4 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Component::Tropo::Say::Complete::Success
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 9 
     | 
    
         
            +
                "The say event was not valid: #{@error}"
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              description do
         
     | 
| 
      
 13 
     | 
    
         
            +
                "be a valid successful say event"
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_transfer_event do
         
     | 
| 
      
 2 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 3 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 4 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Component::Tropo::Transfer::Complete::Success
         
     | 
| 
      
 5 
     | 
    
         
            +
                end
         
     | 
| 
      
 6 
     | 
    
         
            +
              end
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 9 
     | 
    
         
            +
                "The transfer event was not valid: #{@error}"
         
     | 
| 
      
 10 
     | 
    
         
            +
              end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
              description do
         
     | 
| 
      
 13 
     | 
    
         
            +
                "be a valid transfer event"
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_transfer_timeout_event do
         
     | 
| 
      
 18 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 19 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 20 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Component::Tropo::Transfer::Complete::Timeout
         
     | 
| 
      
 21 
     | 
    
         
            +
                end
         
     | 
| 
      
 22 
     | 
    
         
            +
              end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 25 
     | 
    
         
            +
                "The transfer event was not valid: #{@error}"
         
     | 
| 
      
 26 
     | 
    
         
            +
              end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
              description do
         
     | 
| 
      
 29 
     | 
    
         
            +
                "be a valid transfer timeout event"
         
     | 
| 
      
 30 
     | 
    
         
            +
              end
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,138 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'rspec/expectations'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            def execution_expired?(event)
         
     | 
| 
      
 4 
     | 
    
         
            +
              if event == "execution expired"
         
     | 
| 
      
 5 
     | 
    
         
            +
                @error = 'event was not delivered to queue before read timeout'
         
     | 
| 
      
 6 
     | 
    
         
            +
                raise RSpec::Expectations::ExpectationNotMetError
         
     | 
| 
      
 7 
     | 
    
         
            +
              end
         
     | 
| 
      
 8 
     | 
    
         
            +
            end
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
            def uuid_match?(uuid, type)
         
     | 
| 
      
 11 
     | 
    
         
            +
              if uuid.match(/\A[\w]{8}-[\w]{4}-[\w]{4}-[\w]{4}-[\w]{12}/).nil?
         
     | 
| 
      
 12 
     | 
    
         
            +
                @error = "#{type} == #{uuid} - expected a GUID"
         
     | 
| 
      
 13 
     | 
    
         
            +
                raise RSpec::Expectations::ExpectationNotMetError
         
     | 
| 
      
 14 
     | 
    
         
            +
              end
         
     | 
| 
      
 15 
     | 
    
         
            +
            end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
            def match_type(object, type)
         
     | 
| 
      
 18 
     | 
    
         
            +
              unless object.is_a?(type)
         
     | 
| 
      
 19 
     | 
    
         
            +
                @error = "expected reason to be #{type}, got #{object}"
         
     | 
| 
      
 20 
     | 
    
         
            +
                raise RSpec::Expectations::ExpectationNotMetError
         
     | 
| 
      
 21 
     | 
    
         
            +
              end
         
     | 
| 
      
 22 
     | 
    
         
            +
            end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
            def basic_validation(object, klass, validate_component_id = false)
         
     | 
| 
      
 25 
     | 
    
         
            +
              execution_expired? object
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
              match_type object, klass
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              uuid_match? object.call_id, 'call_id'
         
     | 
| 
      
 30 
     | 
    
         
            +
              uuid_match? object.component_id, 'cmd_id' if validate_component_id
         
     | 
| 
      
 31 
     | 
    
         
            +
             
     | 
| 
      
 32 
     | 
    
         
            +
              yield if block_given?
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
              object unless @error
         
     | 
| 
      
 35 
     | 
    
         
            +
            end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
            %w{
         
     | 
| 
      
 38 
     | 
    
         
            +
              ask
         
     | 
| 
      
 39 
     | 
    
         
            +
              call_control
         
     | 
| 
      
 40 
     | 
    
         
            +
              conference
         
     | 
| 
      
 41 
     | 
    
         
            +
              dtmf
         
     | 
| 
      
 42 
     | 
    
         
            +
              input
         
     | 
| 
      
 43 
     | 
    
         
            +
              join
         
     | 
| 
      
 44 
     | 
    
         
            +
              output
         
     | 
| 
      
 45 
     | 
    
         
            +
              recording
         
     | 
| 
      
 46 
     | 
    
         
            +
              say
         
     | 
| 
      
 47 
     | 
    
         
            +
              transfer
         
     | 
| 
      
 48 
     | 
    
         
            +
            }.each { |matcher| require "rspec-rayo/rayo/matchers/#{matcher}" }
         
     | 
| 
      
 49 
     | 
    
         
            +
             
     | 
| 
      
 50 
     | 
    
         
            +
            RSpec::Matchers.define :have_executed_correctly do
         
     | 
| 
      
 51 
     | 
    
         
            +
              match_for_should do |command|
         
     | 
| 
      
 52 
     | 
    
         
            +
                basic_validation command, Punchblock::CommandNode do
         
     | 
| 
      
 53 
     | 
    
         
            +
                  unless command.executing?
         
     | 
| 
      
 54 
     | 
    
         
            +
                    @error = "expected status to be #{:executing.inspect}, got #{command.state_name}"
         
     | 
| 
      
 55 
     | 
    
         
            +
                    raise RSpec::Expectations::ExpectationNotMetError
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 61 
     | 
    
         
            +
                "The command failed to execute: #{@error}"
         
     | 
| 
      
 62 
     | 
    
         
            +
              end
         
     | 
| 
      
 63 
     | 
    
         
            +
             
     | 
| 
      
 64 
     | 
    
         
            +
              description do
         
     | 
| 
      
 65 
     | 
    
         
            +
                "execute correctly"
         
     | 
| 
      
 66 
     | 
    
         
            +
              end
         
     | 
| 
      
 67 
     | 
    
         
            +
            end
         
     | 
| 
      
 68 
     | 
    
         
            +
             
     | 
| 
      
 69 
     | 
    
         
            +
            RSpec::Matchers.define :have_dialed_correctly do
         
     | 
| 
      
 70 
     | 
    
         
            +
              match_for_should do |call|
         
     | 
| 
      
 71 
     | 
    
         
            +
                basic_validation call, RSpecRayo::Call do
         
     | 
| 
      
 72 
     | 
    
         
            +
                  call.ring_event.should be_a_valid_ringing_event
         
     | 
| 
      
 73 
     | 
    
         
            +
                end
         
     | 
| 
      
 74 
     | 
    
         
            +
              end
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 77 
     | 
    
         
            +
                "The command failed to execute: #{@error}"
         
     | 
| 
      
 78 
     | 
    
         
            +
              end
         
     | 
| 
      
 79 
     | 
    
         
            +
             
     | 
| 
      
 80 
     | 
    
         
            +
              description do
         
     | 
| 
      
 81 
     | 
    
         
            +
                "execute correctly"
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
            end
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_complete_hangup_event do
         
     | 
| 
      
 86 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 87 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 88 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Event::Complete::Hangup
         
     | 
| 
      
 89 
     | 
    
         
            +
                end
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 93 
     | 
    
         
            +
                "The complete hangup event was not valid: #{@error}"
         
     | 
| 
      
 94 
     | 
    
         
            +
              end
         
     | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
              description do
         
     | 
| 
      
 97 
     | 
    
         
            +
                "be a valid complete hangup event"
         
     | 
| 
      
 98 
     | 
    
         
            +
              end
         
     | 
| 
      
 99 
     | 
    
         
            +
            end
         
     | 
| 
      
 100 
     | 
    
         
            +
             
     | 
| 
      
 101 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_complete_error_event do
         
     | 
| 
      
 102 
     | 
    
         
            +
              chain :with_message do |message|
         
     | 
| 
      
 103 
     | 
    
         
            +
                @message = message
         
     | 
| 
      
 104 
     | 
    
         
            +
              end
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 107 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 108 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Event::Complete::Error
         
     | 
| 
      
 109 
     | 
    
         
            +
                  @error = "The error message was not correct. Expected '#{@message}', got '#{event.reason.details}'" if @message && event.reason.details != @message
         
     | 
| 
      
 110 
     | 
    
         
            +
                end
         
     | 
| 
      
 111 
     | 
    
         
            +
              end
         
     | 
| 
      
 112 
     | 
    
         
            +
             
     | 
| 
      
 113 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 114 
     | 
    
         
            +
                "The complete error event was not valid: #{@error}"
         
     | 
| 
      
 115 
     | 
    
         
            +
              end
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
              description do
         
     | 
| 
      
 118 
     | 
    
         
            +
                "be a valid complete error event".tap do |d|
         
     | 
| 
      
 119 
     | 
    
         
            +
                  d << " with message '#{@message}'" if @message
         
     | 
| 
      
 120 
     | 
    
         
            +
                end
         
     | 
| 
      
 121 
     | 
    
         
            +
              end
         
     | 
| 
      
 122 
     | 
    
         
            +
            end
         
     | 
| 
      
 123 
     | 
    
         
            +
             
     | 
| 
      
 124 
     | 
    
         
            +
            RSpec::Matchers.define :be_a_valid_complete_stopped_event do
         
     | 
| 
      
 125 
     | 
    
         
            +
              match_for_should do |event|
         
     | 
| 
      
 126 
     | 
    
         
            +
                basic_validation event, Punchblock::Event::Complete, true do
         
     | 
| 
      
 127 
     | 
    
         
            +
                  match_type event.reason, Punchblock::Event::Complete::Stop
         
     | 
| 
      
 128 
     | 
    
         
            +
                end
         
     | 
| 
      
 129 
     | 
    
         
            +
              end
         
     | 
| 
      
 130 
     | 
    
         
            +
             
     | 
| 
      
 131 
     | 
    
         
            +
              failure_message_for_should do |actual|
         
     | 
| 
      
 132 
     | 
    
         
            +
                "The stopped event was not valid: #{@error}"
         
     | 
| 
      
 133 
     | 
    
         
            +
              end
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
              description do
         
     | 
| 
      
 136 
     | 
    
         
            +
                "be a valid stopped event"
         
     | 
| 
      
 137 
     | 
    
         
            +
              end
         
     | 
| 
      
 138 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,51 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            module RSpecRayo
         
     | 
| 
      
 2 
     | 
    
         
            +
              class Tropo1Driver
         
     | 
| 
      
 3 
     | 
    
         
            +
                require 'drb'
         
     | 
| 
      
 4 
     | 
    
         
            +
                require 'net/http'
         
     | 
| 
      
 5 
     | 
    
         
            +
                require 'uri'
         
     | 
| 
      
 6 
     | 
    
         
            +
                require 'countdownlatch'
         
     | 
| 
      
 7 
     | 
    
         
            +
             
     | 
| 
      
 8 
     | 
    
         
            +
                attr_accessor :script_content, :result, :drb, :config
         
     | 
| 
      
 9 
     | 
    
         
            +
             
     | 
| 
      
 10 
     | 
    
         
            +
                def initialize(uri = nil, latch_timeout = 5)
         
     | 
| 
      
 11 
     | 
    
         
            +
                  @uri            = uri || "druby://0.0.0.0:8787"
         
     | 
| 
      
 12 
     | 
    
         
            +
                  @latch_timeout  = latch_timeout
         
     | 
| 
      
 13 
     | 
    
         
            +
                  @config         = {}
         
     | 
| 
      
 14 
     | 
    
         
            +
                  reset!
         
     | 
| 
      
 15 
     | 
    
         
            +
                end
         
     | 
| 
      
 16 
     | 
    
         
            +
             
     | 
| 
      
 17 
     | 
    
         
            +
                def start_drb
         
     | 
| 
      
 18 
     | 
    
         
            +
                  @drb = DRb.start_service @uri, self
         
     | 
| 
      
 19 
     | 
    
         
            +
                end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                def stop_drb
         
     | 
| 
      
 22 
     | 
    
         
            +
                  @drb.stop_service
         
     | 
| 
      
 23 
     | 
    
         
            +
                end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                def reset!
         
     | 
| 
      
 26 
     | 
    
         
            +
                  @script_content = nil
         
     | 
| 
      
 27 
     | 
    
         
            +
                  @result = nil
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @latches = {}
         
     | 
| 
      
 29 
     | 
    
         
            +
                end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
                def trigger(latch_name)
         
     | 
| 
      
 32 
     | 
    
         
            +
                  latch = @latches[latch_name]
         
     | 
| 
      
 33 
     | 
    
         
            +
                  raise RuntimeError, "No latch by that name" unless latch
         
     | 
| 
      
 34 
     | 
    
         
            +
                  latch.countdown!
         
     | 
| 
      
 35 
     | 
    
         
            +
                end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                def add_latch(latch_name, count = 1)
         
     | 
| 
      
 38 
     | 
    
         
            +
                  @latches[latch_name] = CountDownLatch.new count
         
     | 
| 
      
 39 
     | 
    
         
            +
                end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
                def wait(latch_name)
         
     | 
| 
      
 42 
     | 
    
         
            +
                  latch = @latches[latch_name]
         
     | 
| 
      
 43 
     | 
    
         
            +
                  raise RuntimeError, "No latch by that name" unless latch
         
     | 
| 
      
 44 
     | 
    
         
            +
                  latch.wait @latch_timeout
         
     | 
| 
      
 45 
     | 
    
         
            +
                end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                def place_call(session_url)
         
     | 
| 
      
 48 
     | 
    
         
            +
                  Net::HTTP.get URI.parse(session_url)
         
     | 
| 
      
 49 
     | 
    
         
            +
                end
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
            end
         
     | 
    
        data/lib/rspec-rayo.rb
    ADDED
    
    
    
        data/rspec-rayo.gemspec
    ADDED
    
    | 
         @@ -0,0 +1,31 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # -*- encoding: utf-8 -*-
         
     | 
| 
      
 2 
     | 
    
         
            +
            $:.push File.expand_path("../lib", __FILE__)
         
     | 
| 
      
 3 
     | 
    
         
            +
            require "rspec-rayo/version"
         
     | 
| 
      
 4 
     | 
    
         
            +
             
     | 
| 
      
 5 
     | 
    
         
            +
            Gem::Specification.new do |s|
         
     | 
| 
      
 6 
     | 
    
         
            +
              s.name        = %q{rspec-rayo}
         
     | 
| 
      
 7 
     | 
    
         
            +
              s.version     = RSpecRayo::VERSION
         
     | 
| 
      
 8 
     | 
    
         
            +
              s.platform    = Gem::Platform::RUBY
         
     | 
| 
      
 9 
     | 
    
         
            +
              s.licenses    = ["MIT"]
         
     | 
| 
      
 10 
     | 
    
         
            +
              s.authors     = ["Jason Goecke", "Ben Langfeld"]
         
     | 
| 
      
 11 
     | 
    
         
            +
              s.email       = %q{jsgoecke@voxeo.com, ben@langfeld.me}
         
     | 
| 
      
 12 
     | 
    
         
            +
              s.homepage    = %q{http://github.com/tropo/rspec-rayo}
         
     | 
| 
      
 13 
     | 
    
         
            +
              s.summary     = %q{Rspec2 for Rayo}
         
     | 
| 
      
 14 
     | 
    
         
            +
              s.description = %q{Rspec2 Matchers for Rayo}
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
              s.files         = `git ls-files`.split("\n")
         
     | 
| 
      
 17 
     | 
    
         
            +
              s.test_files    = `git ls-files -- {test,spec,features}/*`.split("\n")
         
     | 
| 
      
 18 
     | 
    
         
            +
              s.executables   = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
         
     | 
| 
      
 19 
     | 
    
         
            +
              s.require_paths = ["lib"]
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              s.add_dependency %q<rspec>, [">= 2.6.0"]
         
     | 
| 
      
 22 
     | 
    
         
            +
              s.add_dependency %q<punchblock>, [">= 0.4.0"]
         
     | 
| 
      
 23 
     | 
    
         
            +
              s.add_dependency %q<countdownlatch>, [">= 1.0.0"]
         
     | 
| 
      
 24 
     | 
    
         
            +
              s.add_dependency %q<future-resource>, [">= 0.0.2"]
         
     | 
| 
      
 25 
     | 
    
         
            +
             
     | 
| 
      
 26 
     | 
    
         
            +
              s.add_development_dependency %q<yard>, ["~> 0.6.0"]
         
     | 
| 
      
 27 
     | 
    
         
            +
              s.add_development_dependency %q<bundler>, ["~> 1.0.0"]
         
     | 
| 
      
 28 
     | 
    
         
            +
              s.add_development_dependency %q<rcov>, [">= 0"]
         
     | 
| 
      
 29 
     | 
    
         
            +
              s.add_development_dependency %q<rake>, [">= 0"]
         
     | 
| 
      
 30 
     | 
    
         
            +
              s.add_development_dependency %q<ci_reporter>, [">= 1.6.3"]
         
     | 
| 
      
 31 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Rayo Ask matchers" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "an ask complete event" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  Punchblock::Event::Complete.new.tap do |event|
         
     | 
| 
      
 7 
     | 
    
         
            +
                    event.call_id = '5d6fe904-103d-4551-bd47-cf212c37b8c7'
         
     | 
| 
      
 8 
     | 
    
         
            +
                    event.component_id = '6d5bf745-8fa9-4e78-be18-6e6a48393f13'
         
     | 
| 
      
 9 
     | 
    
         
            +
                    event << reason
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                describe "that's successful" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  let :reason do
         
     | 
| 
      
 15 
     | 
    
         
            +
                    Punchblock::Component::Tropo::Ask::Complete::Success.new.tap do |success|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      success << '<utterance>blah</utterance>'
         
     | 
| 
      
 17 
     | 
    
         
            +
                      success << '<interpretation>blah</interpretation>'
         
     | 
| 
      
 18 
     | 
    
         
            +
                    end
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  it { should be_a_valid_successful_ask_event }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  it { should be_a_valid_successful_ask_event.with_utterance('blah') }
         
     | 
| 
      
 23 
     | 
    
         
            +
                  it { should_not be_a_valid_successful_ask_event.with_utterance('woo') }
         
     | 
| 
      
 24 
     | 
    
         
            +
                  it { should be_a_valid_successful_ask_event.with_interpretation('blah') }
         
     | 
| 
      
 25 
     | 
    
         
            +
                  it { should_not be_a_valid_successful_ask_event.with_interpretation('woo') }
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                describe "that stopped" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  let(:reason) { Punchblock::Event::Complete::Stop.new }
         
     | 
| 
      
 30 
     | 
    
         
            +
                  it { should be_a_valid_complete_stopped_event }
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                describe "that got no input" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  let(:reason) { Punchblock::Component::Tropo::Ask::Complete::NoInput.new }
         
     | 
| 
      
 35 
     | 
    
         
            +
                  it { should be_a_valid_ask_noinput_event }
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                describe "that got no match" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                  let(:reason) { Punchblock::Component::Tropo::Ask::Complete::NoMatch.new }
         
     | 
| 
      
 40 
     | 
    
         
            +
                  it { should be_a_valid_ask_nomatch_event }
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,83 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Rayo call control matchers" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "a call event" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                let(:headers) do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  {
         
     | 
| 
      
 7 
     | 
    
         
            +
                    :content_type   => "application/sdp",
         
     | 
| 
      
 8 
     | 
    
         
            +
                    :contact        => "<sip:10.0.1.11:5060;transport=udp>",
         
     | 
| 
      
 9 
     | 
    
         
            +
                    :cseq           => "1 INVITE",
         
     | 
| 
      
 10 
     | 
    
         
            +
                    :max_forwards   => "70",
         
     | 
| 
      
 11 
     | 
    
         
            +
                    :to             => "sip:usera@10.0.1.11",
         
     | 
| 
      
 12 
     | 
    
         
            +
                    :call_id        => "1bu9qwbcz2cum",
         
     | 
| 
      
 13 
     | 
    
         
            +
                    :content_length => "444",
         
     | 
| 
      
 14 
     | 
    
         
            +
                    :from           => "<sip:Tropo@10.6.69.201>;tag=1unfb1cousd2z",
         
     | 
| 
      
 15 
     | 
    
         
            +
                    :via            => "SIP/2.0/UDP 10.0.1.11:5060;branch=z9hG4bK10psx2ki47qe5;rport=5060",
         
     | 
| 
      
 16 
     | 
    
         
            +
                    :x_vdirect      => "true"
         
     | 
| 
      
 17 
     | 
    
         
            +
                  }
         
     | 
| 
      
 18 
     | 
    
         
            +
                end
         
     | 
| 
      
 19 
     | 
    
         
            +
             
     | 
| 
      
 20 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 21 
     | 
    
         
            +
                  Punchblock::Event::Offer.new.tap do |offer|
         
     | 
| 
      
 22 
     | 
    
         
            +
                    offer.call_id = "8df3437f-285f-406e-9ba2-9d14af1b72c4"
         
     | 
| 
      
 23 
     | 
    
         
            +
                    offer.to = "sip:usera@10.0.1.11"
         
     | 
| 
      
 24 
     | 
    
         
            +
                    offer.headers = headers
         
     | 
| 
      
 25 
     | 
    
         
            +
                  end
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                it { should be_a_valid_offer_event }
         
     | 
| 
      
 29 
     | 
    
         
            +
              end
         
     | 
| 
      
 30 
     | 
    
         
            +
             
     | 
| 
      
 31 
     | 
    
         
            +
              describe "an answered event" do
         
     | 
| 
      
 32 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 33 
     | 
    
         
            +
                  Punchblock::Event::Answered.new.tap do |event|
         
     | 
| 
      
 34 
     | 
    
         
            +
                    event.call_id = "3b7720bf-d5dc-4f4f-a837-d7338ec18b3a@10.0.1.11"
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                it { should be_a_valid_answered_event }
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              describe "a hangup event" do
         
     | 
| 
      
 42 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  Punchblock::Event::End.new.tap do |end_event|
         
     | 
| 
      
 44 
     | 
    
         
            +
                    end_event.call_id = "3b7720bf-d5dc-4f4f-a837-d7338ec18b3a@10.0.1.11"
         
     | 
| 
      
 45 
     | 
    
         
            +
                    end_event << Punchblock::RayoNode.new('hangup')
         
     | 
| 
      
 46 
     | 
    
         
            +
                  end
         
     | 
| 
      
 47 
     | 
    
         
            +
                end
         
     | 
| 
      
 48 
     | 
    
         
            +
             
     | 
| 
      
 49 
     | 
    
         
            +
                it { should be_a_valid_hangup_event }
         
     | 
| 
      
 50 
     | 
    
         
            +
              end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
              describe "a ringing event" do
         
     | 
| 
      
 53 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 54 
     | 
    
         
            +
                  Punchblock::Event::Ringing.new.tap do |event|
         
     | 
| 
      
 55 
     | 
    
         
            +
                    event.call_id = "3b7720bf-d5dc-4f4f-a837-d7338ec18b3a@10.0.1.11"
         
     | 
| 
      
 56 
     | 
    
         
            +
                  end
         
     | 
| 
      
 57 
     | 
    
         
            +
                end
         
     | 
| 
      
 58 
     | 
    
         
            +
             
     | 
| 
      
 59 
     | 
    
         
            +
                it { should be_a_valid_ringing_event }
         
     | 
| 
      
 60 
     | 
    
         
            +
              end
         
     | 
| 
      
 61 
     | 
    
         
            +
             
     | 
| 
      
 62 
     | 
    
         
            +
              describe "a redirect event" do
         
     | 
| 
      
 63 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 64 
     | 
    
         
            +
                  Punchblock::Event::End.new.tap do |end_event|
         
     | 
| 
      
 65 
     | 
    
         
            +
                    end_event.call_id = "3b7720bf-d5dc-4f4f-a837-d7338ec18b3a@10.0.1.11"
         
     | 
| 
      
 66 
     | 
    
         
            +
                    end_event << Punchblock::RayoNode.new('redirect')
         
     | 
| 
      
 67 
     | 
    
         
            +
                  end
         
     | 
| 
      
 68 
     | 
    
         
            +
                end
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                it { should be_a_valid_redirect_event }
         
     | 
| 
      
 71 
     | 
    
         
            +
              end
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
              describe "a reject event" do
         
     | 
| 
      
 74 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 75 
     | 
    
         
            +
                  Punchblock::Event::End.new.tap do |end_event|
         
     | 
| 
      
 76 
     | 
    
         
            +
                    end_event.call_id = "3b7720bf-d5dc-4f4f-a837-d7338ec18b3a@10.0.1.11"
         
     | 
| 
      
 77 
     | 
    
         
            +
                    end_event << Punchblock::RayoNode.new('reject')
         
     | 
| 
      
 78 
     | 
    
         
            +
                  end
         
     | 
| 
      
 79 
     | 
    
         
            +
                end
         
     | 
| 
      
 80 
     | 
    
         
            +
             
     | 
| 
      
 81 
     | 
    
         
            +
                it { should be_a_valid_reject_event }
         
     | 
| 
      
 82 
     | 
    
         
            +
              end
         
     | 
| 
      
 83 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,54 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Rayo Conference matchers" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "a conference event" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  Punchblock::Component::Tropo::Conference::OffHold.new.tap do |event|
         
     | 
| 
      
 7 
     | 
    
         
            +
                    event.call_id = '5d6fe904-103d-4551-bd47-cf212c37b8c7'
         
     | 
| 
      
 8 
     | 
    
         
            +
                    event.component_id = '6d5bf745-8fa9-4e78-be18-6e6a48393f13'
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                it { should be_a_valid_conference_offhold_event }
         
     | 
| 
      
 13 
     | 
    
         
            +
              end
         
     | 
| 
      
 14 
     | 
    
         
            +
             
     | 
| 
      
 15 
     | 
    
         
            +
              describe "a speaking event" do
         
     | 
| 
      
 16 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 17 
     | 
    
         
            +
                  Punchblock::Component::Tropo::Conference::Speaking.new.tap do |event|
         
     | 
| 
      
 18 
     | 
    
         
            +
                    event.call_id = '5d6fe904-103d-4551-bd47-cf212c37b8c7'
         
     | 
| 
      
 19 
     | 
    
         
            +
                    event.component_id = '6d5bf745-8fa9-4e78-be18-6e6a48393f13'
         
     | 
| 
      
 20 
     | 
    
         
            +
                    event.write_attr :'call-id', 'abc123'
         
     | 
| 
      
 21 
     | 
    
         
            +
                  end
         
     | 
| 
      
 22 
     | 
    
         
            +
                end
         
     | 
| 
      
 23 
     | 
    
         
            +
             
     | 
| 
      
 24 
     | 
    
         
            +
                it { should be_a_valid_speaking_event }
         
     | 
| 
      
 25 
     | 
    
         
            +
                it { should be_a_valid_speaking_event.for_call_id('abc123') }
         
     | 
| 
      
 26 
     | 
    
         
            +
                it { should_not be_a_valid_speaking_event.for_call_id('123abc') }
         
     | 
| 
      
 27 
     | 
    
         
            +
              end
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
              describe "a finished-speaking event" do
         
     | 
| 
      
 30 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 31 
     | 
    
         
            +
                  Punchblock::Component::Tropo::Conference::FinishedSpeaking.new.tap do |event|
         
     | 
| 
      
 32 
     | 
    
         
            +
                    event.call_id = '5d6fe904-103d-4551-bd47-cf212c37b8c7'
         
     | 
| 
      
 33 
     | 
    
         
            +
                    event.component_id = '6d5bf745-8fa9-4e78-be18-6e6a48393f13'
         
     | 
| 
      
 34 
     | 
    
         
            +
                    event.write_attr :'call-id', 'abc123'
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                it { should be_a_valid_finished_speaking_event }
         
     | 
| 
      
 39 
     | 
    
         
            +
                it { should be_a_valid_finished_speaking_event.for_call_id('abc123') }
         
     | 
| 
      
 40 
     | 
    
         
            +
                it { should_not be_a_valid_finished_speaking_event.for_call_id('123abc') }
         
     | 
| 
      
 41 
     | 
    
         
            +
              end
         
     | 
| 
      
 42 
     | 
    
         
            +
             
     | 
| 
      
 43 
     | 
    
         
            +
              describe "a conference complete terminator event" do
         
     | 
| 
      
 44 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 45 
     | 
    
         
            +
                  Punchblock::Event::Complete.new.tap do |event|
         
     | 
| 
      
 46 
     | 
    
         
            +
                    event.call_id = '5d6fe904-103d-4551-bd47-cf212c37b8c7'
         
     | 
| 
      
 47 
     | 
    
         
            +
                    event.component_id = '6d5bf745-8fa9-4e78-be18-6e6a48393f13'
         
     | 
| 
      
 48 
     | 
    
         
            +
                    event << Punchblock::Component::Tropo::Conference::Complete::Terminator.new
         
     | 
| 
      
 49 
     | 
    
         
            +
                  end
         
     | 
| 
      
 50 
     | 
    
         
            +
                end
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                it { should be_a_valid_conference_complete_terminator_event }
         
     | 
| 
      
 53 
     | 
    
         
            +
              end
         
     | 
| 
      
 54 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,16 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Rayo DTMF matchers" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "a DTMF event" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  Punchblock::Event::DTMF.new.tap do |dtmf_event|
         
     | 
| 
      
 7 
     | 
    
         
            +
                    dtmf_event.call_id = '5d6fe904-103d-4551-bd47-cf212c37b8c7'
         
     | 
| 
      
 8 
     | 
    
         
            +
                    dtmf_event.signal = 3
         
     | 
| 
      
 9 
     | 
    
         
            +
                  end
         
     | 
| 
      
 10 
     | 
    
         
            +
                end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                it { should be_a_valid_dtmf_event }
         
     | 
| 
      
 13 
     | 
    
         
            +
                it { should be_a_valid_dtmf_event.with_signal('3') }
         
     | 
| 
      
 14 
     | 
    
         
            +
                it { should_not be_a_valid_dtmf_event.with_signal('5') }
         
     | 
| 
      
 15 
     | 
    
         
            +
              end
         
     | 
| 
      
 16 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -0,0 +1,43 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            require 'spec_helper'
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            describe "Rayo Input matchers" do
         
     | 
| 
      
 4 
     | 
    
         
            +
              describe "an input complete event" do
         
     | 
| 
      
 5 
     | 
    
         
            +
                subject do
         
     | 
| 
      
 6 
     | 
    
         
            +
                  Punchblock::Event::Complete.new.tap do |event|
         
     | 
| 
      
 7 
     | 
    
         
            +
                    event.call_id = '5d6fe904-103d-4551-bd47-cf212c37b8c7'
         
     | 
| 
      
 8 
     | 
    
         
            +
                    event.component_id = '6d5bf745-8fa9-4e78-be18-6e6a48393f13'
         
     | 
| 
      
 9 
     | 
    
         
            +
                    event << reason
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
                end
         
     | 
| 
      
 12 
     | 
    
         
            +
             
     | 
| 
      
 13 
     | 
    
         
            +
                describe "that's successful" do
         
     | 
| 
      
 14 
     | 
    
         
            +
                  let :reason do
         
     | 
| 
      
 15 
     | 
    
         
            +
                    Punchblock::Component::Input::Complete::Success.new.tap do |success|
         
     | 
| 
      
 16 
     | 
    
         
            +
                      success << '<utterance>blah</utterance>'
         
     | 
| 
      
 17 
     | 
    
         
            +
                      success << '<interpretation>blah</interpretation>'
         
     | 
| 
      
 18 
     | 
    
         
            +
                    end
         
     | 
| 
      
 19 
     | 
    
         
            +
                  end
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
                  it { should be_a_valid_successful_input_event }
         
     | 
| 
      
 22 
     | 
    
         
            +
                  it { should be_a_valid_successful_input_event.with_utterance('blah') }
         
     | 
| 
      
 23 
     | 
    
         
            +
                  it { should_not be_a_valid_successful_input_event.with_utterance('woo') }
         
     | 
| 
      
 24 
     | 
    
         
            +
                  it { should be_a_valid_successful_input_event.with_interpretation('blah') }
         
     | 
| 
      
 25 
     | 
    
         
            +
                  it { should_not be_a_valid_successful_input_event.with_interpretation('woo') }
         
     | 
| 
      
 26 
     | 
    
         
            +
                end
         
     | 
| 
      
 27 
     | 
    
         
            +
             
     | 
| 
      
 28 
     | 
    
         
            +
                describe "that stopped" do
         
     | 
| 
      
 29 
     | 
    
         
            +
                  let(:reason) { Punchblock::Event::Complete::Stop.new }
         
     | 
| 
      
 30 
     | 
    
         
            +
                  it { should be_a_valid_complete_stopped_event }
         
     | 
| 
      
 31 
     | 
    
         
            +
                end
         
     | 
| 
      
 32 
     | 
    
         
            +
             
     | 
| 
      
 33 
     | 
    
         
            +
                describe "that got no input" do
         
     | 
| 
      
 34 
     | 
    
         
            +
                  let(:reason) { Punchblock::Component::Input::Complete::NoInput.new }
         
     | 
| 
      
 35 
     | 
    
         
            +
                  it { should be_a_valid_input_noinput_event }
         
     | 
| 
      
 36 
     | 
    
         
            +
                end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                describe "that got no match" do
         
     | 
| 
      
 39 
     | 
    
         
            +
                  let(:reason) { Punchblock::Component::Input::Complete::NoMatch.new }
         
     | 
| 
      
 40 
     | 
    
         
            +
                  it { should be_a_valid_input_nomatch_event }
         
     | 
| 
      
 41 
     | 
    
         
            +
                end
         
     | 
| 
      
 42 
     | 
    
         
            +
              end
         
     | 
| 
      
 43 
     | 
    
         
            +
            end
         
     |