Sha256: a479da47c46180a29ebbe7f2e24f2bf4df9d0825870fab37a05c4da00b520c6d

Contents?: true

Size: 587 Bytes

Versions: 16

Compression:

Stored size: 587 Bytes

Contents

module Spec
  module Matchers
    def has(sym, *args) # :nodoc:
      simple_matcher do |actual, matcher|
        matcher.failure_message          = "expected ##{predicate(sym)}(#{args[0].inspect}) to return true, got false"
        matcher.negative_failure_message = "expected ##{predicate(sym)}(#{args[0].inspect}) to return false, got true"
        matcher.description              = "have key #{args[0].inspect}"
        actual.__send__(predicate(sym), *args)
      end
    end
    
  private
    def predicate(sym)
      "#{sym.to_s.sub("have_","has_")}?".to_sym
    end

  end
end

Version data entries

16 entries across 16 versions & 4 rubygems

Version Path
dchelimsky-rspec-1.1.11.1 lib/spec/matchers/has.rb
dchelimsky-rspec-1.1.11.2 lib/spec/matchers/has.rb
dchelimsky-rspec-1.1.11.3 lib/spec/matchers/has.rb
dchelimsky-rspec-1.1.11.4 lib/spec/matchers/has.rb
dchelimsky-rspec-1.1.11.5 lib/spec/matchers/has.rb
dchelimsky-rspec-1.1.11.6 lib/spec/matchers/has.rb
dchelimsky-rspec-1.1.11.7 lib/spec/matchers/has.rb
dchelimsky-rspec-1.1.12 lib/spec/matchers/has.rb
mack-0.8.3.1 lib/gems/rspec-1.1.12/lib/spec/matchers/has.rb
mack-0.8.3 lib/gems/rspec-1.1.12/lib/spec/matchers/has.rb
rspec-1.1.12 lib/spec/matchers/has.rb
spree-0.6.0 vendor/plugins/rspec/lib/spec/matchers/has.rb
spree-0.7.1 vendor/plugins/rspec/lib/spec/matchers/has.rb
spree-0.7.0 vendor/plugins/rspec/lib/spec/matchers/has.rb
spree-0.8.0 vendor/plugins/rspec/lib/spec/matchers/has.rb
spree-0.8.1 vendor/plugins/rspec/lib/spec/matchers/has.rb