Sha256: 988a7bae3d127a39ed34ab38f898f36eaeb365daf368f9a282b1dfddb41fd7be

Contents?: true

Size: 1.29 KB

Versions: 9

Compression:

Stored size: 1.29 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.select { |group| group.name == "User" }.first }
  let(:role_group) { model_handler.groups.select { |group| group.name == 'Role' }.first }
  let(:translation_keys) { user_group.translations.map { |translation| translation.key }.to_a }
  let(:role_translation_keys) { role_group.translations.map { |translation| translation.key }.to_a }

  it "#groups" do
    groups.length.should eq 2
  end

  describe "#translations_for_group" do
    it "should find the right number of translations" do
      user_group.translations.to_a.length.should eq 7
    end

    it "finds the model translations" do
      translation_keys.should include "activerecord.models.user.other"
    end

    it "finds the attribute translations" do
      translation_keys.should include "activerecord.attributes.user.age"
    end

    it "finds the has_many association translations" do
      translation_keys.should include "activerecord.attributes.user.roles"
    end

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

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
awesome_translations-0.0.24 spec/handlers/model_handler_spec.rb
awesome_translations-0.0.23 spec/handlers/model_handler_spec.rb
awesome_translations-0.0.22 spec/handlers/model_handler_spec.rb
awesome_translations-0.0.21 spec/handlers/model_handler_spec.rb
awesome_translations-0.0.20 spec/handlers/model_handler_spec.rb
awesome_translations-0.0.19 spec/handlers/model_handler_spec.rb
awesome_translations-0.0.18 spec/handlers/model_handler_spec.rb
awesome_translations-0.0.17 spec/handlers/model_handler_spec.rb
awesome_translations-0.0.16 spec/handlers/model_handler_spec.rb