Sha256: d6cfa40c3808b21a1808bf2b0c744ea10aed832672467b3cf2bee6c73bedc6dc

Contents?: true

Size: 1.37 KB

Versions: 1

Compression:

Stored size: 1.37 KB

Contents

require "spec_helper"

describe AwesomeTranslations::Handlers::ModelHandler do
  let(:model_handler) { AwesomeTranslations::Handlers::ModelHandler.new }
  let(:groups) { model_handler.groups.to_a }
  let(:user_group) { model_handler.groups.detect { |group| group.name == "User" } }
  let(:role_group) { model_handler.groups.detect { |group| group.name == "Role" } }
  let(:translation_keys) { user_group.translations.map(&:key).to_a }
  let(:role_translation_keys) { role_group.translations.map(&:key).to_a }

  it "#groups" do
    expect(groups.length).to eq 5
  end

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

    it "finds the model translations" do
      expect(translation_keys).to include "activerecord.models.user.other"
    end

    it "finds the attribute translations" do
      expect(translation_keys).to include "activerecord.attributes.user.age"
    end

    it "finds the has_many association translations" do
      expect(translation_keys).to include "activerecord.attributes.user.roles"
    end

    it "finds money-rails translations" do
      expect(role_translation_keys).to include "activerecord.attributes.role.price"
    end
  end

  it "finds globalize translations" do
    expect(role_translation_keys).to include "activerecord.attributes.role.name"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
awesome_translations-0.0.59 spec/handlers/model_handler_spec.rb