Module: XSpec::Evaluator::Simple
- Defined in:
- lib/xspec/evaluators.rb
Overview
### Simple Assertions
This simple evaluator provides very straight-forward assertion methods.
Defined Under Namespace
Classes: AssertionFailed
Instance Method Summary collapse
- #assert(proposition, message = nil) ⇒ Object
- #assert_equal(expected, actual) ⇒ Object
- #assert_include(expected, output) ⇒ Object
- #call(unit_of_work) ⇒ Object
- #fail(message = nil) ⇒ Object
Instance Method Details
#assert(proposition, message = nil) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/xspec/evaluators.rb', line 60 def assert(proposition, =nil) unless proposition ||= 'assertion failed' _raise end end |
#assert_equal(expected, actual) ⇒ Object
68 69 70 71 72 73 74 75 76 77 |
# File 'lib/xspec/evaluators.rb', line 68 def assert_equal(expected, actual) unless expected == actual ||= "want: \#{expected.inspect}\n got: \#{actual.inspect}\n".chomp _raise end end |
#assert_include(expected, output) ⇒ Object
79 80 81 82 |
# File 'lib/xspec/evaluators.rb', line 79 def assert_include(expected, output) assert output.include?(expected), "#{expected.inspect} not present in: #{output.inspect}" end |
#call(unit_of_work) ⇒ Object
54 55 56 57 58 |
# File 'lib/xspec/evaluators.rb', line 54 def call(unit_of_work) super rescue AssertionFailed => e [Failure.new(unit_of_work, e., e.backtrace)] end |
#fail(message = nil) ⇒ Object
84 85 86 87 88 |
# File 'lib/xspec/evaluators.rb', line 84 def fail( = nil) ||= 'failed' _raise end |