Sha256: bb0effe58b8c7b3fe25f1ac80e75961bcd9df244b3924129a8876f6644a97bf1

Contents?: true

Size: 900 Bytes

Versions: 17

Compression:

Stored size: 900 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

require "knj/strings"
require "knj/errors"

describe "Strings" do
  it "regex" do
    regex = Knj::Strings.regex("/(\d+)/i")
    raise "Regex should be '(?i-mx:(d+))' but wasnt: '#{regex}'." if "#{regex}" != "(?i-mx:(d+))"
    
    regex = Knj::Strings.regex("/\d+/")
    raise "Regex should be '(?-mix:d+)' but wasnt: '#{regex}'." if "#{regex}" != "(?-mix:d+)"
    
    begin
      regex = Knj::Strings.regex("/\d+/U")
      raise "Ruby doesnt support the U-modifier - an exception should be thrown!"
    rescue Knj::Errors::InvalidData
      #this should happen - Ruby doesnt support U-modifier...
    end
    
    res = Knj::Strings.is_regex?("Kasper")
    raise "Expected res to be false but it wasnt." if res
    
    res = Knj::Strings.is_regex?("/^Kasper$/")
    raise "Expected res to be true but it wasnt." if !res
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
knjrbfw-0.0.59 spec/strings_spec.rb
knjrbfw-0.0.58 spec/strings_spec.rb
knjrbfw-0.0.57 spec/strings_spec.rb
knjrbfw-0.0.55 spec/strings_spec.rb
knjrbfw-0.0.54 spec/strings_spec.rb
knjrbfw-0.0.53 spec/strings_spec.rb
knjrbfw-0.0.52 spec/strings_spec.rb
knjrbfw-0.0.51 spec/strings_spec.rb
knjrbfw-0.0.50 spec/strings_spec.rb
knjrbfw-0.0.49 spec/strings_spec.rb
knjrbfw-0.0.48 spec/strings_spec.rb
knjrbfw-0.0.47 spec/strings_spec.rb
knjrbfw-0.0.46 spec/strings_spec.rb
knjrbfw-0.0.45 spec/strings_spec.rb
knjrbfw-0.0.44 spec/strings_spec.rb
knjrbfw-0.0.43 spec/strings_spec.rb
knjrbfw-0.0.42 spec/strings_spec.rb