Sha256: 6c41d998b1996c4f2da86eb78ebeef5c4e3ff4575a83e364574166c029c3eb87

Contents?: true

Size: 1.07 KB

Versions: 1

Compression:

Stored size: 1.07 KB

Contents

require 'spec_helper'
module Alf
  describe "Tools#parse_commandline_args" do
    
    subject{ Tools.parse_commandline_args(args) }
    
    describe "on empty string" do
      let(:args){ "" }
      it { should eq([]) }
    end

    describe "on pseudo empty string" do
      let(:args){ "   " }
      it { should eq([]) }
    end

    describe "on a single arg" do
      let(:args){ "--text" }
      it { should eq(["--text"]) }
    end

    describe "on a multiple args" do
      let(:args){ "--text --size=10" }
      it { should eq(["--text", "--size=10"]) }
    end

    describe "on single quoted arg" do
      let(:args){ "'hello'" }
      it { should eq(["hello"]) }
    end

    describe "on single quoted arg with spacing" do
      let(:args){ "'hello the world'" }
      it { should eq(["hello the world"]) }
    end
    
    describe "on double quoted arg" do
      let(:args){ '"hello"' }
      it { should eq(["hello"]) }
    end

    describe "on double quoted arg with spacing" do
      let(:args){ "'hello the world'" }
      it { should eq(['hello the world']) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alf-0.9.3 spec/unit/tools/test_parse_commandline_args.rb