Sha256: 726f7f4f643895bd70bd8f841b23022e687395e581e30941a1384ff3922e85c9

Contents?: true

Size: 696 Bytes

Versions: 17

Compression:

Stored size: 696 Bytes

Contents

module Spec
  module Matchers
    
    class Has #:nodoc:
      def initialize(sym, *args)
        @sym = sym
        @args = args
      end
      
      def matches?(given)
        given.__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

17 entries across 17 versions & 5 rubygems

Version Path
dchelimsky-rspec-1.1.10 lib/spec/matchers/has.rb
dchelimsky-rspec-1.1.11 lib/spec/matchers/has.rb
merb-core-1.1.3 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/matchers/has.rb
merb-core-1.1.2 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/matchers/has.rb
merb-core-1.1.1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/matchers/has.rb
merb-core-1.1.0 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/matchers/has.rb
merb-core-1.1.0.rc1 spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/matchers/has.rb
merb-core-1.1.0.pre spec10/public/webrat/test_app/gems/gems/rspec-1.1.11/lib/spec/matchers/has.rb
mack-0.8.2 lib/gems/rspec-1.1.11/lib/spec/matchers/has.rb
rspec-1.1.10 lib/spec/matchers/has.rb
rspec-1.1.7 lib/spec/matchers/has.rb
rspec-1.1.6 lib/spec/matchers/has.rb
rspec-1.1.11 lib/spec/matchers/has.rb
rspec-1.1.8 lib/spec/matchers/has.rb
rspec-1.1.9 lib/spec/matchers/has.rb
typo-5.1.98 vendor/plugins/rspec/lib/spec/matchers/has.rb
typo-5.2 vendor/plugins/rspec/lib/spec/matchers/has.rb