Sha256: 16b682f3b17f4bbc3710a30f58a35749ca70c39ea5c5834429e064eaf5ef15e9

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

require "i18n"
require "json"

require "i18n/js"

module Helpers
  # Set the configuration as the current one
  def set_config(path)
    config_file_path = File.dirname(__FILE__) + "/fixtures/#{path}"
    allow(I18n::JS).to receive_messages(
      :config_file_exists? => true,
      :config_file_path => config_file_path,
    )
  end

  # Shortcut to I18n::JS.translations
  def translations
    I18n::JS.translations
  end

  def file_should_exist(name)
    file_path = File.join(temp_path, name)
    expect(File.file?(file_path)).to eq(true)
  end

  def temp_path(file_name = "")
    File.expand_path("../../tmp/i18n-js/#{file_name}", __FILE__)
  end


  def self.included(base)
    base.let(:backend_class_with_fallbacks) do
      klass = Class.new(I18n::Backend::Simple)
      klass.send(:include, I18n::Backend::Fallbacks)
      klass
    end
  end
end

RSpec.configure do |config|
  config.before do
    I18n.load_path = [File.dirname(__FILE__) + "/fixtures/locales.yml"]
    FileUtils.rm_rf(temp_path)
  end

  config.after do
    FileUtils.rm_rf(temp_path)
  end

  config.include Helpers

  # Remove deprecation warnings
  config.expect_with :rspec do |c|
    c.syntax = [:should, :expect]
  end
  config.mock_with :rspec do |c|
    c.syntax = [:should, :expect]
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
i18n-js-3.1.0 spec/spec_helper.rb
i18n-js-3.0.11 spec/spec_helper.rb
i18n-js-3.0.10 spec/spec_helper.rb
i18n-js-3.0.9 spec/spec_helper.rb
i18n-js-3.0.8 spec/spec_helper.rb
i18n-js-3.0.7 spec/spec_helper.rb
i18n-js-3.0.6 spec/spec_helper.rb