Sha256: 253a53db47d422754c8041eafe65961e032e1ef70b227ca204c480443c5a89bd

Contents?: true

Size: 1.24 KB

Versions: 4

Compression:

Stored size: 1.24 KB

Contents

require 'spec_helper'
require 'ronin/ui/cli/command'

require 'ui/cli/classes/test_command'

describe UI::CLI::Command do
  subject { TestCommand }

  it "should have a command name" do
    subject.command_name.should == 'test_command'
  end

  describe "#run" do
    it "should allow running the command with options" do
      command = subject.new
      value   = 'bar'

      command.run(:foo => value)

      command.foo.should == value
    end
  end

  describe "#start" do
    subject { TestCommand.new }

    it "should parse options" do
      value = 'baz'
      subject.start(['--foo', value])

      subject.foo.should == value
    end

    it "should parse additional arguments" do
      path = 'to/file.txt'

      subject.start([path])

      subject.path.should == path
    end

    it "should parse additional arguments into an Array/Set argument" do
      value = 'bax'
      path  = 'to/file.txt'
      files = ['one.txt', 'two.txt']

      subject.start(['--foo', value, path, *files])

      subject.foo.should == value
      subject.path.should == path
      subject.files.should == files
    end
  end

  it "should have zero indentation by default" do
    command = subject.new
    command.instance_variable_get('@indent').should == 0
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ronin-1.4.1 spec/ui/cli/command_spec.rb
ronin-1.4.0 spec/ui/cli/command_spec.rb
ronin-1.4.0.rc2 spec/ui/cli/command_spec.rb
ronin-1.4.0.rc1 spec/ui/cli/command_spec.rb