Sha256: 35517fe285bd8a27a7d8bcd08de7ef60aed8b7baf3c3a64415666512052b8ff4

Contents?: true

Size: 1.03 KB

Versions: 18

Compression:

Stored size: 1.03 KB

Contents

require 'spec_helper'
require 'localeapp/cli/update'

describe Localeapp::CLI::Update, "#execute" do
  let(:output)  { StringIO.new }
  let(:updater) { Localeapp::CLI::Update.new(:output => output) }
  let(:poller)  { Localeapp::Poller.new }

  before do
    poller
    allow(Localeapp::Poller).to receive(:new) { poller }
  end

  context "when timestamp is recent" do
    before { allow(poller).to receive(:updated_at) { Time.now.to_i - 60 } }

    it "creates a Poller and calls poll! on it" do
      with_configuration do
        expect(poller).to receive(:poll!)
        updater.execute
      end
    end
  end

  context "when timestamp is too old" do
    before { allow(poller).to receive(:updated_at) { 0 } }

    it "warns the user" do
      with_configuration do
        updater.execute
        expect(output.string).to include("Timestamp is missing or too old.")
      end
    end

    it "does not even call the API" do
      with_configuration do
        expect(poller).not_to receive(:poll!)
        updater.execute
      end
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
localeapp-3.3.0 spec/localeapp/cli/update_spec.rb
localeapp-3.2.0 spec/localeapp/cli/update_spec.rb
localeapp-3.1.3 spec/localeapp/cli/update_spec.rb
localeapp-3.1.2 spec/localeapp/cli/update_spec.rb
localeapp-3.1.1 spec/localeapp/cli/update_spec.rb
localeapp-3.1.0 spec/localeapp/cli/update_spec.rb
localeapp-3.0.1 spec/localeapp/cli/update_spec.rb
localeapp-3.0.0 spec/localeapp/cli/update_spec.rb
localeapp-2.5.0 spec/localeapp/cli/update_spec.rb
localeapp-2.4.0 spec/localeapp/cli/update_spec.rb
localeapp-2.3.0 spec/localeapp/cli/update_spec.rb
localeapp-2.2.0 spec/localeapp/cli/update_spec.rb
localeapp-2.1.1 spec/localeapp/cli/update_spec.rb
localeapp-2.1.0 spec/localeapp/cli/update_spec.rb
localeapp-2.0.0 spec/localeapp/cli/update_spec.rb
localeapp-1.0.2 spec/localeapp/cli/update_spec.rb
localeapp-1.0.1 spec/localeapp/cli/update_spec.rb
localeapp-1.0.0 spec/localeapp/cli/update_spec.rb