Sha256: b5c0540c14128b969eed88049c10ad3a412c9492161edef1786a0a60c717f837
Contents?: true
Size: 941 Bytes
Versions: 2
Compression:
Stored size: 941 Bytes
Contents
module Remarkable module MongoMapper module Matchers class HaveKeyMatcher < Remarkable::MongoMapper::Base arguments :type, :collection => :attributes, :as => :attribute collection_assertions :has_key? # before_assert do # @type = @options[:type] # end protected def has_key? @subject.respond_to?(@attribute) && @subject.class.keys[@attribute] == ::MongoMapper::Plugins::Keys::Key.new(@attribute, @type) end end # Ensures that a key of the database actually exists. # # == Examples # # should_have_key :name, String # # it { should have_key(:name, String) } # it { should have_keys(:name, :phone_number, String) } # def have_key(*args, &block) HaveKeyMatcher.new(args.pop, *args, &block).spec(self) end alias :have_keys :have_key end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
remarkable_mongo-0.1.4 | lib/remarkable/mongo_mapper/matchers/have_key_matcher.rb |
remarkable_mongo-0.1.3 | lib/remarkable/mongo_mapper/matchers/have_key_matcher.rb |