Sha256: b1bdead5fb20d90de83e48b17251983924610d8fc0496610c106084c308ce326

Contents?: true

Size: 753 Bytes

Versions: 23

Compression:

Stored size: 753 Bytes

Contents

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

Version data entries

23 entries across 23 versions & 7 rubygems

Version Path
dchelimsky-rspec-1.1.99.13 lib/spec/matchers/has.rb
hubbub-0.0.11 lib/vendor/plugins/rspec/lib/spec/matchers/has.rb
hubbub-0.0.10 lib/vendor/plugins/rspec/lib/spec/matchers/has.rb
hubbub-0.0.9 lib/vendor/plugins/rspec/lib/spec/matchers/has.rb
hubbub-0.0.8 lib/vendor/plugins/rspec/lib/spec/matchers/has.rb
hubbub-0.0.6 lib/vendor/plugins/rspec/lib/spec/matchers/has.rb
simple-templater-0.0.1.4 gems/gems/rspec-1.2.9/lib/spec/matchers/has.rb
middleman-0.10.17 vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/has.rb
middleman-0.10.16 vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/has.rb
middleman-0.10.15 vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/has.rb
rackjour-0.1.8 vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/has.rb
middleman-0.10.14 vendor/gems/gems/rspec-1.2.9/lib/spec/matchers/has.rb
ageweke-rspec-1.2.9 lib/spec/matchers/has.rb
rspec-1.2.9 lib/spec/matchers/has.rb
rspec-1.2.7 lib/spec/matchers/has.rb
rspec-1.2.8 lib/spec/matchers/has.rb
rspec-1.2.2 lib/spec/matchers/has.rb
rspec-1.2.0 lib/spec/matchers/has.rb
rspec-1.2.1 lib/spec/matchers/has.rb
rspec-1.2.6 lib/spec/matchers/has.rb