Sha256: 6d1d096ecad116dfac20a37997c8142fa984a62b1886cd5e6e6fa5e33a961a03

Contents?: true

Size: 1.13 KB

Versions: 8

Compression:

Stored size: 1.13 KB

Contents

require 'spec_helper'
require 'integration/length_validator/spec_helper'

describe "entity with a name shorter than 2 characters", :shared => true do
  it "has a meaninful error message with length restrictions mentioned" do
    @model.errors.on(:name).should == [ 'Name must be at least 2 characters long' ]
  end
end

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

    @model = DataMapper::Validations::Fixtures::Mittelschnauzer.valid_instance
  end

  it_should_behave_like "valid model"

  describe "with a 13 characters long name" do
    it_should_behave_like "valid model"
  end

  describe "with a single character name" do
    before :all do
      @model.name = "R"
      @model.valid?
    end

    it_should_behave_like "invalid model"

    it_should_behave_like "entity with a name shorter than 2 characters"
  end

  describe "with blank name" do
    before :all do
      @model.name = ""
      @model.valid?
    end

    it_should_behave_like "invalid model"

    it_should_behave_like "entity with a name shorter than 2 characters"
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
dm-validations-1.1.0.rc2 spec/integration/length_validator/minimum_spec.rb
dm-validations-1.1.0.rc1 spec/integration/length_validator/minimum_spec.rb
dm-validations-1.0.2 spec/integration/length_validator/minimum_spec.rb
dm-validations-1.0.1 spec/integration/length_validator/minimum_spec.rb
dm-validations-1.0.0 spec/integration/length_validator/minimum_spec.rb
dm-validations-1.0.0.rc3 spec/integration/length_validator/minimum_spec.rb
dm-validations-1.0.0.rc2 spec/integration/length_validator/minimum_spec.rb
dm-validations-1.0.0.rc1 spec/integration/length_validator/minimum_spec.rb