Sha256: 8794ae8885dce9e1b19a6a1c5075731fa6c6be1fd11e5af427c45178a0ff0dfe

Contents?: true

Size: 1.15 KB

Versions: 4

Compression:

Stored size: 1.15 KB

Contents

require 'spec_helper'

module Capistrano
  class Configuration

    describe Question do

      let(:question) { Question.new(env, key, default) }
      let(:default) { :default }
      let(:key) { :branch }
      let(:env) { stub }

      describe '.new' do
        it 'takes a key, default' do
          question
        end
      end

      describe '#call' do
        subject { question.call }

        context 'value is entered' do
          let(:branch) { 'branch' }

          before do
            $stdout.expects(:print).with('Please enter branch (default): ')
            $stdin.expects(:gets).returns(branch)
          end

          it 'sets the value' do
            env.expects(:set).with(key, branch)
            question.call
          end
        end

        context 'value is not entered' do
          let(:branch) { default }

          before do
            $stdout.expects(:print).with('Please enter branch (default): ')
            $stdin.expects(:gets).returns('')
          end

          it 'sets the default as the value' do
            env.expects(:set).with(key, branch)
            question.call
          end

        end
      end
    end

  end
end

Version data entries

4 entries across 2 versions & 2 rubygems

Version Path
honeybadger-2.4.0 vendor/gems/ruby/1.9.1/gems/capistrano-3.2.1/spec/lib/capistrano/configuration/question_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.1.0/gems/capistrano-3.2.1/spec/lib/capistrano/configuration/question_spec.rb
honeybadger-2.4.0 vendor/gems/ruby/2.2.0/gems/capistrano-3.2.1/spec/lib/capistrano/configuration/question_spec.rb
capistrano-3.2.1 spec/lib/capistrano/configuration/question_spec.rb