Sha256: 945b421067fcf55448d66febd160f8da979a3271aa53d8e88246c01396fc2a88

Contents?: true

Size: 838 Bytes

Versions: 2

Compression:

Stored size: 838 Bytes

Contents

require "spec_helper"

describe Recommendations::User::Ratings do
  subject {Recommendations::User.new("1")}

  describe "#rate" do
    before {subject.rate("890", 4.5)}

    it "stores a user rating for this item" do
      Recommendations.redis.hget("recommendations:ratings:user:1", "890").should == "4.5"
    end

    it "stores an item rating for this user" do
      Recommendations.redis.zscore("recommendations:ratings:item:890", "1").should == "4.5"
    end
  end

  describe "#ratings" do
    let :ratings do
      {
        "1" => "5",
        "2" => "4",
        "3" => "3",
        "4" => "2",
        "5" => "1"
      }
    end

    before do
      ratings.each {|k, v| subject.rate(k, v)}
    end

    it "returns all ratings" do
      subject.ratings.should == ratings
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
recommendations2-0.0.5 spec/recommendations/user/ratings_spec.rb
recommendations2-0.0.4 spec/recommendations/user/ratings_spec.rb