Class: MotionSpec::Expectation
Instance Method Summary collapse
- #assert ⇒ Object
- #fail(matcher, negated) ⇒ Object
-
#initialize(subject, &subject_block) ⇒ Expectation
constructor
A new instance of Expectation.
- #matcher_passes(matcher) ⇒ Object
- #not_to(matcher) ⇒ Object (also: #to_not)
- #to(matcher) ⇒ Object
Constructor Details
#initialize(subject, &subject_block) ⇒ Expectation
Returns a new instance of Expectation.
4 5 6 7 |
# File 'lib/motion-spec/expectation.rb', line 4 def initialize(subject, &subject_block) @subject = subject @subject_block = subject_block end |
Instance Method Details
#assert ⇒ Object
28 29 30 |
# File 'lib/motion-spec/expectation.rb', line 28 def assert true.should == true end |
#fail(matcher, negated) ⇒ Object
24 25 26 |
# File 'lib/motion-spec/expectation.rb', line 24 def fail(matcher, negated) raise matcher.fail!(@subject, negated, &@subject_block) end |
#matcher_passes(matcher) ⇒ Object
20 21 22 |
# File 'lib/motion-spec/expectation.rb', line 20 def matcher_passes(matcher) matcher.matches?(@subject, &@subject_block) end |
#not_to(matcher) ⇒ Object Also known as: to_not
14 15 16 17 |
# File 'lib/motion-spec/expectation.rb', line 14 def not_to(matcher) fail(matcher, true) if matcher_passes(matcher) assert end |
#to(matcher) ⇒ Object
9 10 11 12 |
# File 'lib/motion-spec/expectation.rb', line 9 def to(matcher) fail(matcher, false) unless matcher_passes(matcher) assert end |