Class: Mockr::Response

Inherits:
Object
  • Object
show all
Includes:
Test::Unit
Defined in:
lib/mockr.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initializeResponse

Returns a new instance of Response.



161
162
163
# File 'lib/mockr.rb', line 161

def initialize
  @handlers = []
end

Instance Method Details

#add_handler(handler) ⇒ Object



165
166
167
# File 'lib/mockr.rb', line 165

def add_handler(handler)
  @handlers << handler; handler
end

#call(*args, &block) ⇒ Object

Raises:

  • (AssertionFailedError)


169
170
171
172
173
174
175
# File 'lib/mockr.rb', line 169

def call(*args, &block)
  args << block if block
  @handlers.each do |handler|
    return handler.call if handler === args
  end
  raise AssertionFailedError.new("no match for arguments: #{args.inspect}")
end