Sha256: d54b67b1f6c3429657df923979388dbd3061339deaec1a659b4e880a5ca098fa

Contents?: true

Size: 1.33 KB

Versions: 7

Compression:

Stored size: 1.33 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

  describe "persisted, with a single character owner" do
    before :all do
      @model.save
      @model.owner = 'a'
      @model.valid?
    end

    it_should_behave_like "invalid model"
  end
end

Version data entries

7 entries across 7 versions & 3 rubygems

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