Module: Switest::Assertions
- Included in:
- Scenario
- Defined in:
- lib/switest/assertions.rb
Instance Method Summary collapse
- #assert_answered(agent, timeout: 5) ⇒ Object
- #assert_call(agent, timeout: 5) ⇒ Object
- #assert_dtmf(agent, expected_dtmf, timeout: 5, after: 1, &block) ⇒ Object
- #assert_hungup(agent, timeout: 5) ⇒ Object
- #assert_no_call(agent, timeout: 2) ⇒ Object
- #assert_not_hungup(agent, timeout: 2) ⇒ Object
Instance Method Details
#assert_answered(agent, timeout: 5) ⇒ Object
15 16 17 18 19 |
# File 'lib/switest/assertions.rb', line 15 def assert_answered(agent, timeout: 5) assert agent.call?, "Agent has no call" success = agent.wait_for_answer(timeout: timeout) assert success, "Expected call to be answered within #{timeout} seconds" end |
#assert_call(agent, timeout: 5) ⇒ Object
5 6 7 8 |
# File 'lib/switest/assertions.rb', line 5 def assert_call(agent, timeout: 5) success = agent.wait_for_call(timeout: timeout) assert success, "Expected agent to receive a call within #{timeout} seconds" end |
#assert_dtmf(agent, expected_dtmf, timeout: 5, after: 1, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/switest/assertions.rb', line 33 def assert_dtmf(agent, expected_dtmf, timeout: 5, after: 1, &block) assert agent.call?, "Agent has no call" if block agent.flush_dtmf Async do sleep after block.call end received = agent.receive_dtmf(count: expected_dtmf.length, timeout: timeout + after) else received = agent.receive_dtmf(count: expected_dtmf.length, timeout: timeout) end assert_equal expected_dtmf, received, "Expected DTMF '#{expected_dtmf}' but received '#{received}'" end |
#assert_hungup(agent, timeout: 5) ⇒ Object
21 22 23 24 25 |
# File 'lib/switest/assertions.rb', line 21 def assert_hungup(agent, timeout: 5) assert agent.call?, "Agent has no call" success = agent.wait_for_end(timeout: timeout) assert success, "Expected call to be hung up within #{timeout} seconds" end |
#assert_no_call(agent, timeout: 2) ⇒ Object
10 11 12 13 |
# File 'lib/switest/assertions.rb', line 10 def assert_no_call(agent, timeout: 2) sleep timeout refute agent.call?, "Expected agent to not have received a call" end |
#assert_not_hungup(agent, timeout: 2) ⇒ Object
27 28 29 30 31 |
# File 'lib/switest/assertions.rb', line 27 def assert_not_hungup(agent, timeout: 2) assert agent.call?, "Agent has no call" sleep timeout refute agent.ended?, "Expected call to still be active" end |