Sha256: 97d78e628d0a78c7569f440a4da48fdf72e5f9ebab04e33b086bf3295eee5be7

Contents?: true

Size: 1.58 KB

Versions: 4

Compression:

Stored size: 1.58 KB

Contents

# encoding: utf-8

module CallControllerTestHelpers
  include FlexMock::ArgumentTypes

  def self.included(test_case)
    test_case.let(:call_id) { new_uuid }
    test_case.let(:call)    { Adhearsion::Call.new }
    test_case.let(:block)   { nil }

    test_case.subject do
      case test_case.describes
      when Class
        test_case.describes
      when Module
        Class.new Adhearsion::CallController
      end.new call, :doo => :dah, &block
    end

    test_case.before do
      flexmock subject
      flexmock call, :write_command => true, :id => call_id
    end
  end

  def expect_message_waiting_for_response(message)
    subject.should_receive(:write_and_await_response).once.with(message).and_return message
    message.request!
  end

  def expect_message_of_type_waiting_for_response(message)
    subject.should_receive(:write_and_await_response).once.with(message.class).and_return message
    message.request!
  end

  def expect_component_execution(component)
    subject.should_receive(:execute_component_and_await_completion).once.with(component).and_return(component)
  end

  def mock_with_potential_matches(potential_matches)
    Adhearsion::Punchblock::MenuDSL::CalculatedMatch.new :potential_matches => potential_matches
  end

  def mock_with_exact_matches(exact_matches)
    Adhearsion::Punchblock::MenuDSL::CalculatedMatch.new :exact_matches => exact_matches
  end

  def mock_with_potential_and_exact_matches(potential_matches, exact_matches)
    Adhearsion::Punchblock::MenuDSL::CalculatedMatch.new :potential_matches => potential_matches, :exact_matches => exact_matches
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
adhearsion-2.0.1 spec/support/call_controller_test_helpers.rb
adhearsion-2.0.0 spec/support/call_controller_test_helpers.rb
adhearsion-2.0.0.rc5 spec/support/call_controller_test_helpers.rb
adhearsion-2.0.0.rc4 spec/support/call_controller_test_helpers.rb