Sha256: 774c471a038c1f28fecade26d1d7613b8a77dbc8cda8f84ca5efd91358b1c4de

Contents?: true

Size: 1.28 KB

Versions: 5

Compression:

Stored size: 1.28 KB

Contents

require "spec_helper"

describe AwesomeTranslations::ErbInspector::TranslationInspector do
  let(:erb_inspector) do
    AwesomeTranslations::ErbInspector.new(
      dirs: [Rails.root.to_s]
    )
  end

  let(:files) { erb_inspector.files.to_a }
  let(:file_paths) { files.map { |file| file.file_path } }
  let(:user_index_inspector) { files.select { |file_inspector| file_inspector.file_path == "app/views/users/index.html.haml" }.first }
  let(:user_index_translations) { user_index_inspector.translations.to_a }
  let(:hello_world_translation) { user_index_translations.select { |translation| translation.key == ".hello_world" }.first }
  let(:user_was_created_translation) do
    files
      .select { |file_inspector| file_inspector.file_path == "app/controllers/users_controller.rb" }
      .first
      .translations
      .select { |translation| translation.key == ".user_was_created" }
      .first
  end

  it "#full_key" do
    hello_world_translation.full_key.should eq "users.index.hello_world"
  end

  it "#full_path" do
    hello_world_translation.full_path.should eq Rails.root.join('app', 'views', 'users', 'index.html.haml').to_s
  end

  it '#dir' do
    user_was_created_translation.dir.should end_with 'spec/dummy/config/locales/awesome_translations/app/controllers/users_controller'
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
awesome_translations-0.0.24 spec/lib/erb_inspector/translation_inspector_spec.rb
awesome_translations-0.0.23 spec/lib/erb_inspector/translation_inspector_spec.rb
awesome_translations-0.0.22 spec/lib/erb_inspector/translation_inspector_spec.rb
awesome_translations-0.0.21 spec/lib/erb_inspector/translation_inspector_spec.rb
awesome_translations-0.0.20 spec/lib/erb_inspector/translation_inspector_spec.rb