Sha256: 63fb74132d1fc392b04408deabd92cf5101af3f038fb67a4936adb4db2c7c267

Contents?: true

Size: 1.23 KB

Versions: 24

Compression:

Stored size: 1.23 KB

Contents

require 'spec_helper'
require 'tempfile'

describe LitmusPaper::Dependency::FileContents do
  describe "#available?" do
    it "is true when the file matches the regexp" do
      file_path = SpecHelper.create_temp_file("yes")

      check = LitmusPaper::Dependency::FileContents.new(file_path, /^yes$/)
      check.should be_available
    end

    it "is false when the file does not match the regexp" do
      file_path = SpecHelper.create_temp_file("no")

      check = LitmusPaper::Dependency::FileContents.new(file_path, /^yes$/)
      check.should_not be_available
    end

    it "is false when the script exceeds the timeout" do
      check = LitmusPaper::Dependency::FileContents.new("/dev/zero", /^timeout$/, :timeout => 1)
      check.should_not be_available
    end

    it "logs exceptions and returns false" do
      check = LitmusPaper::Dependency::FileContents.new("/tmp/this_file_does_not_exist", /^foo$/)
      LitmusPaper.logger.should_receive(:info)
      check.should_not be_available
    end
  end

  describe "to_s" do
    it "returns the command" do
      check = LitmusPaper::Dependency::FileContents.new("/path/to/file", /^a.regexp$/)
      check.to_s.should == "Dependency::FileContents(/path/to/file, /^a.regexp$/)"
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
litmus_paper-1.6.2 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.6.1 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.6.0 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.5.0 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.4.2 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.4.1 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.3.0 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.2.0 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.1.1 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.1.0 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-1.0.0 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.9.9 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.9.7 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.9.6 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.9.5 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.9.4 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.9.3 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.9.2 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.9.1 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.9.0 spec/litmus_paper/dependency/file_contents_spec.rb