Sha256: 4dbbdbc09395472b96f93ddf0e80bd26f735b032229c2f9807f290b64e6428da

Contents?: true

Size: 987 Bytes

Versions: 88

Compression:

Stored size: 987 Bytes

Contents

require 'epitools/clitools'

describe String do

  it "highlights" do
    color = :light_yellow
    highlighted = "xxx#{"match".send(color)}zzz"

    "xxxmatchzzz".highlight(/match/, color).should   == highlighted
    "xxxmatchzzz".highlight("match", color).should   == highlighted
    "xxxmatchzzz".highlight(/m.+h/, color).should    == highlighted
    "xxxmatchzzz".highlight(/MATCH/i, color).should  == highlighted
  end

  it "highlights with a block" do
    result = "xxxmatchxxx".highlight(/match/) { |match| "<8>#{match}</8>" }
    result.should == "xxx<8>match</8>xxx"
  end
  
  it "cmds" do
    cmd( ['test -f ?', __FILE__] ).should == true
    cmd( ['test -d ?', __FILE__] ).should == false
    cmd( "test", "-f", __FILE__ ).should == true 
    cmd( "test", "-d", __FILE__ ).should == false
    
    lambda { cmd( ["test -f ? ?", __FILE__] ) }.should raise_error  # too many ?'s
    lambda { cmd( ["test -f", __FILE__] ) }.should raise_error      # too few ?'s
  end
    
end

Version data entries

88 entries across 88 versions & 1 rubygems

Version Path
epitools-0.5.98 spec/clitools_spec.rb
epitools-0.5.97 spec/clitools_spec.rb
epitools-0.5.96 spec/clitools_spec.rb
epitools-0.5.95 spec/clitools_spec.rb
epitools-0.5.94 spec/clitools_spec.rb
epitools-0.5.93 spec/clitools_spec.rb
epitools-0.5.92 spec/clitools_spec.rb
epitools-0.5.91 spec/clitools_spec.rb
epitools-0.5.90 spec/clitools_spec.rb
epitools-0.5.89 spec/clitools_spec.rb
epitools-0.5.88 spec/clitools_spec.rb
epitools-0.5.87 spec/clitools_spec.rb
epitools-0.5.86 spec/clitools_spec.rb
epitools-0.5.85 spec/clitools_spec.rb
epitools-0.5.84 spec/clitools_spec.rb
epitools-0.5.83 spec/clitools_spec.rb
epitools-0.5.82 spec/clitools_spec.rb
epitools-0.5.81 spec/clitools_spec.rb
epitools-0.5.79 spec/clitools_spec.rb
epitools-0.5.78 spec/clitools_spec.rb