Skip to content

Instantly share code, notes, and snippets.

@shingara
Created May 7, 2015 09:00
Show Gist options
  • Save shingara/cd4f768f7b20e0d24d8a to your computer and use it in GitHub Desktop.
Save shingara/cd4f768f7b20e0d24d8a to your computer and use it in GitHub Desktop.
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