require "spec_helper" describe Recommendations::User::Suggestions do describe "#update_suggestions" do subject {Recommendations::User.new("1")} before do i1 = Recommendations::Item.new("1", violento: 100, romantico: 0, acao: 50) i2 = Recommendations::Item.new("2", violento: 50, romantico: 0, acao: 50) # 1.50 i3 = Recommendations::Item.new("3", violento: 100, romantico: 100, acao: 0) # 1.150, 2.200 i4 = Recommendations::Item.new("4", violento: 70, romantico: 30, acao: 20) # 1.90, 2.80 items = [i1, i2, i3, i4] items.each(&:save!) items.each(&:update_similars) subject.rate("1", 5) end it "updates suggestions" do subject.update_suggestions subject.suggestions.should == {"2" => "2.0", "4" => "2.0", "3" => "2.0"} end end end