Sha256: 2027a77a4fa574e49cd8dcd4268eb219a6157f6898056965925f3c24c1e6f922

Contents?: true

Size: 1.5 KB

Versions: 9

Compression:

Stored size: 1.5 KB

Contents

require 'spec_helper'
require 'command_kit/arguments/argument_value'

describe CommandKit::Arguments::ArgumentValue do
  let(:required) { false  }
  let(:usage)    { 'FOO'  }

  subject do
    described_class.new(
      required: required,
      usage:    usage
    )
  end

  describe "#initialize" do
    it "must require a usage: keyword"do
      expect {
        described_class.new(required: required)
      }.to raise_error(ArgumentError)
    end

    context "when required: is given" do
      subject { described_class.new(required: required, usage: usage) }

      it "must set #required" do
        expect(subject.required).to eq(required)
      end
    end

    context "when required: is not given" do
      subject { described_class.new(usage: usage) }

      it "must default to true" do
        expect(subject.required).to be(true)
      end
    end
  end

  describe "#required?" do
    context "when required: is initialized with true" do
      let(:required) { true }

      it { expect(subject.required?).to be(true) }
    end

    context "when required: is initialized with false" do
      let(:required) { false }

      it { expect(subject.required?).to be(false) }
    end
  end

  describe "#optional?" do
    context "when required: is initialized with true" do
      let(:required) { true }

      it { expect(subject.optional?).to be(false) }
    end

    context "when required: is initialized with false" do
      let(:required) { false }

      it { expect(subject.optional?).to be(true) }
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
command_kit-0.4.1 spec/arguments/argument_value_spec.rb
command_kit-0.4.0 spec/arguments/argument_value_spec.rb
command_kit-0.3.0 spec/arguments/argument_value_spec.rb
command_kit-0.2.2 spec/arguments/argument_value_spec.rb
command_kit-0.2.1 spec/arguments/argument_value_spec.rb
command_kit-0.2.0 spec/arguments/argument_value_spec.rb
command_kit-0.1.0 spec/arguments/argument_value_spec.rb
command_kit-0.1.0.rc1 spec/arguments/argument_value_spec.rb
command_kit-0.1.0.pre2 spec/arguments/argument_value_spec.rb