Sha256: ba871899b6b08744f9a2436ab76eadd0ca37fab51e92ba31ee4a4a34c40955ac

Contents?: true

Size: 1.28 KB

Versions: 4

Compression:

Stored size: 1.28 KB

Contents

require 'rprogram/program'

require 'spec_helper'
require 'classes/ls_program'

describe Program do
  subject { Program.new('/usr/bin/cc') }
  after(:all) { LS.path = nil }

  it "should create a Program from a path" do
    subject.should_not be_nil
  end

  it "should derive the program name from a path" do
    subject.name.should == 'cc'
  end

  it "should return the program path when converted to a String" do
    subject.to_s.should == '/usr/bin/cc'
  end

  it "should raise an exception for invalid paths" do
    lambda {
      Program.new('/totally/doesnt/exist')
    }.should raise_error(ProgramNotFound)
  end

  it "should find a program from a path" do
    prog = Program.find_with_path('/usr/bin/cc')

    prog.should_not be_nil
  end

  it "should find a program from given paths" do
    prog = Program.find_with_paths(['/usr/bin/ls','/bin/ls'])

    prog.should_not be_nil
  end

  it "should be able to find a program based on the program names" do
    ls = LS.find

    File.executable?(ls.path).should == true
  end

  it "should raise a ProgramNotFound exception if no path/name is valid" do
    lambda {
      Program.find
    }.should raise_error(ProgramNotFound)
  end

  it "should allow using a default path" do
    LS.path = '/usr/bin/dir'

    LS.find.path.should == LS.path
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rprogram-0.2.3 spec/program_spec.rb
rprogram-0.2.2 spec/program_spec.rb
rprogram-0.2.1 spec/program_spec.rb
rprogram-0.2.0 spec/program_spec.rb