Sha256: 657592ab7f882b430f168d23996f0a46529aed81e6d15071267a007ebc513c9c

Contents?: true

Size: 1.53 KB

Versions: 2

Compression:

Stored size: 1.53 KB

Contents

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_component_execution(component)
    subject.should_receive(:execute_component_and_await_completion).once.with(component).and_return(component)
  end

  def expect_component_execution_asynchronously(component)
    subject.should_receive(:execute_component).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

2 entries across 2 versions & 1 rubygems

Version Path
adhearsion-2.0.0.beta1 spec/support/call_controller_test_helpers.rb
adhearsion-2.0.0.alpha3 spec/support/call_controller_test_helpers.rb