Sha256: a3175472b55c52bac76967e8b6c9e5a6e63fc144b31eb2c6acb1a5b0bec30379

Contents?: true

Size: 1.03 KB

Versions: 4

Compression:

Stored size: 1.03 KB

Contents

require 'rails_helper'

module CitizenBudgetModel
  RSpec.describe LocaleValidator do
    describe '#validate_each' do
      let :instance do
        Thing.new
      end

      it 'should not add an error if the name is present in one language' do
        instance.name_en_ca = 'Foo'
        expect(instance).to be_valid
        expect(instance.errors).to be_empty
      end

      it 'should not add an error if the name is present in another language' do
        instance.name_fr_ca = 'Foo'
        expect(instance).to be_valid
        expect(instance.errors).to be_empty
      end

      it 'should add an error if the name is blank' do
        expect(instance).to_not be_valid
        expect(instance.errors.full_messages).to eq(["Name can't be blank"])
      end

      it 'should add an error if the name is removed' do
        instance = Thing.create! name_en_ca: 'Foo'
        instance.name_en_ca = ''
        expect(instance).to_not be_valid
        expect(instance.errors.full_messages).to eq(["Name can't be blank"])
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
citizen_budget_model-0.0.4 spec/validators/citizen_budget_model/locale_validator_spec.rb
citizen_budget_model-0.0.3 spec/validators/citizen_budget_model/locale_validator_spec.rb
citizen_budget_model-0.0.2 spec/validators/citizen_budget_model/locale_validator_spec.rb
citizen_budget_model-0.0.1 spec/validators/citizen_budget_model/locale_validator_spec.rb