Sha256: c4061adbae3a15a67a36cb6af0073e614ce55bbf22f181fb146d7d086607a453

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

require 'rprogram/program'

require 'spec_helper'
require 'classes/ls_program'

describe Program do
  it "should create a Program from a path" do
    prog = Program.new('/usr/bin/ruby')

    prog.should_not be_nil
  end

  it "should derive the program name from a path" do
    prog = Program.new('/usr/bin/ruby')

    prog.name.should == 'ruby'
  end

  it "should return the program path when converted to a String" do
    prog = Program.new('/usr/bin/ruby')

    prog.to_s.should == '/usr/bin/ruby'
  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/dir')

    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 = nil

    lambda {
      ls = LS.find
    }.should_not raise_error(ProgramNotFound)

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rprogram-0.1.8 spec/program_spec.rb
rprogram-0.1.7 spec/program_spec.rb
rprogram-0.1.6 spec/program_spec.rb