Sha256: 98f971330034cb6e40aa4d8e70e7f0c81abe53cca2feed73851646dc126f8c41
Contents?: true
Size: 1.32 KB
Versions: 8
Compression:
Stored size: 1.32 KB
Contents
require "helper" class LunarSetsTest < Test::Unit::TestCase setup do Lunar.redis(Redis.new(:host => "127.0.0.1", :port => "6380")) Lunar.redis.flushdb @keys = [ "Lunar:Item:name:#{ Lunar.encode('iphone') }", "Lunar:Item:desc:#{ Lunar.encode('iphone') }", "Lunar:Item:tags:#{ Lunar.encode('asian') }", "Lunar:Item:tags:#{ Lunar.encode('hacker') }", "Lunar:Item:tags:#{ Lunar.encode('ninja') }", "Lunar:Item:body:#{ Lunar.encode('ninja') }", "Lunar:Item:body:#{ Lunar.encode('assassin') }" ] @keys.each { |key| Lunar.redis.zadd key, 1, 1001 } end context "given prefix Item, keywords iphone" do should "return both keys" do sets = Lunar::Sets.new("Item", "iphone") assert sets.include?(@keys[0]) assert sets.include?(@keys[1]) end end context "given prefix Item, keywords iphone, field name" do should "return only the name key" do sets = Lunar::Sets.new("Item", "iphone", "name") assert sets.include?(@keys[0]) assert ! sets.include?(@keys[1]) end end context "given asian ninja assassin" do should "return all relevant keys" do sets = Lunar::Sets.new("Item", "asian ninja assassin", "tags") assert sets.include?(@keys[2]) assert sets.include?(@keys[4]) end end end
Version data entries
8 entries across 8 versions & 1 rubygems