Skip to content
This repository
Browse code

Don't depend on order of elements in Set

  • Loading branch information...
commit a307fd6bd37d12d8ad6baa7e7fcfd0207e8b354a 1 parent 1e4be20
authored March 22, 2010

Showing 1 changed file with 16 additions and 5 deletions. Show diff stats Hide diff stats

  1. 21  activerecord/test/cases/finder_test.rb
21  activerecord/test/cases/finder_test.rb
@@ -502,6 +502,18 @@ def test_named_bind_variables
502 502
     assert_kind_of Time, Topic.find(:first, :conditions => ["id = :id", { :id => 1 }]).written_on
503 503
   end
504 504
 
  505
+  class SimpleEnumerable
  506
+    include Enumerable
  507
+
  508
+    def initialize(ary)
  509
+      @ary = ary
  510
+    end
  511
+
  512
+    def each(&b)
  513
+      @ary.each(&b)
  514
+    end
  515
+  end
  516
+
505 517
   def test_bind_enumerable
506 518
     quoted_abc = %(#{ActiveRecord::Base.connection.quote('a')},#{ActiveRecord::Base.connection.quote('b')},#{ActiveRecord::Base.connection.quote('c')})
507 519
 
@@ -511,12 +523,11 @@ def test_bind_enumerable
511 523
     assert_equal '1,2,3', bind(':a', :a => [1, 2, 3])
512 524
     assert_equal quoted_abc, bind(':a', :a => %w(a b c)) # '
513 525
 
514  
-    require 'set'
515  
-    assert_equal '1,2,3', bind('?', Set.new([1, 2, 3]))
516  
-    assert_equal quoted_abc, bind('?', Set.new(%w(a b c)))
  526
+    assert_equal '1,2,3', bind('?', SimpleEnumerable.new([1, 2, 3]))
  527
+    assert_equal quoted_abc, bind('?', SimpleEnumerable.new(%w(a b c)))
517 528
 
518  
-    assert_equal '1,2,3', bind(':a', :a => Set.new([1, 2, 3]))
519  
-    assert_equal quoted_abc, bind(':a', :a => Set.new(%w(a b c))) # '
  529
+    assert_equal '1,2,3', bind(':a', :a => SimpleEnumerable.new([1, 2, 3]))
  530
+    assert_equal quoted_abc, bind(':a', :a => SimpleEnumerable.new(%w(a b c))) # '
520 531
   end
521 532
 
522 533
   def test_bind_empty_enumerable

0 notes on commit a307fd6

Please sign in to comment.
Something went wrong with that request. Please try again.