Sha256: 875766b59b39823982b65e42d53f7c56e580e72cf02f3e9df059f3bd0d464950

Contents?: true

Size: 1.33 KB

Versions: 1

Compression:

Stored size: 1.33 KB

Contents

describe CLIForge::CommandSet, "#[]" do
  include_context "fixture config"

  subject {
    described_class.new(config)
  }

  it "should return nil if no command was found" do
    expect(subject[:missing_command]).to eq(nil)
  end

  describe "bin commands" do

    it "should return the first matching command on the search paths" do
      command = subject[:bar]

      expect(command).to be_a(CLIForge::BinCommand)
      expect(command.path).to eq(File.join(FIXTURE_ROOT, "bins", "foo-bar"))
    end

    it "should search subsequent search paths" do
      command = subject[:too]

      expect(command).to be_a(CLIForge::BinCommand)
      expect(command.path).to eq(File.join(FIXTURE_ROOT, "bins2", "foo-too"))
    end

    it "should accept strings" do
      command = subject["bar"]

      expect(command).to be_a(CLIForge::BinCommand)
      expect(command.path).to eq(File.join(FIXTURE_ROOT, "bins", "foo-bar"))
    end

  end

  describe "embedded commands" do

    it "should return embedded commands" do
      command = double("TestCommand")
      config.register_command("my-command", command)

      expect(subject["my-command"]).to be(command)
    end

    it "should prioritize embedded commands" do
      command = double("ABetterBar")
      config.register_command(:bar, command)

      expect(subject[:bar]).to be(command)
    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
cli-forge-0.1.0 spec/unit/cli_forge/command_set/element_reader_spec.rb