Sha256: a885303e4ac47322d37d4e2662e08515432357d4e15ed4f09fa6e4adcc31f5f4

Contents?: true

Size: 1.09 KB

Versions: 8

Compression:

Stored size: 1.09 KB

Contents

require File.dirname(__FILE__) + '/../spec_helper'
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

8 entries across 8 versions & 1 rubygems

Version Path
aquarium-0.5.1 spec/aquarium/extensions/regex_spec.rb
aquarium-0.4.4 spec/aquarium/extensions/regex_spec.rb
aquarium-0.3.0 spec/aquarium/extensions/regex_spec.rb
aquarium-0.3.1 spec/aquarium/extensions/regex_spec.rb
aquarium-0.4.1 spec/aquarium/extensions/regex_spec.rb
aquarium-0.4.2 spec/aquarium/extensions/regex_spec.rb
aquarium-0.4.0 spec/aquarium/extensions/regex_spec.rb
aquarium-0.4.3 spec/aquarium/extensions/regex_spec.rb