class GhostDog::Responder::DSL
Public Class Methods
new()
click to toggle source
# File lib/ghost_dog/responder/dsl.rb, line 4 def initialize @options = { :create_method => true } end
Public Instance Methods
to_responder()
click to toggle source
# File lib/ghost_dog/responder/dsl.rb, line 8 def to_responder raise "Incomplete ghost method - must specify matcher and responding_block" unless [@matcher, @responder].all? Responder.new(@matcher, @options, @responder) end
Private Instance Methods
create_method(value)
click to toggle source
# File lib/ghost_dog/responder/dsl.rb, line 16 def create_method(value) @options[:create_method] = value end
match_with(matcher_as_arg = nil, &matcher_as_block)
click to toggle source
# File lib/ghost_dog/responder/dsl.rb, line 24 def match_with(matcher_as_arg = nil, &matcher_as_block) raise "Must specify either exactly one of a matcher instance or a matcher block" unless !!matcher_as_arg ^ block_given? matcher = matcher_as_block || matcher_as_arg @matcher = if matcher.respond_to? :matches matcher else Responder.const_get("#{matcher.class}Matcher").new(matcher) end end
respond_with(&block)
click to toggle source
# File lib/ghost_dog/responder/dsl.rb, line 20 def respond_with(&block) @responder = block end