Sha256: 6fd9e10e31cd3faaa6ea2d5e9dd36a65f726199460c06a1aa1fc529d9c314a63

Contents?: true

Size: 759 Bytes

Versions: 7

Compression:

Stored size: 759 Bytes

Contents

require File.join(File.dirname(__FILE__),'teststrap')

context "has_key macro" do
  setup do
    mock_model do
      field :name, :type => String
      field :rad,  :type => Boolean, :default => false
      field :surname, :type => String

      key :name, :rad, :surname
    end
  end

  asserts "passes when the key is specified" do
    RiotMongoid::HasKeyAssertion.new.evaluate(topic, :name, :rad, :surname).first
  end.equals(:pass)
  
  asserts "fails when the key doesn't match" do 
    RiotMongoid::HasKeyAssertion.new.evaluate(topic, :name, :surname).first
  end.equals(:fail)
  
  asserts "returns a helpful message" do 
    RiotMongoid::HasKeyAssertion.new.evaluate(topic, :name, :rad, :surname).last
  end.matches %r{has key name-rad-surname}

end

Version data entries

7 entries across 7 versions & 1 rubygems

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