Class: RTest::Expect

Inherits:
Object
  • Object
show all
Defined in:
lib/rtest/expect.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object) ⇒ Expect

Returns a new instance of Expect.



6
7
8
# File 'lib/rtest/expect.rb', line 6

def initialize(object)
  @object = object
end

Instance Attribute Details

#failure_messageObject (readonly)

Returns the value of attribute failure_message.



4
5
6
# File 'lib/rtest/expect.rb', line 4

def failure_message
  @failure_message
end

#passing_messageObject (readonly)

Returns the value of attribute passing_message.



4
5
6
# File 'lib/rtest/expect.rb', line 4

def passing_message
  @passing_message
end

Instance Method Details

#not_to(matcher) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/rtest/expect.rb', line 18

def not_to(matcher)
  if(matcher.match?(@object)) then @failure_message = matcher.failure_message_for_not_to
  else
    @passing_message = matcher.success_message_for_not_to
    @pass = true
  end
end

#pass?Boolean

Returns:

  • (Boolean)


26
27
28
# File 'lib/rtest/expect.rb', line 26

def pass?
  @pass
end

#to(matcher) ⇒ Object



10
11
12
13
14
15
16
# File 'lib/rtest/expect.rb', line 10

def to(matcher)
  if(matcher.match?(@object)) 
    @pass = true
    @passing_message = matcher.success_message_for_to
  else @failure_message = matcher.failure_message_for_to
  end
end