Class: Rproof::Censor
- Inherits:
-
Object
- Object
- Rproof::Censor
- Defined in:
- lib/rproof/censor.rb
Instance Attribute Summary collapse
-
#test_result ⇒ Object
readonly
Returns the value of attribute test_result.
Instance Method Summary collapse
- #assert(statement, comment) ⇒ Object
- #assert_different(expected, obtained, comment) ⇒ Object
- #assert_equal(expected, obtained, comment) ⇒ Object
- #assert_exception(expected, comment, &block) ⇒ Object
-
#initialize(reporter, name, description) ⇒ Censor
constructor
A new instance of Censor.
- #log_exception(error) ⇒ Object
- #warning(message) ⇒ Object
Constructor Details
#initialize(reporter, name, description) ⇒ Censor
Returns a new instance of Censor.
12 13 14 15 |
# File 'lib/rproof/censor.rb', line 12 def initialize(reporter, name, description) @reporter = reporter @test_result = TestResult.new name, description end |
Instance Attribute Details
#test_result ⇒ Object (readonly)
Returns the value of attribute test_result.
16 17 18 |
# File 'lib/rproof/censor.rb', line 16 def test_result @test_result end |
Instance Method Details
#assert(statement, comment) ⇒ Object
38 39 40 |
# File 'lib/rproof/censor.rb', line 38 def assert(statement, comment) assert_equal true, statement, comment end |
#assert_different(expected, obtained, comment) ⇒ Object
18 19 20 21 |
# File 'lib/rproof/censor.rb', line 18 def assert_different(expected, obtained, comment) @test_result.add_assertion Assertion.new(expected, obtained, (obtained != expected), comment) @reporter.report_assertion @test_result.assertions.last end |
#assert_equal(expected, obtained, comment) ⇒ Object
23 24 25 26 |
# File 'lib/rproof/censor.rb', line 23 def assert_equal(expected, obtained, comment) @test_result.add_assertion Assertion.new(expected, obtained, (obtained == expected), comment) @reporter.report_assertion @test_result.assertions.last end |
#assert_exception(expected, comment, &block) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rproof/censor.rb', line 28 def assert_exception(expected, comment, &block) error = nil begin block.call rescue Exception => error ensure assert_equal(expected, error.class, comment) end end |
#log_exception(error) ⇒ Object
47 48 49 50 |
# File 'lib/rproof/censor.rb', line 47 def log_exception(error) @test_result.add_exception error @reporter.report_exception @test_result.exceptions.last end |