Sha256: 6a72efc129f0417773a9384df09bb23c32c3fb2c0d6f16e7f7fc0dd1cd46d8ce

Contents?: true

Size: 1.1 KB

Versions: 8

Compression:

Stored size: 1.1 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe Mongoa::MongoMapper do
  describe "validates_presence_of or key required => :true" do
    describe "#validates_presence_of" do
      it "should return true if the key has a validates_presence_of validtion" do
        validation = Mongoa::MongoMapper::Matchers::ValidatePresenceOfMatcher.new(:name)
        validation.should be_matches(Post.new)
      end

      it "should return false if the key does not have a validates_presence_of validtion" do
        validation = Mongoa::MongoMapper::Matchers::ValidatePresenceOfMatcher.new(:foo)
        validation.should_not be_matches(Post.new)
      end
    end
  
    describe "required" do
      it "should work the same if the key is required rather than validates_presence_of" do
        validation = Mongoa::MongoMapper::Matchers::ValidatePresenceOfMatcher.new(:name)
        validation.should be_matches(PostRequired.new)

        validation = Mongoa::MongoMapper::Matchers::ValidatePresenceOfMatcher.new(:foo)
        validation.should_not be_matches(PostRequired.new)
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
mongoa-0.2.3 spec/validations/validate_presence_of_spec.rb
mongoa-0.2.2 spec/validations/validate_presence_of_spec.rb
mongoa-0.2.1 spec/validations/validate_presence_of_spec.rb
mongoa-0.1.17 spec/validations/validate_presence_of_spec.rb
mongoa-0.1.16 spec/validations/validate_presence_of_spec.rb
mongoa-0.1.15 spec/validations/validate_presence_of_spec.rb
mongoa-0.1.14 spec/validations/validate_presence_of_spec.rb
mongoa-0.1.13 spec/validations/validate_presence_of_spec.rb