Sha256: 5726f106366c340a371279e2a7dd8376d075c1aac53fdc14a0145167295f93bf

Contents?: true

Size: 1.05 KB

Versions: 3

Compression:

Stored size: 1.05 KB

Contents

require 'spec_helper'

describe WebTranslateIt::AutoFetch do
  let(:application) { double(:application, call: []) }

  let(:env) do
    { 'PATH_INFO' => path }
  end

  subject { described_class.new(application) }

  before { WebTranslateIt.stub(:fetch_translations) }

  after { subject.call(env) }

  context 'path is /' do
    let(:path) { '/' }

    it 'should call the application' do
      application.should_receive(:call).with(env)
    end

    it 'should update the translations' do
      WebTranslateIt.should_receive(:fetch_translations)
    end

    it 'should reload the I18n definitions' do
      I18n.should_receive(:reload!)
    end
  end

  context 'path is /assets/application.js' do
    let(:path) { '/assets/application.js' }

    it 'should call the application' do
      application.should_receive(:call).with(env)
    end

    it 'should not update the translations' do
      WebTranslateIt.should_not_receive(:fetch_translations)
    end

    it 'should not reload the I18n definitions' do
      I18n.should_not_receive(:reload!)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
web_translate_it-2.6.2 spec/web_translate_it/auto_fetch_spec.rb
web_translate_it-2.6.1 spec/web_translate_it/auto_fetch_spec.rb
web_translate_it-2.6.0 spec/web_translate_it/auto_fetch_spec.rb