Sha256: 579e9a5e04f343dc575d3baeecead55266b06d54661b9952a26f84e40fc2f540

Contents?: true

Size: 1.34 KB

Versions: 3

Compression:

Stored size: 1.34 KB

Contents

require File.expand_path(File.dirname(__FILE__)+"/../helper.rb")
require_files "condition_matcher"

describe BuildEm::ConditionMatcher, "match" do
  
  before :each do
    @matcher = BuildEm::ConditionMatcher.new
  end
  
  # match(return_code, output, condition)
  
  it "raises an exception when an unsupported condition is supplied" do
    unsupported_type = 1.00
    expecting_exception("unsupported type for condition") { @matcher.match(0,"foo", unsupported_type) } 
  end
  
  describe "output with string matching" do
    it "returns true when it finds a match" do
      @matcher.match(0,"foo", "foo").should == true
    end 
    it "returns true when it can not find a match" do
      @matcher.match(0,"foo", "bar").should == false
    end
  end
  
  describe "output with regexp matching" do
    it "returns true when it finds a match" do
      @matcher.match(0,"very complex output", /\w+\s+complex\s+\w+/).should == true
    end
    it "returns true when it can not find a match" do
      @matcher.match(0,"more [complex] output", /\w+\s+complex\s+\w+/).should == false
    end
  end

  describe "return code matching" do
    it "returns true when it finds a match" do
      @matcher.match(0,"SUCCESS", 0).should == true
    end
    it "returns true when it can not find a match" do
       @matcher.match(0,"FAILURE", 1).should == false
    end
  end
  
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
buildem-1.0.0 spec/unit/condition_matcher_spec.rb
buildem-0.0.5 spec/unit/condition_matcher_spec.rb
buildem-0.0.4 spec/unit/condition_matcher_spec.rb