Guest User

Untitled

a guest
Sep 6th, 2018
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. require 'rails_helper'
  2.  
  3. describe Product do
  4.  
  5. let(:product) { Product.create!(name: "race bike", color: "blue", description: "Lifechanging Coaching.", price: 45) }
  6.  
  7. let(:user) {User.create!(email: "somepleb271@yahoo.com", password: "20thcentury")}
  8. before do
  9. product.comments.create!(rating: 1, user: user, body: "Bad")
  10. product.comments.create!(rating: 3, user: user, body: "Decent")
  11. product.comments.create!(rating: 5, user: user, body: "Great")
  12. end
  13.  
  14. it "returns the average rating of all comments" do
  15. expect(product.average_rating).to eq 3
  16. end
  17.  
  18. end
Add Comment
Please, Sign In to add comment