X-Git-Url: https://git.openstreetmap.org/rails.git/blobdiff_plain/ddd5b4cf19a92582fd114914be5bd5a04d3522a7..3f607d565bc0e2c7b1b738301c11c16d069913d5:/vendor/gems/rspec-1.1.2/lib/spec/matchers/respond_to.rb diff --git a/vendor/gems/rspec-1.1.2/lib/spec/matchers/respond_to.rb b/vendor/gems/rspec-1.1.2/lib/spec/matchers/respond_to.rb new file mode 100644 index 000000000..3d23422aa --- /dev/null +++ b/vendor/gems/rspec-1.1.2/lib/spec/matchers/respond_to.rb @@ -0,0 +1,45 @@ +module Spec + module Matchers + + class RespondTo #:nodoc: + def initialize(*names) + @names = names + @names_not_responded_to = [] + end + + def matches?(target) + @names.each do |name| + unless target.respond_to?(name) + @names_not_responded_to << name + end + end + return @names_not_responded_to.empty? + end + + def failure_message + "expected target to respond to #{@names_not_responded_to.collect {|name| name.inspect }.join(', ')}" + end + + def negative_failure_message + "expected target not to respond to #{@names.collect {|name| name.inspect }.join(', ')}" + end + + def description + "respond to ##{@names.to_s}" + end + end + + # :call-seq: + # should respond_to(*names) + # should_not respond_to(*names) + # + # Matches if the target object responds to all of the names + # provided. Names can be Strings or Symbols. + # + # == Examples + # + def respond_to(*names) + Matchers::RespondTo.new(*names) + end + end +end