Sha256: 74e4f16476bcd89385623b0f6ff0d7560119c911726fa5b3a994595a0b0b8887

Contents?: true

Size: 1.04 KB

Versions: 15

Compression:

Stored size: 1.04 KB

Contents

require 'spec_helper'
require 'integration/required_field_validator/spec_helper'

describe 'required_field_validator/plain_old_ruby_object_spec' do

  describe "A plain old Ruby object (not a DM resource)" do
    before do
      class PlainClass
        extend DataMapper::Validations::ClassMethods
        include DataMapper::Validations
        attr_accessor :accessor
        validates_presence_of :here, :empty, :nil, :accessor
        def here;  "here" end
        def empty; ""     end
        def nil;   nil    end
      end

      @pc = PlainClass.new
    end

    it "should fail validation with empty, nil, or blank fields" do
      @pc.should_not be_valid
      @pc.errors.on(:empty).should    == [ 'Empty must not be blank' ]
      @pc.errors.on(:nil).should      == [ 'Nil must not be blank' ]
      @pc.errors.on(:accessor).should == [ 'Accessor must not be blank' ]
    end

    it "giving accessor a value should remove validation error" do
      @pc.accessor = "full"
      @pc.valid?
      @pc.errors.on(:accessor).should be_nil
    end
  end

end

Version data entries

15 entries across 15 versions & 3 rubygems

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