Sha256: 59817c25ab71854fea19c75cecc86e7114ea38e1fdcd7d07f5e7bbb162847de8

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

require "spec_helper"

describe Qe::Locale do
  let(:i18n) { double("I18n", locale: :en) }

  before do
    stub_const("I18n", i18n)
  end

  context "when including extension" do
    context "before Qe::Locale" do
      it "raises exception" do
        expect {
          mod = Module.new do
            include Qe::Locale
          end
        }.to raise_error(Qe::OutOfOrderError)
      end
    end

    context "after Qe::Locale" do
      it "does nothing" do
        expect {
          mod = Module.new do
            include Qe::Worker
            include Qe::Locale
          end
        }.not_to raise_error
      end
    end
  end

  context "when enqueuing" do
    before do
      Qe.adapter = Qe::Testing
    end

    it "sets locale" do
      expect {
        LocalizedWorker.enqueue
      }.to enqueue(LocalizedWorker).with(locale: :en)
    end

    it "keeps defined locale" do
      expect {
        LocalizedWorker.enqueue(locale: "pt-BR")
      }.to enqueue(LocalizedWorker).with(locale: "pt-BR")
    end
  end

  context "when performing" do
    it "sets locale" do
      i18n
        .should_receive(:locale=)
        .with(:en)

      LocalizedWorker.enqueue
      Qe.drain
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
qe-0.3.4 spec/qe/locale_spec.rb
qe-0.3.3 spec/qe/locale_spec.rb