Sha256: 55fa9274cf9c08844be6ae95b883204d9151068aa6e9f566cab33ddf0ed782ff

Contents?: true

Size: 1.61 KB

Versions: 1

Compression:

Stored size: 1.61 KB

Contents

# encoding: utf-8

require File.dirname(__FILE__) + '/../integration_helper'
require 'locomotive/wagon/commands/push_command'
require 'thor'

describe Locomotive::Wagon::PushCommand do

  before { VCR.insert_cassette 'push', record: :new_episodes, match_requests_on: [:method, :query, :body] }
  after  { VCR.eject_cassette }

  let(:env)       { 'production' }
  let(:path)      { default_site_path }
  let(:shell)     { Thor::Shell::Color.new }
  let(:options)   { { data: true, verbose: true } }
  let(:command)   { described_class.new(env, path, options, shell) }

  describe '#push' do

    subject { command.push }

    context 'unknown env' do

      let(:credentials) { instance_double('Credentials', login: TEST_API_EMAIL, password: TEST_API_KEY) }
      let(:env) { 'hosting' }

      before do
        allow(Netrc).to receive(:read).and_return(TEST_PLATFORM_ALT_URL => credentials)
        allow(Thor::LineEditor).to receive(:readline).and_return(TEST_PLATFORM_URL.dup, '')
      end

      after { restore_deploy_file(default_site_path) }

      it 'creates a site and push the site' do
        resources = []
        ActiveSupport::Notifications.subscribe('wagon.push') do |name, start, finish, id, payload|
          resources << payload[:name]
        end
        is_expected.not_to eq nil
        expect(resources).to eq %w(content_types content_entries pages snippets theme_assets translations)
      end

      context 'no previous authentication' do

        let(:credentials) { nil }

        it { expect { subject }.to raise_error('You need to run wagon authenticate before going further') }

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
locomotivecms_wagon-2.0.0.pre.alpha.3 spec/integration/commands/push_command_spec.rb