Sha256: 81e24d330bc25c003ce030adec7c76bed973dea079bdf831868ef6eaa47097ae

Contents?: true

Size: 1.59 KB

Versions: 8

Compression:

Stored size: 1.59 KB

Contents

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

describe Mongoa::MongoMapper do
  describe "#validates_inclusion_of or key :in => []" do
    describe "validates_inclusion_of" do
      it "should return true if the key has a validate_inclusion_of with the specified within" do
        validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:state, ["new", "uploaded"])
        validation.should be_matches(Within.new)
      end
  
      it "should return false if the key has a validate_inclusion_of but the within doesn't match" do
        validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:state, ["goo", "gaa"])
        validation.should_not be_matches(Within.new)
      end

      it "should return false if the key does not have a validate_inclusion_of set" do
        validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:foo, ["new", "uploaded"])
        validation.should_not be_matches(Within.new)
      end
    end

    describe "in" do    
      it "should work the same as validates_inclusion_of" do
        validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:state, ["new", "uploaded"])
        validation.should be_matches(WithinIn.new)

        validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:state, ["goo", "gaa"])
        validation.should_not be_matches(WithinIn.new)

        validation = Mongoa::MongoMapper::Matchers::ValidateInclusionOfMatcher.new(:foo, ["new", "uploaded"])
        validation.should_not be_matches(WithinIn.new)
      end
    end            
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

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