Sha256: afb6c60352f3d1ea124c505a0ac916359881550ffd1ff504bbd0b31d747a5e8a
Contents?: true
Size: 1.42 KB
Versions: 5
Compression:
Stored size: 1.42 KB
Contents
module ClassAction module RSpec class RespondWithMatcher def initialize(expected) @expected = expected.to_sym end def on(condition) @condition = condition self end def matches?(action) @action = action @actual = action.class._responses[@condition].try(:to_sym) @actual == @expected end def description if @condition "respond with method :#{@expected} on :#{@condition}" else "respond with method :#{@expected}" end end def failure_message_for_should suffix = if @actual ", but it responds with :#{@actual}" else ", but it has no response method" end if @condition "expected action of class #{@action.class} to respond with :#{@expected} on :#{@condition}#{suffix}" else "expected action of class #{@action.class} to respond with :#{@expected}#{suffix}" end end def failure_message_for_should_not if @condition "expected action of class #{@action.class} not to respond with :#{@expected} on :#{@condition}" else "expected action of class #{@action.class} not to respond with :#{@expected}" end end end end end RSpec::Matchers.module_eval do def respond_with(expected) ClassAction::RSpec::RespondWithMatcher.new(expected) end end
Version data entries
5 entries across 5 versions & 1 rubygems