Module: Test::Right::Assertions
- Included in:
- Feature
- Defined in:
- lib/test/right/assertions.rb
Constant Summary collapse
- DEFAULT_ASSERTION_TIMEOUT =
seconds
15
Instance Method Summary collapse
- #assert(timeout = DEFAULT_ASSERTION_TIMEOUT) ⇒ Object
- #assert_equal(expected, actual, timeout = DEFAULT_ASSERTION_TIMEOUT) ⇒ Object
Instance Method Details
#assert(timeout = DEFAULT_ASSERTION_TIMEOUT) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/test/right/assertions.rb', line 6 def assert(timeout=DEFAULT_ASSERTION_TIMEOUT) if !block_given? raise ArgumentError, "assert requires a block" end start = Time.now while Time.now-start < timeout begin if yield return end rescue WidgetNotPresentError end sleep(0.5) end raise AssertionFailedError, "Assertion failed after #{timeout} seconds" end |
#assert_equal(expected, actual, timeout = DEFAULT_ASSERTION_TIMEOUT) ⇒ Object
25 26 27 28 29 30 31 32 33 |
# File 'lib/test/right/assertions.rb', line 25 def assert_equal(expected, actual, timeout=DEFAULT_ASSERTION_TIMEOUT) if actual.is_a? Value assert do expected == actual.value end else raise AssertionFailedError, "Expected #{expected.inspect} but got #{actual.inspect}" unless expected == actual end end |