Sha256: f3ac927984f3714b1acd305acf3e449da0858b7534c1b4c953d0e9002535ab60

Contents?: true

Size: 928 Bytes

Versions: 15

Compression:

Stored size: 928 Bytes

Contents

require 'spec_helper'

describe MB::Cli::Base do
  subject { cli }

  let(:cli) { described_class.new }

  describe "#display_job" do
    let(:job) { double('job') }

    it "creates a new CliClient with the given job and displays it" do
      cli_client = double('cli_client')
      MB::CliClient.should_receive(:new).with(job).and_return(cli_client)
      cli_client.should_receive(:display)

      subject.display_job(job)
    end
  end

  describe "#requires_one_of" do
    let(:options) { Hash.new }
    let(:ui_stub) { double }

    before do
      cli.stub options: options, ui: ui_stub
    end

    it "exits with an error message" do
      ui_stub.should_receive(:say)
      cli.should_receive(:exit)

      cli.requires_one_of(:a, :b)
    end

    context "with at least one valid option" do
      let(:options) { { a: 1 } }

      it "does not exit" do
        cli.requires_one_of(:a, :b)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
motherbrain-1.5.0 spec/unit/mb/cli/base_spec.rb
motherbrain-1.4.0 spec/unit/mb/cli/base_spec.rb
motherbrain-1.3.0 spec/unit/mb/cli/base_spec.rb
motherbrain-1.2.1 spec/unit/mb/cli/base_spec.rb
motherbrain-1.2.0 spec/unit/mb/cli/base_spec.rb
motherbrain-1.1.3 spec/unit/mb/cli/base_spec.rb
motherbrain-1.1.2 spec/unit/mb/cli/base_spec.rb
motherbrain-1.1.1 spec/unit/mb/cli/base_spec.rb
motherbrain-1.1.0 spec/unit/mb/cli/base_spec.rb
motherbrain-1.0.0 spec/unit/mb/cli/base_spec.rb
motherbrain-0.14.5 spec/unit/mb/cli/base_spec.rb
motherbrain-0.14.4 spec/unit/mb/cli/base_spec.rb
motherbrain-0.14.3 spec/unit/mb/cli/base_spec.rb
motherbrain-0.14.2 spec/unit/mb/cli/base_spec.rb
motherbrain-0.13.1 spec/unit/mb/cli/base_spec.rb