Sha256: c6f16578c4f8d48d2e484c5f7684ee8c42b7df84bfa31345555fe862df1543b0

Contents?: true

Size: 1.43 KB

Versions: 1

Compression:

Stored size: 1.43 KB

Contents

require 'spec_helper'

describe Travis::Cli::Config do
  let(:shell)  { Mock::Shell.new }
  let(:config) { "staging:\n  foo: bar" }

  before :each do
    Travis::Cli::Config.any_instance.stubs(:clean?).returns(true)
    Travis::Cli::Config.any_instance.stubs(:run)
    Travis::Keychain.any_instance.stubs(:fetch).returns(config)
    File.stubs(:open)
  end

  describe 'sync' do
    it 'fetches the config from the keychain' do
      command = Travis::Cli::Config.new(shell, 'staging', {})
      command.send(:keychain).expects(:fetch).returns(config)
      command.invoke
    end

    it 'writes the config to the local config file' do
      command = Travis::Cli::Config.new(shell, 'staging', {})
      File.expects(:open).with { |path, mode| path =~ %r(config/travis.yml) }
      command.invoke
    end

    it 'pushes the config to the given heroku remote' do
      command = Travis::Cli::Config.new(shell, 'staging', {})
      command.expects(:run).with { |cmd, options| cmd =~ /heroku config:add travis_config=.* -r staging/m }
      command.invoke
    end

    it 'restarts the app when --restart is given' do
      command = Travis::Cli::Config.new(shell, 'staging', 'restart' => true)
      command.expects(:restart)
      command.invoke
    end

    it 'does not restart the app when --restart is not given' do
      command = Travis::Cli::Config.new(shell, 'staging', {})
      command.expects(:restart).never
      command.invoke
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
travis-cli-0.0.1 spec/travis/cli/config_spec.rb