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
rsanheim-micronaut-0.1.3.2 lib/micronaut/matchers/has.rb
rsanheim-micronaut-0.1.4.1 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.0.6 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.0.7 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.0.9 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.0 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.1 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.2 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.3 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.4.1 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.4.2 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.4.3 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.4.4 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.4 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.5.2 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.5 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.6.1 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.6.8 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.6.9.1 lib/micronaut/matchers/has.rb
spicycode-micronaut-0.1.6.9 lib/micronaut/matchers/has.rb