Sha256: 957d0751769f9c3e990de7417fd565ea41b9308e290ed8279c0a011eb1c94b05

Contents?: true

Size: 1.07 KB

Versions: 19

Compression:

Stored size: 1.07 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 'random' do
    it 'should choose one element from the array' do
      left = [1,2,3]
      100.times do
        left.delete [1,2,3].random
      end
      left.should be_empty
    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
  end

end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
picky-0.9.3 spec/lib/extensions/array_spec.rb
picky-0.9.2 spec/lib/extensions/array_spec.rb
picky-0.9.1 spec/lib/extensions/array_spec.rb
picky-0.9.0 spec/lib/extensions/array_spec.rb
picky-0.3.0 spec/lib/extensions/array_spec.rb
picky-0.2.4 spec/lib/extensions/array_spec.rb
picky-0.2.3 spec/lib/extensions/array_spec.rb
picky-0.2.2 spec/lib/extensions/array_spec.rb
picky-0.2.1 spec/lib/extensions/array_spec.rb
picky-0.2.0 spec/lib/extensions/array_spec.rb
picky-0.1.0 spec/lib/extensions/array_spec.rb
picky-0.0.9 spec/lib/extensions/array_spec.rb
picky-0.0.8 spec/lib/extensions/array_spec.rb
picky-0.0.7 spec/lib/extensions/array_spec.rb
picky-0.0.6 spec/lib/extensions/array_spec.rb
picky-0.0.5 spec/lib/extensions/array_spec.rb
picky-0.0.4 spec/lib/extensions/array_spec.rb
picky-0.0.3 spec/lib/extensions/array_spec.rb
picky-0.0.2 spec/lib/extensions/array_spec.rb