Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

set_members and set_intersect return a ruby Set now not an array

  • Loading branch information...
commit 16fd66f6809f1104c9a5239407ee73ea1f587934 1 parent ea13aaf
Ezra Zygmuntowicz authored
Showing with 7 additions and 6 deletions.
  1. +3 −2 lib/redis.rb
  2. +4 −4 spec/redis_spec.rb
View
5 lib/redis.rb
@@ -1,5 +1,6 @@
require 'socket'
require File.join(File.dirname(__FILE__),'better_timeout')
+require 'set'
class RedisError < StandardError
end
@@ -511,7 +512,7 @@ def set_member?(key, member)
def set_intersect(*keys)
timeout_retry(3, 3){
write "SINTER #{keys.join(' ')}\r\n"
- multi_bulk_reply
+ Set.new(multi_bulk_reply)
}
end
@@ -536,7 +537,7 @@ def set_inter_store(destkey, *keys)
def set_members(key)
timeout_retry(3, 3){
write "SMEMBERS #{key}\r\n"
- multi_bulk_reply
+ Set.new(multi_bulk_reply)
}
end
View
8 spec/redis_spec.rb
@@ -209,10 +209,10 @@ class MyFail; def fail; 'it will' end; end
@r.set_add "set", 'key2'
@r.type?('set').should == "set"
@r.set_count('set').should == 2
- @r.set_members('set').sort.should == ['key1', 'key2'].sort
+ @r.set_members('set').should == Set.new(['key1', 'key2'])
@r.set_delete('set', 'key1')
@r.set_count('set').should == 1
- @r.set_members('set').sort.should == ['key2'].sort
+ @r.set_members('set').should == Set.new(['key2'])
@r.delete('set')
end
@@ -239,7 +239,7 @@ class MyFail; def fail; 'it will' end; end
@r.set_add "set", 'key1'
@r.set_add "set", 'key2'
@r.set_add "set2", 'key2'
- @r.set_intersect('set', 'set2').should == ['key2']
+ @r.set_intersect('set', 'set2').should == Set.new(['key2'])
@r.delete('set')
end
@@ -248,7 +248,7 @@ class MyFail; def fail; 'it will' end; end
@r.set_add "set", 'key2'
@r.set_add "set2", 'key2'
@r.set_inter_store('newone', 'set', 'set2')
- @r.set_members('newone').should == ['key2']
+ @r.set_members('newone').should == Set.new(['key2'])
@r.delete('set')
end
Please sign in to comment.
Something went wrong with that request. Please try again.