Sha256: 8c49897903a7772e9df0cb652992b4a59c2601e368f8a89288eebb1a51790b26

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

require "spec_helper"

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

  it "#groups" do
    expect(validations_handler.groups.to_a.length).to eq 5
  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.join("config/locales/awesome_translations/models/user").to_s
    end

    it "finds confirmation translations" do
      confirmation_translation = user_group.translations.find { |translation| translation.key.include? "email_confirmation" }
      expect(confirmation_translation).not_to be_blank
      expect(confirmation_translation.key).to eq "activerecord.errors.models.user.attributes.email_confirmation.confirmation"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
awesome_translations-0.0.62 spec/handlers/validations_handler_spec.rb
awesome_translations-0.0.61 spec/handlers/validations_handler_spec.rb
awesome_translations-0.0.60 spec/handlers/validations_handler_spec.rb
awesome_translations-0.0.59 spec/handlers/validations_handler_spec.rb