Sha256: 3a90a9314b92d20ae5bf6d0b70031efe2224b1f9b3304adf641928f1a7939be0

Contents?: true

Size: 723 Bytes

Versions: 14

Compression:

Stored size: 723 Bytes

Contents

require File.expand_path(File.join(File.dirname(__FILE__), "../..", "example_helper.rb"))

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

14 entries across 14 versions & 5 rubygems

Version Path
relevance-tarantula-0.1.6 examples/relevance/tarantula/transform_example.rb
relevance-tarantula-0.1.7 examples/relevance/tarantula/transform_example.rb
relevance-tarantula-0.1.8 examples/relevance/tarantula/transform_example.rb
relevance-tarantula-0.2.0 examples/relevance/tarantula/transform_example.rb
relevance-tarantula-0.2.1 examples/relevance/tarantula/transform_example.rb
relevance-tarantula-0.3.2 examples/relevance/tarantula/transform_example.rb
relevance-tarantula-0.3.3 examples/relevance/tarantula/transform_example.rb
romanbsd-tarantula-0.1.8 examples/relevance/tarantula/transform_example.rb
romanbsd-tarantula-0.2.0 examples/relevance/tarantula/transform_example.rb
tarantula-rails3-0.3.3 examples/relevance/tarantula/transform_example.rb
panmind-tarantula-0.3.3 examples/relevance/tarantula/transform_example.rb
tarantula-0.3.3 examples/relevance/tarantula/transform_example.rb
tarantula-0.1.8 examples/relevance/tarantula/transform_example.rb
tarantula-0.2.0 examples/relevance/tarantula/transform_example.rb