Sha256: ba953251024425a6bf655b291a8be1127bb8bd7453a3b7bfaa34ec5dbbbdd739

Contents?: true

Size: 755 Bytes

Versions: 3

Compression:

Stored size: 755 Bytes

Contents

# encoding: utf-8
require 'spec_helper'


class TestItem
  include ActiveAttr::Model
  attribute :validity
  validates_inclusion_of :validity, :in => [true]
end

class TestModel
  include ActiveAttr::Model
  attribute :item
  validates :item, :validity => true
end

describe "validity validator" do

  it "Item is valid" do
    model = TestModel.new(item: TestItem.new(validity: true))
    model.valid?.should == true
    model.errors.count.should == 0
  end

  it "Item is invalid" do
    model = TestModel.new(item: TestItem.new(validity: false))
    model.valid?.should == false
    model.errors.count.should == 2
    model.errors.messages.should == {:item => ['must be valid', 'validity attribute is invalid: is not included in the list']}
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
osm-1.2.18.dev.2 spec/validity_validator_spec.rb
osm-1.2.18.dev.1 spec/validity_validator_spec.rb
osm-1.2.18.dev spec/validity_validator_spec.rb