require "spec_helper" describe Recommendations::User::Similarity do describe "#update similarity" do subject {Recommendations::User.new("1")} let :ratings do { "1" => { "1" => "5", "2" => "4", "3" => "3", "4" => "2" }, "2" => { "1" => "5", "2" => "4", "3" => "2", "4" => "1" }, "3" => { "1" => "1", "2" => "2", "3" => "1", "4" => "1" }, "4" => { "1" => "4", "2" => "3", "3" => "2", "4" => "1" } } end before do ratings.each do |user_id, user_ratings| user = Recommendations::User.new(user_id) user_ratings.each {|item_id, rating| user.rate(item_id, rating)} end end it "update similars" do subject.update_similars subject.similars.should == %w(2 4 3) end end end