class ResourceKit::Testing::ActionHandlerMatchers
Constants
- ResponseStub
Attributes
action[R]
failure_message[R]
response_stub[R]
Public Class Methods
new(action)
click to toggle source
# File lib/resource_kit/testing/action_handler_matchers.rb, line 10 def initialize(action) @action = action end
Public Instance Methods
matches?(subject, &block)
click to toggle source
# File lib/resource_kit/testing/action_handler_matchers.rb, line 21 def matches?(subject, &block) @handled_block ||= block action = subject.resources.find_action(self.action) unless action @failure_message = "expected :#{self.action} to be handled by the class." return false end status_code = response_stub.status || 200 unless action.handlers[status_code] @failure_message = "expected the #{status_code} status code to be handled by the class." return false end handled_response = action.handlers[status_code].call(response_stub) @handled_block.call(handled_response) true end
with(options, &block)
click to toggle source
# File lib/resource_kit/testing/action_handler_matchers.rb, line 14 def with(options, &block) @response_stub = ResponseStub.new(options) @handled_block = block self end