Class: AnySpec::Assertions
- Inherits:
-
Object
- Object
- AnySpec::Assertions
- Defined in:
- lib/any-spec/assertions.rb
Instance Method Summary collapse
- #assert(expression) ⇒ Object
- #assert_block(message = "assert_block failed") ⇒ Object
- #assert_execution_failure ⇒ Object
- #assert_execution_success ⇒ Object
- #assert_output(expected, output = @test_case.test_output) ⇒ Object
- #flunk ⇒ Object
-
#initialize(test_case_instance) ⇒ Assertions
constructor
A new instance of Assertions.
Constructor Details
#initialize(test_case_instance) ⇒ Assertions
Returns a new instance of Assertions.
4 5 6 |
# File 'lib/any-spec/assertions.rb', line 4 def initialize(test_case_instance) @test_case = test_case_instance end |
Instance Method Details
#assert(expression) ⇒ Object
13 14 15 16 |
# File 'lib/any-spec/assertions.rb', line 13 def assert( expression ) = "#{expression.inspect} is not true".indent(3).red assert_block() { expression == true } end |
#assert_block(message = "assert_block failed") ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/any-spec/assertions.rb', line 35 def assert_block( = "assert_block failed") return if(@test_case.last_assertion_result == false) @test_case.assertions += 1 unless( yield ) @test_case.last_assertion_result = false @test_case. = end end |
#assert_execution_failure ⇒ Object
29 30 31 32 33 |
# File 'lib/any-spec/assertions.rb', line 29 def assert_execution_failure = " Execution of test case succeeded when it was expected to fail:\n" += @test_case.test_output.prefix_each_line_with("# ").indent(4).grey assert_block() { @test_case.exit_status != 0 } end |
#assert_execution_success ⇒ Object
23 24 25 26 27 |
# File 'lib/any-spec/assertions.rb', line 23 def assert_execution_success = "Execution of test case failed when it was expected to succeed:\n".indent(3).red += @test_case.test_output.prefix_each_line_with("# ").indent(4).grey assert_block() { @test_case.exit_status == 0 } end |
#assert_output(expected, output = @test_case.test_output) ⇒ Object
18 19 20 21 |
# File 'lib/any-spec/assertions.rb', line 18 def assert_output(expected, output = @test_case.test_output) = "Expected output to be:\n<#{expected.inspect}> but was:\n<#{output.inspect}>".indent(3).red assert_block() { output == expected } end |
#flunk ⇒ Object
8 9 10 11 |
# File 'lib/any-spec/assertions.rb', line 8 def flunk = "Flunked.".indent(3).red assert_block() { false } end |