Sha256: eeebc106eccb2ca0f105879307de1ea41f637d3303e27200b4dd3177970516d6

Contents?: true

Size: 1.35 KB

Versions: 9

Compression:

Stored size: 1.35 KB

Contents

require 'spec_helper'

describe AwesomeTranslations::Translation do
  let(:day_names_monday_translation) do
    AwesomeTranslations::Translation.new(
      dir: Rails.root.join('config', 'locales', 'awesome_translations', 'date_time'),
      key: 'date.day_names[1]'
    )
  end

  let(:am_translation) do
    AwesomeTranslations::Translation.new(
      dir: Rails.root.join('config', 'locales', 'awesome_translations', 'date_time'),
      key: 'time.am'
    )
  end

  it '#array_key' do
    expect(day_names_monday_translation.array_key).to eq 'date.day_names'
  end

  it '#array_translation?' do
    expect(day_names_monday_translation.array_translation?).to eq true
  end

  it '#array_no' do
    expect(day_names_monday_translation.array_no).to eq 1
  end

  describe '#value' do
    it 'returns correct value when it is an array translation' do
      expect(day_names_monday_translation.value(locale: 'en')).to eq 'Monday'
    end

    it 'returns correct value for normal translations' do
      expect(am_translation.value(locale: 'en')).to eq 'am'
    end
  end

  describe '#value_for?' do
    it 'returns correct value when it is an array translation' do
      expect(day_names_monday_translation.value_for?('en')).to eq true
    end

    it 'returns correct value for normal translations' do
      expect(am_translation.value_for?('en')).to eq true
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
awesome_translations-0.0.25 spec/models/awesome_translations/translation_spec.rb
awesome_translations-0.0.24 spec/models/awesome_translations/translation_spec.rb
awesome_translations-0.0.23 spec/models/awesome_translations/translation_spec.rb
awesome_translations-0.0.22 spec/models/awesome_translations/translation_spec.rb
awesome_translations-0.0.21 spec/models/awesome_translations/translation_spec.rb
awesome_translations-0.0.20 spec/models/awesome_translations/translation_spec.rb
awesome_translations-0.0.19 spec/models/awesome_translations/translation_spec.rb
awesome_translations-0.0.18 spec/models/awesome_translations/translation_spec.rb
awesome_translations-0.0.17 spec/models/awesome_translations/translation_spec.rb