Created
May 7, 2015 09:00
-
-
Save shingara/cd4f768f7b20e0d24d8a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'spec_helper' | |
require 'analytics/top_seller' | |
RSpec.describe Analytics::TopSeller do | |
before do | |
Analytics::Storage.redis = InitRedis.get_test | |
end | |
after do | |
Analytics::Storage.redis.flushdb | |
end | |
describe ".top" do | |
before do | |
Analytics::Storage.zincrby("ca_by_user", 1000, "12") | |
Analytics::Storage.zincrby("ca_by_user", 12000, "13") | |
Analytics::Storage.zincrby("ca_by_user", 300, "14") | |
end | |
it 'return the 10 top sellers' do | |
expect(Analytics::TopSeller.top(2)).to eql([ | |
Analytics::TopSeller.new("13", 12000), | |
Analytics::TopSeller.new("12", 1000), | |
]) | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment