Sha256: fb9501c411c81c98a873a4ed19d98f915070ce11b408d9ecf98100c2d0a3d41d

Contents?: true

Size: 1.1 KB

Versions: 6

Compression:

Stored size: 1.1 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper.rb'
require 'aquarium/extensions/regexp'

describe Regexp, "#empty?" do
  
  it "should return true for an empty regular expression" do
    //.empty?.should be_true
    Regexp.new("").empty?.should be_true
  end
  
  it "should return true for an empty regular expression with whitespace" do
    /   /.empty?.should be_true
    Regexp.new("   ").empty?.should be_true
  end
  
  it "should return false for a non-empty regular expression" do
    /x/.empty?.should be_false
    Regexp.new("x").empty?.should be_false
  end
end

describe Regexp, "#strip" do
  it "should return equivalent Regexp if there is no leading or trailing whitespace." do
    re = /^.{3}.*[a-z]$/
    re.strip.should == re
  end

  it "should return new Regexp with removed leading and/or trailing whitespace, when present." do
    re_string = "^.{3}.*[a-z]$"
    re = Regexp.new "  #{re_string}  "
    re.strip.source.should == re_string
  end
end

describe Regexp, "#<=>" do
  it "should sort by the output of #to_s" do
    ary = [/^x/, /x/, /x$/]
    ary.sort.should == [/^x/, /x$/, /x/]
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
aquarium-0.1.6 spec/aquarium/extensions/regex_spec.rb
aquarium-0.1.7 spec/aquarium/extensions/regex_spec.rb
aquarium-0.1.8 spec/aquarium/extensions/regex_spec.rb
aquarium-0.2.0 spec/aquarium/extensions/regex_spec.rb
aquarium-0.1.0 spec/aquarium/extensions/regex_spec.rb
aquarium-0.1.5 spec/aquarium/extensions/regex_spec.rb