Class: Fix::Expectation
- Inherits:
-
Object
- Object
- Fix::Expectation
- Includes:
- Spectus::DSL
- Defined in:
- lib/fix/expectation.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#priority ⇒ Object
readonly
Returns the value of attribute priority.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #evaluate(front_object) ⇒ Object
-
#initialize(object, positive, definition, *args) ⇒ Expectation
constructor
A new instance of Expectation.
Constructor Details
#initialize(object, positive, definition, *args) ⇒ Expectation
Returns a new instance of Expectation.
12 13 14 15 16 17 18 19 20 |
# File 'lib/fix/expectation.rb', line 12 def initialize object, positive, definition, *args @positive = positive @definition = definition @args = args @priority = DB.instance.random.rand DB.instance.update(object => SortedSet[]) unless DB.instance.key? object DB.instance.fetch(object).add self end |
Instance Attribute Details
#priority ⇒ Object (readonly)
Returns the value of attribute priority.
10 11 12 |
# File 'lib/fix/expectation.rb', line 10 def priority @priority end |
Instance Method Details
#<=>(other) ⇒ Object
22 23 24 |
# File 'lib/fix/expectation.rb', line 22 def <=> other self.priority <=> other.priority end |
#evaluate(front_object) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/fix/expectation.rb', line 26 def evaluate front_object Thread.new { subject = Subject.new front_object, *@args got = nil report = begin expect { got = subject.actual }.__send__ target, @definition rescue => e e end data = presenter report, got, subject Hash[ data.to_a + (subject).to_a ].merge object: front_object }.value end |