Module: Lookout::Recorders::State

Defined in:
lib/lookout/recorders/state.rb

Constant Summary collapse

Error =
Class.new(StandardError)

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method, *args) ⇒ Object (private)



29
30
31
32
33
34
# File 'lib/lookout/recorders/state.rb', line 29

def method_missing(method, *args)
  description << method.to_s
  args.each{ |arg| description << arg.inspect }
  methods.record method, args
  self
end

Instance Method Details

#verifyObject



6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/lookout/recorders/state.rb', line 6

def verify
  !!methods.play_for(subject) ^ @negated or
    raise Error,
      case [@negated, @verb]
      when [true, :be]    then 'expected %p not to be %s'
      when [true, :have]  then 'expected %p not to have %s'
      when [true, nil]    then 'expected %p not to %s'
      when [false, :be]   then 'expected %p to be %s'
      when [false, :have] then 'expected %p to have %s'
      when [false, nil]   then 'expected %p to %s'
      end % [subject, description.join(' ')]
end