Sha256: d703622c1842236d3e62d4d2a3b201fe60dfb2a2855030ebf53f6897e3e03bf8

Contents?: true

Size: 1.25 KB

Versions: 7

Compression:

Stored size: 1.25 KB

Contents

require 'spec_helper'

describe LitmusPaper::Dependency::Script do
  describe "#available?" do
    it "is true when the script returns 0" do
      check = LitmusPaper::Dependency::Script.new("true")
      check.should be_available
    end

    it "is false when the script returns 1" do
      check = LitmusPaper::Dependency::Script.new("false")
      check.should_not be_available
    end

    it "is false when the script exceeds the timeout" do
      check = LitmusPaper::Dependency::Script.new("sleep 10", :timeout => 1)
      check.should_not be_available
    end

    it "kills the child process when script check exceeds timeout" do
      check = LitmusPaper::Dependency::Script.new("sleep 50", :timeout => 1)
      check.should_not be_available
      expect { Process.kill(0, check.script_pid) }.to raise_error(Errno::ESRCH)
    end

    it "can handle pipes" do
      check = LitmusPaper::Dependency::Script.new("ls | grep lib")
      check.should be_available

      check = LitmusPaper::Dependency::Script.new("ls | grep missing")
      check.should_not be_available
    end
  end

  describe "to_s" do
    it "returns the command" do
      check = LitmusPaper::Dependency::Script.new("sleep 10")
      check.to_s.should == "Dependency::Script(sleep 10)"
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
litmus_paper-0.8.5 spec/litmus_paper/dependency/script_spec.rb
litmus_paper-0.8.4 spec/litmus_paper/dependency/script_spec.rb
litmus_paper-0.8.3 spec/litmus_paper/dependency/script_spec.rb
litmus_paper-0.8.2 spec/litmus_paper/dependency/script_spec.rb
litmus_paper-0.8.1 spec/litmus_paper/dependency/script_spec.rb
litmus_paper-0.8.0 spec/litmus_paper/dependency/script_spec.rb
litmus_paper-0.7.9 spec/litmus_paper/dependency/script_spec.rb