Sha256: 31c21f544cbb2486edbaa03ade879d9690042b50d0540a00549952994a10fdb4

Contents?: true

Size: 1 KB

Versions: 11

Compression:

Stored size: 1 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
  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

11 entries across 11 versions & 1 rubygems

Version Path
litmus_paper-0.8.5 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.8.4 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.8.3 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.8.2 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.8.1 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.8.0 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.7.9 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.7.5 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.7.4 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.7.3 spec/litmus_paper/dependency/file_contents_spec.rb
litmus_paper-0.7.2 spec/litmus_paper/dependency/file_contents_spec.rb