Class: IOCheck::Policy
- Inherits:
-
Object
- Object
- IOCheck::Policy
- Defined in:
- lib/iocheck/policy.rb
Direct Known Subclasses
Defined Under Namespace
Classes: Block, Failure, Success
Instance Attribute Summary collapse
-
#result ⇒ Object
readonly
Returns the value of attribute result.
Class Method Summary collapse
Instance Method Summary collapse
-
#evaluate(test) ⇒ Object
Expected -> Actual -> Success or Failure.
-
#initialize ⇒ Policy
constructor
A new instance of Policy.
- #run!(test) ⇒ Object
Constructor Details
#initialize ⇒ Policy
Returns a new instance of Policy.
4 5 6 |
# File 'lib/iocheck/policy.rb', line 4 def initialize @result = nil end |
Instance Attribute Details
#result ⇒ Object (readonly)
Returns the value of attribute result.
7 8 9 |
# File 'lib/iocheck/policy.rb', line 7 def result @result end |
Class Method Details
.by_bytes ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/iocheck/policy.rb', line 47 def self.by_bytes Block.new do |test| # TODO: Better to show the diff to the user. succeed_if( test.actual.bytes == test.expected.bytes, by_bytes_log( test )) end end |
.by_bytes_log(test) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/iocheck/policy.rb', line 56 def self.by_bytes_log( test ) "Bytes not exactly matched.\n" + "--------------------------\n" + "expected :\n#{test.expected.bytes}\n" + "--------------------------\n" + "actual :\n#{test.actual.bytes}" end |
Instance Method Details
#evaluate(test) ⇒ Object
Expected -> Actual -> Success or Failure
10 11 12 |
# File 'lib/iocheck/policy.rb', line 10 def evaluate( test ) raise NoMethodError, "You must override this method." end |
#run!(test) ⇒ Object
14 15 16 |
# File 'lib/iocheck/policy.rb', line 14 def run!( test ) @result = evaluate( test ) end |