Sha256: aae24fe0da9c2994ac8aa4ae9231edcf11624875f22405ff55050fa94e91039f

Contents?: true

Size: 721 Bytes

Versions: 8

Compression:

Stored size: 721 Bytes

Contents

module Spec
  module Matchers
    
    class RespondTo #:nodoc:
      def initialize(sym)
        @sym = sym
      end
      
      def matches?(target)
        return target.respond_to?(@sym)
      end
      
      def failure_message
        "expected target to respond to #{@sym.inspect}"
      end
      
      def negative_failure_message
        "expected target not to respond to #{@sym.inspect}"
      end
      
      def description
        "respond to ##{@sym.to_s}"
      end
    end
    
    # :call-seq:
    #   should respond_to(:sym)
    #   should_not respond_to(:sym)
    #
    # Matches if the target object responds to :sym
    def respond_to(sym)
      Matchers::RespondTo.new(sym)
    end
  end
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
puppet-0.23.0 test/lib/spec/matchers/respond_to.rb
puppet-0.22.4 test/lib/spec/matchers/respond_to.rb
puppet-0.23.1 test/lib/spec/matchers/respond_to.rb
puppet-0.23.2 test/lib/spec/matchers/respond_to.rb
riess-0.0.8 vendor/rspec-0.8.2/lib/spec/matchers/respond_to.rb
rspec-0.8.0 lib/spec/matchers/respond_to.rb
rspec-0.8.1 lib/spec/matchers/respond_to.rb
rspec-0.8.2 lib/spec/matchers/respond_to.rb