Sha256: 6da56f14e6eb24c6a40982e96e1df4b91188eb8b91bc0879d9216db3817b3826

Contents?: true

Size: 1.94 KB

Versions: 1

Compression:

Stored size: 1.94 KB

Contents

require File.join(File.dirname(__FILE__), 'support', 'spec_helper')
require 'albacore/albacoremodel'
require 'system_patch'

class RunCommandObject
  include AlbacoreModel
  include RunCommand

  def execute
    result = run_command "Run Command Test Object"
  end
end

describe "when setting the command" do
  before :all do
    @runme = RunCommandObject.new
    @runme.extend SystemPatch

    @runme.command = "test.exe"
    @runme.execute
  end

  it "should execute the specified command, quoted" do
    @runme.system_command.should == "\"test.exe\""
  end
end

describe "when specifying a parmaeter to a command" do
  before :all do
    @runme = RunCommandObject.new
    @runme.extend SystemPatch
    @runme.command = "test.exe"
    @runme.parameters "param1"
    @runme.execute
  end

  it "should separate the parameters from the command" do
    @runme.system_command.should == "\"test.exe\" param1"
  end
end

describe "when specifying multiple parameters to a command" do
  before :all do
    @runme = RunCommandObject.new
    @runme.extend SystemPatch
    @runme.command = "test.exe"
    @runme.parameters "param1", "param2", "param3"
    @runme.execute
  end

  it "should separate all parameters by a space" do
    @runme.system_command.should == "\"test.exe\" param1 param2 param3"
  end
end

describe "when executing a runcommand object twice" do
  before :all do
    @runmeone = RunCommandObject.new
    @runmetwo = @runmeone
    @runmeone.extend SystemPatch
    @runmeone.command = "test.exe"
    @runmeone.parameters "1", "2", "3"

    @runmeone.execute
    @runmetwo.execute
  end

  it "should only pass the parameters to the command once for the first execution" do
    @runmeone.system_command.should == "\"test.exe\" 1 2 3"
  end

  it "should only pass the parameters to the command once for the second execution" do
    @runmetwo.system_command.should == "\"test.exe\" 1 2 3"
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
albacore-0.2.0.preview1 spec/runcommand_spec.rb