Sha256: 6ad3c40c0e19b82d1733ac0bfa16cfe1ceed59f073ef070020b7fc4de894d964

Contents?: true

Size: 1.88 KB

Versions: 7

Compression:

Stored size: 1.88 KB

Contents

require 'spec_helper'
require 'integration/absent_field_validator/spec_helper'

describe 'DataMapper::Validations::Fixtures::Kayak' do
  before :all do
    DataMapper::Validations::Fixtures::Kayak.auto_migrate!

    @kayak = DataMapper::Validations::Fixtures::Kayak.new
    @kayak.should be_valid_for_sale
  end

  describe "with salesman being non blank" do
    before :all do
      @kayak.salesman = 'Joe'
    end

    it "is invalid" do
      @kayak.should_not be_valid_for_sale
    end

    it "has meaningful error message" do
      @kayak.errors.on(:salesman).should == [ 'Salesman must be absent' ]
    end
  end


  describe "with salesman being nil" do
    before :all do
      @kayak.salesman = nil
    end

    it "is valid" do
      @kayak.should be_valid_for_sale
    end

    it "has no error messages" do
      @kayak.errors.on(:salesman).should be_nil
    end
  end


  describe "with salesman being an empty string" do
    before :all do
      @kayak.salesman = ''
    end

    it "is valid" do
      @kayak.should be_valid_for_sale
    end

    it "has no error messages" do
      @kayak.errors.on(:salesman).should be_nil
    end
  end


  describe "with salesman being a string of white spaces" do
    before :all do
      @kayak.salesman = '    '
    end

    it "is valid" do
      @kayak.should be_valid_for_sale
    end

    it "has no error messages" do
      @kayak.errors.on(:salesman).should be_nil
    end
  end
end


describe 'DataMapper::Validations::Fixtures::Pirogue' do
  before :all do
    DataMapper::Validations::Fixtures::Pirogue.auto_migrate!

    @kayak = DataMapper::Validations::Fixtures::Pirogue.new
    @kayak.should_not be_valid_for_sale
  end

  describe "by default" do
    it "is invalid" do
      @kayak.should_not be_valid_for_sale
    end

    it "has meaningful error message" do
      @kayak.errors.on(:salesman).should == [ 'Salesman must be absent' ]
    end
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

Version Path
ardm-validations-1.2.0 spec/integration/absent_field_validator/absent_field_validator_spec.rb
aequitas-0.0.1 spec_legacy/integration/absent_field_validator/absent_field_validator_spec.rb
dm-validations-1.2.0 spec/integration/absent_field_validator/absent_field_validator_spec.rb
dm-validations-1.2.0.rc2 spec/integration/absent_field_validator/absent_field_validator_spec.rb
dm-validations-1.2.0.rc1 spec/integration/absent_field_validator/absent_field_validator_spec.rb
dm-validations-1.1.0 spec/integration/absent_field_validator/absent_field_validator_spec.rb
dm-validations-1.1.0.rc3 spec/integration/absent_field_validator/absent_field_validator_spec.rb