Sha256: 6aa7a2c5b1afad496f3d32b4e6384c2a4ab00364ef7db0ba0340bc2adf222808

Contents?: true

Size: 1.79 KB

Versions: 151

Compression:

Stored size: 1.79 KB

Contents

require 'spec_helper'

describe Array do

  describe 'sort_by_levenshtein!' do
    it 'should sort right' do
      ['fish', 'flash', 'flush', 'smooch'].sort_by_levenshtein!(:fush).should == ['fish', 'flush', 'flash', 'smooch']
    end
  end
  
  describe "clustered_uniq_fast" do
    it "should generate a new array" do
      ary = [:test1, :test2, :test1]
      ary.clustered_uniq_fast.object_id.should_not == ary.object_id
    end
    it "should not change clusteredly unique arrays" do
      [:test1, :test2, :test1].clustered_uniq_fast.should == [:test1, :test2, :test1]
    end
    it "should not skip interspersed elements" do
      [:test1, :test1, :test2, :test1].clustered_uniq_fast.should == [:test1, :test2, :test1]
    end
    it "should work like uniq if no interspersed elements exist" do
      [:test1, :test1, :test2, :test2, :test3].clustered_uniq_fast.should == [:test1, :test2, :test3]
    end
    it "is fast" do
      performance_of { [:test1, :test1, :test2, :test2, :test3].clustered_uniq_fast }.should < 0.00001
    end
  end
  describe "clustered_uniq" do
    it "should generate a new array" do
      ary = [:test1, :test2, :test1]
      ary.clustered_uniq.object_id.should_not == ary.object_id
    end
    it "should not change clusteredly unique arrays" do
      [:test1, :test2, :test1].clustered_uniq.should == [:test1, :test2, :test1]
    end
    it "should not skip interspersed elements" do
      [:test1, :test1, :test2, :test1].clustered_uniq.should == [:test1, :test2, :test1]
    end
    it "should work like uniq if no interspersed elements exist" do
      [:test1, :test1, :test2, :test2, :test3].clustered_uniq.should == [:test1, :test2, :test3]
    end
    it "is fast" do
      performance_of { [:test1, :test1, :test2, :test2, :test3].clustered_uniq }.should < 0.000012
    end
  end

end

Version data entries

151 entries across 151 versions & 1 rubygems

Version Path
picky-4.10.0 spec/lib/extensions/array_spec.rb
picky-4.9.0 spec/lib/extensions/array_spec.rb
picky-4.8.1 spec/lib/extensions/array_spec.rb
picky-4.8.0 spec/lib/extensions/array_spec.rb
picky-4.7.0 spec/lib/extensions/array_spec.rb
picky-4.6.6 spec/lib/extensions/array_spec.rb
picky-4.6.5 spec/lib/extensions/array_spec.rb
picky-4.6.4 spec/lib/extensions/array_spec.rb
picky-4.6.3 spec/lib/extensions/array_spec.rb
picky-4.6.2 spec/lib/extensions/array_spec.rb
picky-4.6.1 spec/lib/extensions/array_spec.rb
picky-4.6.0 spec/lib/extensions/array_spec.rb
picky-4.5.12 spec/lib/extensions/array_spec.rb
picky-4.5.11 spec/lib/extensions/array_spec.rb
picky-4.5.10 spec/lib/extensions/array_spec.rb
picky-4.5.9 spec/lib/extensions/array_spec.rb
picky-4.5.8 spec/lib/extensions/array_spec.rb
picky-4.5.7 spec/lib/extensions/array_spec.rb
picky-4.5.6 spec/lib/extensions/array_spec.rb
picky-4.5.5 spec/lib/extensions/array_spec.rb