Sha256: a1abec27fd0c1e1054b42157fd121d17c818cd6ee5dcbcf5fd7a0df4cc46aad5

Contents?: true

Size: 1.5 KB

Versions: 13

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'
require 'commander/methods'

describe Commander::Methods do
  it 'includes Commander::UI' do
    expect(subject.ancestors).to include(Commander::UI)
  end

  describe 'AskForClass' do
    it 'includes Commander::UI::AskForClass' do
      expect(subject.ancestors).to include(Commander::UI::AskForClass)
    end

    describe 'defining methods' do
      let(:terminal) { double }

      before do
        allow(terminal).to receive(:ask)
        $_old_terminal = $terminal
        $terminal = terminal
      end

      after do
        $terminal = $_old_terminal
      end

      subject do
        Class.new do
          include Commander::UI::AskForClass
        end.new
      end

      it 'defines common "ask_for_*" methods' do
        expect(subject.respond_to?(:ask_for_float)).to be_truthy
      end

      it 'responds to "ask_for_*" methods for classes that implement #parse' do
        expect(subject.respond_to?(:ask_for_datetime)).to be_truthy
      end

      it 'fails "ask_for_*" method invocations without a prompt' do
        expect do
          subject.ask_for_datetime
        end.to raise_error(ArgumentError)
      end

      it 'implements "ask_for_*"' do
        expect(terminal).to receive(:ask)
        subject.ask_for_datetime('hi')
      end
    end
  end

  it 'includes Commander::Delegates' do
    expect(subject.ancestors).to include(Commander::Delegates)
  end

  it 'does not change the Object ancestors' do
    expect(Object.ancestors).not_to include(Commander::UI)
  end
end

Version data entries

13 entries across 13 versions & 3 rubygems

Version Path
commander-openflighthpc-2.0.2 spec/methods_spec.rb
commander-openflighthpc-2.0.1 spec/methods_spec.rb
commander-openflighthpc-2.0.0 spec/methods_spec.rb
commander-openflighthpc-1.2.0 spec/methods_spec.rb
commander-openflighthpc-1.1.2 spec/methods_spec.rb
commander-openflighthpc-1.1.1 spec/methods_spec.rb
commander-openflighthpc-1.1.0 spec/methods_spec.rb
commander-openflighthpc-1.0.0 spec/methods_spec.rb
commander-openflighthpc-1.0.0.pre.alpha1 spec/methods_spec.rb
commander-4.4.6 spec/methods_spec.rb
commander-4.4.5 spec/methods_spec.rb
commander-fastlane-4.4.6 spec/methods_spec.rb
commander-4.4.4 spec/methods_spec.rb