Sha256: 07d20693ad8e67f807f5d0cc837ec3c02f5c5d56e6ee5248bd21efe9dda1502d

Contents?: true

Size: 698 Bytes

Versions: 6

Compression:

Stored size: 698 Bytes

Contents

module Spec
  module Matchers
    
    class Has #:nodoc:
      def initialize(sym, *args)
        @sym = sym
        @args = args
      end
      
      def matches?(target)
        target.__send__(predicate, *@args)
      end
      
      def failure_message
        "expected ##{predicate}(#{@args[0].inspect}) to return true, got false"
      end
      
      def negative_failure_message
        "expected ##{predicate}(#{@args[0].inspect}) to return false, got true"
      end
      
      def description
        "have key #{@args[0].inspect}"
      end
      
      private
        def predicate
          "#{@sym.to_s.sub("have_","has_")}?".to_sym
        end
        
    end
 
  end
end

Version data entries

6 entries across 6 versions & 3 rubygems

Version Path
jnstq-acts_as_sms-0.1.0 test/vendor/plugins/rspec/lib/spec/matchers/has.rb
jnstq-acts_as_sms-0.1.1 test/vendor/plugins/rspec/lib/spec/matchers/has.rb
jnstq-acts_as_sms-0.1.3 test/vendor/plugins/rspec/lib/spec/matchers/has.rb
jnstq-acts_as_sms-0.1.4 test/vendor/plugins/rspec/lib/spec/matchers/has.rb
pictrails-0.5.0 vendor/plugins/rspec/lib/spec/matchers/has.rb
rspec-1.1.5 lib/spec/matchers/has.rb