Sha256: a2c7c6531e4c661a6b11189acc181758f0b4dedb5ba3efffcb164b43dc2a1a5d
Contents?: true
Size: 1.11 KB
Versions: 2
Compression:
Stored size: 1.11 KB
Contents
require "spec_helper" describe Recommendations::Item do subject {Recommendations::Item.new("1", violent: 100, romantic: 25)} describe "#initialize" do its(:id) {should == "1"} its(:categories) {should == {violent: 100, romantic: 25}} end describe "#similars" do context "when count was not specified" do let(:count) {Recommendations.configuration.similar_items_count - 1} it "gets sorted set range from similar count configuration" do Recommendations.redis.should_receive(:zrange) .with("recommendations:similars:item:1", 0, count) .and_return ["2", "3", "4"] subject.similars.should == ["2", "3", "4"] end end context "when count was specified" do it "gets sorted set range until count" do Recommendations.redis.should_receive(:zrange) .with("recommendations:similars:item:1", 0, 9) .and_return ["2", "3", "4"] subject.similars(10).should == ["2", "3", "4"] end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
recommendations2-0.0.5 | spec/recommendations/item_spec.rb |
recommendations2-0.0.4 | spec/recommendations/item_spec.rb |