Sha256: 59aacd4813da55a324036ce64312eb22660433b861248d7ee6e06eb0bf814bd2

Contents?: true

Size: 1.76 KB

Versions: 15

Compression:

Stored size: 1.76 KB

Contents

require 'spec_helper'
require 'integration/primitive_validator/spec_helper'

describe 'DataMapper::Validations::Fixtures::MemoryObject' do
  include DataMapper::Validations::Fixtures

  before :all do
    DataMapper::Validations::Fixtures::MemoryObject.auto_migrate!

    @model = DataMapper::Validations::Fixtures::MemoryObject.new
  end

  describe "with color given as a string" do
    before :all do
      @model.color = "grey"
    end

    it "is valid" do
      @model.should be_valid
    end
  end


  describe "with color given as an object" do
    before :all do
      # we have to go through the back door
      # since writer= method does typecasting
      # and Object is casted to String
      @model.instance_variable_set(:@color,  Object.new)
    end

    it "is NOT valid" do
      @model.should_not be_valid
    end
  end


  describe "with mark flag set to true" do
    before :all do
      @model.marked = true
    end

    it "is valid" do
      @model.should be_valid
    end
  end


  describe "with mark flag set to false" do
    before :all do
      @model.marked = false
    end

    it "is valid" do
      @model.should be_valid
    end
  end

  describe "with mark flag set to an object" do
    before :all do
      # go through the back door to avoid typecasting
      @model.instance_variable_set(:@marked, Object.new)
    end

    it "is NOT valid" do
      @model.should_not be_valid
    end
  end


  describe "with color set to nil" do
    before :all do
      # go through the back door to avoid typecasting
      @model.color = nil
    end

    it "is valid" do
      @model.should be_valid
    end
  end


  describe "with mark flag set to nil" do
    before :all do
      @model.marked = nil
    end

    it "is valid" do
      @model.should be_valid
    end
  end
end

Version data entries

15 entries across 15 versions & 3 rubygems

Version Path
ardm-validations-1.2.0 spec/integration/primitive_validator/primitive_validator_spec.rb
aequitas-0.0.1 spec_legacy/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.2.0 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.2.0.rc2 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.2.0.rc1 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.1.0 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.1.0.rc3 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.1.0.rc2 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.1.0.rc1 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.0.2 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.0.1 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.0.0 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.0.0.rc3 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.0.0.rc2 spec/integration/primitive_validator/primitive_validator_spec.rb
dm-validations-1.0.0.rc1 spec/integration/primitive_validator/primitive_validator_spec.rb