Sha256: e1f2d678851b8cabe7ba025bcb7d7355033812dfc238aa529e9c64f2de7c0b67

Contents?: true

Size: 910 Bytes

Versions: 10

Compression:

Stored size: 910 Bytes

Contents

require 'spec_helper'

describe ActiveData::Model::Validations do
  let(:model) do
    stub_model(:model) do
      attribute :name, String
      validates :name, presence: true
    end
  end

  describe '#errors' do
    specify { expect(model.new.errors).to be_a ActiveModel::Errors }
    specify { expect(model.new.errors).to be_empty }
  end

  describe '#valid?' do
    specify { expect(model.new).not_to be_valid }
    specify { expect(model.new(name: 'Name')).to be_valid }
  end

  describe '#invalid?' do
    specify { expect(model.new).to be_invalid }
    specify { expect(model.new(name: 'Name')).not_to be_invalid }
  end

  describe '#validate!' do
    specify { expect { model.new.validate! }.to raise_error ActiveData::ValidationError }
    specify { expect(model.new(name: 'Name').validate!).to eq(true) }
    specify { expect { model.new(name: 'Name').validate! }.not_to raise_error }
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
active_data-1.2.0 spec/lib/active_data/model/validations_spec.rb
active_data-1.1.7 spec/lib/active_data/model/validations_spec.rb
active_data-1.1.6 spec/lib/active_data/model/validations_spec.rb
active_data-1.1.5 spec/lib/active_data/model/validations_spec.rb
active_data-1.1.4 spec/lib/active_data/model/validations_spec.rb
active_data-1.1.3 spec/lib/active_data/model/validations_spec.rb
active_data-1.1.2 spec/lib/active_data/model/validations_spec.rb
active_data-1.1.1 spec/lib/active_data/model/validations_spec.rb
active_data-1.1.0 spec/lib/active_data/model/validations_spec.rb
active_data-1.0.0 spec/lib/active_data/model/validations_spec.rb