class ClassAction::RSpec::RespondToFormatMatcher
Public Class Methods
new(format)
click to toggle source
# File lib/class_action/rspec/respond_to_format_matcher.rb, line 6 def initialize(format) @format = format.to_sym end
Public Instance Methods
description()
click to toggle source
# File lib/class_action/rspec/respond_to_format_matcher.rb, line 36 def description if @condition "respond to format :#{@format} on :#{@condition}" else "respond to format :#{@format}" end end
failure_message()
click to toggle source
# File lib/class_action/rspec/respond_to_format_matcher.rb, line 44 def failure_message if @condition "expected action of class #{@action.class} to respond to format :#{@format} on :#{@condition}" else "expected action of class #{@action.class} to respond to format :#{@format}" end end
failure_message_when_negated()
click to toggle source
# File lib/class_action/rspec/respond_to_format_matcher.rb, line 52 def failure_message_when_negated if @condition "expected action of class #{@action.class} not to respond to format :#{@format} on :#{@condition}" else "expected action of class #{@action.class} not to respond to format :#{@format}" end end
matches?(action, &block)
click to toggle source
# File lib/class_action/rspec/respond_to_format_matcher.rb, line 15 def matches?(action, &block) @action = action if action.class._responders.key?([@format, @condition]) if block # Response defined, we return true but we need to also execute the block, # as it might contain additional checks. First run the action's response # block, for this. respond_block = action.class._responders[ [@format, @condition] ] action.instance_exec &respond_block if respond_block action.send :copy_assigns_to_controller block.call end true else false end end
on(condition)
click to toggle source
# File lib/class_action/rspec/respond_to_format_matcher.rb, line 10 def on(condition) @condition = condition self end