Sha256: 6366d434c4926fd507fd455a595178ae9c49a3a864965fcde5bc81c3f36d1a38

Contents?: true

Size: 1.28 KB

Versions: 1

Compression:

Stored size: 1.28 KB

Contents

require "spec_helper"

describe AwesomeTranslations::Handlers::ValidationsHandler do
  let(:validations_handler) { AwesomeTranslations::Handlers::ValidationsHandler.new }
  let(:user_group) { validations_handler.groups.select { |group| group.name == "User" }.first }
  let(:blank_email_translation) { user_group.translations.select { |translation| translation.key.include? "email.blank" }.first }

  it "#groups" do
    expect(validations_handler.groups.to_a.length).to eq 4
  end

  describe "#translations_for_group" do
    it "finds the right number of validation translations" do
      expect(user_group.translations.to_a.length).to eq 6
    end

    it "finds the right key" do
      expect(blank_email_translation.key).to eq "activerecord.errors.models.user.attributes.email.blank"
    end

    it "finds the right directory" do
      expect(blank_email_translation.dir).to eq "#{Rails.root}/config/locales/awesome_translations/models/user"
    end

    it 'finds confirmation translations' do
      confirmation_translation = user_group.translations.select { |translation| translation.key.include? 'email_confirmation' }.first
      expect(confirmation_translation).to_not be_blank
      expect(confirmation_translation.key).to eq 'activerecord.attributes.user.email_confirmation'
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
awesome_translations-0.0.25 spec/handlers/validations_handler_spec.rb