Sha256: 7fabbcb34febda9628900d22e44bc791a6d30e8409c7db5db92fd455d9996f57

Contents?: true

Size: 449 Bytes

Versions: 7

Compression:

Stored size: 449 Bytes

Contents

module RiotMongoid
  class HasKeyAssertion < Riot::AssertionMacro
    register :has_key

    def evaluate(model, *key_macro_info)
      if key_macro_info.nil?
        fail("keys must be specified with this assertion macro")
      else
        valid = key_macro_info == model.primary_key
        key = key_macro_info.join('-')
        valid ? pass("#{model} has key #{key}") : fail("expected #{model} to have key #{key}")
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
riot-mongoid-2.1.0 lib/riot-mongoid/has_key.rb
riot-mongoid-2.0.0.beta.rc.7 lib/riot-mongoid/has_key.rb
riot-mongoid-2.0.0.beta.2 lib/riot-mongoid/has_key.rb
riot-mongoid-2.0.0.beta lib/riot-mongoid/has_key.rb
riot-mongoid-1.1.5 lib/riot-mongoid/has_key.rb
riot-mongoid-1.1.4 lib/riot-mongoid/has_key.rb
riot-mongoid-1.1.3 lib/riot-mongoid/has_key.rb