Sha256: e41119d6ed7be00aa8f6a1d4e32fafc4497f027c845da7c3b55f735d9388f476

Contents?: true

Size: 1.74 KB

Versions: 1

Compression:

Stored size: 1.74 KB

Contents

# encoding: utf-8
#
# This file is part of the lazier gem. Copyright (C) 2013 and above Shogun <shogun_panda@cowtech.it>.
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
#

require "spec_helper"

describe Lazier::Localizer do
  describe "#initialize" do
    it "should call i18n_setup and then i18n=" do
      expect_any_instance_of(::Lazier::Localizer).to receive(:i18n_setup).with("ROOT", "PATH")
      expect_any_instance_of(::Lazier::Localizer).to receive(:i18n=).with(:it)
      ::Lazier::Localizer.new("ROOT", "PATH", :it)
    end

    it "should setup default arguments" do
      expect_any_instance_of(::Lazier::Localizer).to receive(:i18n_setup).with(:lazier, ::File.absolute_path(::Pathname.new(::File.dirname(__FILE__)).to_s + "/../../locales/"))
      expect_any_instance_of(::Lazier::Localizer).to receive(:i18n=).with(nil)
      ::Lazier::Localizer.new
    end
  end

  describe ".localize" do
    it "should create a new localizer and forward the message" do
      obj = ::Object.new
      expect(obj).to receive(:string).with("ARGUMENT")

      expect(::Lazier::Localizer).to receive(:new).and_call_original
      expect_any_instance_of(::Lazier::Localizer).to receive(:i18n).and_return(obj)
      ::Lazier::Localizer.localize(:string, "ARGUMENT")
    end
  end

  describe ".localize_on_locale" do
    it "should create a new localizer and forward the message" do
      obj = ::Object.new
      expect(obj).to receive(:string).with("ARGUMENT")

      expect(::Lazier::Localizer).to receive(:new).with(nil, nil, :it).and_call_original
      expect_any_instance_of(::Lazier::Localizer).to receive(:i18n).and_return(obj)
      ::Lazier::Localizer.localize_on_locale(:it, :string, "ARGUMENT")
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lazier-3.3.6 spec/lazier/localizer_spec.rb