Sha256: f41a199ae437b366e6cbd705c2b847cb4b7682a69a68442402f546de27e1ed88

Contents?: true

Size: 590 Bytes

Versions: 51

Compression:

Stored size: 590 Bytes

Contents

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

51 entries across 51 versions & 3 rubygems

Version Path
spicycode-micronaut-0.2.10 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.2.2 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.2.3 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.2.4 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.2.5 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.2.7 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.2.8 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.2.9 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.3.0 lib/micronaut/matchers/has.rb
micronaut-0.3.0 lib/micronaut/matchers/has.rb
micronaut-0.2.9 lib/micronaut/matchers/has.rb