Class: Tengu::Expectation

Inherits:
Object
  • Object
show all
Defined in:
lib/tengu/expectation.rb

Instance Method Summary collapse

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

#messageObject



25
26
27
28
29
30
31
# File 'lib/tengu/expectation.rb', line 25

def message
  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

Returns:

  • (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