Class: Tengu::Expectation
- Inherits:
-
Object
- Object
- Tengu::Expectation
- Defined in:
- lib/tengu/expectation.rb
Instance Method Summary collapse
-
#initialize(object) ⇒ Expectation
constructor
A new instance of Expectation.
- #message ⇒ Object
- #not_to(matcher) ⇒ Object
- #success? ⇒ Boolean
- #to(matcher) ⇒ Object
Constructor Details
#initialize(object) ⇒ Expectation
Returns a new instance of Expectation.
3 4 5 6 7 8 |
# File 'lib/tengu/expectation.rb', line 3 def initialize(object) @object = object @success = false @positive = true @matcher = nil end |
Instance Method Details
#message ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/tengu/expectation.rb', line 25 def if @positive "expected #{@object.inspect} to #{@matcher.description}" else "expected #{@object.inspect} not to #{@matcher.description}" end end |
#not_to(matcher) ⇒ Object
19 20 21 22 23 |
# File 'lib/tengu/expectation.rb', line 19 def not_to(matcher) @positive = false @matcher = matcher @success = !@matcher.matches?(@object) end |
#success? ⇒ Boolean
10 11 12 |
# File 'lib/tengu/expectation.rb', line 10 def success? @success end |
#to(matcher) ⇒ Object
14 15 16 17 |
# File 'lib/tengu/expectation.rb', line 14 def to(matcher) @matcher = matcher @success = @matcher.matches?(@object) end |