Sha256: 9ae0540eda538d2648102f59b82118add68a664f8ced7fa3f7240322e20f051c

Contents?: true

Size: 656 Bytes

Versions: 11

Compression:

Stored size: 656 Bytes

Contents

require "spec_helper"

describe "Relevance::Tarantula::Transform" do
  it "can do a simple replace" do
    t = Relevance::Tarantula::Transform.new(/\w/, ".")
    t["hello world"].should == "..... ....."
  end
  
  it "can do a replace with a block" do
    t = Relevance::Tarantula::Transform.new(/([aeiou])/, Proc.new {|value| value.upcase})
    t["hello world"].should == "hEllO wOrld"
  end

  # this is broken in Ruby?
  it "cannot access groups from a block, despite Ruby docs" do
    p = Proc.new {|value| $1.upcase}
    t = Relevance::Tarantula::Transform.new(/([aeiou])/, p)
    lambda {t["hello world"]}.should raise_error(NoMethodError)
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
codez-tarantula-0.5.5 spec/relevance/tarantula/transform_spec.rb
codez-tarantula-0.5.4 spec/relevance/tarantula/transform_spec.rb
codez-tarantula-0.5.3 spec/relevance/tarantula/transform_spec.rb
codez-tarantula-0.5.1 spec/relevance/tarantula/transform_spec.rb
codez-tarantula-0.5.0 spec/relevance/tarantula/transform_spec.rb
tarantula-0.5.1 spec/relevance/tarantula/transform_spec.rb
tarantula-0.5.0 spec/relevance/tarantula/transform_spec.rb
tarantula-0.4.3 spec/relevance/tarantula/transform_spec.rb
tarantula-0.4.2 spec/relevance/tarantula/transform_spec.rb
tarantula-0.4.1 spec/relevance/tarantula/transform_spec.rb
tarantula-0.4.0 spec/relevance/tarantula/transform_spec.rb