Sha256: 3aa0bc95312d7299d5658674c0f645a059018c69d7817d6f8594a55f86d70e39

Contents?: true

Size: 754 Bytes

Versions: 41

Compression:

Stored size: 754 Bytes

Contents

module RSpec
  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

41 entries across 41 versions & 4 rubygems

Version Path
messagebus_ruby_api-0.4.7 spec/ruby/1.9.1/gems/rspec-expectations-2.5.0/lib/rspec/matchers/has.rb
messagebus_ruby_api-0.4.4 spec/ruby/1.9.1/gems/rspec-expectations-2.5.0/lib/rspec/matchers/has.rb
rspec-expectations-2.5.0 lib/rspec/matchers/has.rb
vim-jar-0.1.2.0001 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/lib/rspec/matchers/has.rb
rspec-expectations-2.4.0 lib/rspec/matchers/has.rb
vim-jar-0.1.2 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/lib/rspec/matchers/has.rb
vim-jar-0.1.1 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/lib/rspec/matchers/has.rb
vim-jar-0.1.0 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/lib/rspec/matchers/has.rb
rspec-expectations-2.3.0 lib/rspec/matchers/has.rb
vim-jar-0.0.3 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/lib/rspec/matchers/has.rb
vim-jar-0.0.2 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/lib/rspec/matchers/has.rb
vim-jar-0.0.1 bundler/ruby/1.8/gems/rspec-expectations-2.1.0/lib/rspec/matchers/has.rb
rspec-expectations-2.2.0 lib/rspec/matchers/has.rb
rspec-expectations-2.1.0 lib/rspec/matchers/has.rb
rspec-expectations-2.0.1 lib/rspec/matchers/has.rb
gemrage-1.0.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/lib/rspec/matchers/has.rb
gemrage-0.4.1 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/lib/rspec/matchers/has.rb
gemrage-0.4.0 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/lib/rspec/matchers/has.rb
gemrage-0.3.2 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/lib/rspec/matchers/has.rb
gemrage-0.3.1 vendor/ruby/1.8/gems/rspec-expectations-2.0.0/lib/rspec/matchers/has.rb