Я супер новичок в тестировании своего приложения с помощью Rspec, и я пытаюсь проверить проверку комментария без пользователя и продолжать получать синтаксические ошибки. Вот код модели комментария.Тестирование валидации в модели с использованием Rspec с рельсами
class Comment < ApplicationRecord
validates :body, presence:true
validates :user, presence: true
validates :product, presence: true
validates :rating, numericality: {only_integer: true }
after_create_commit { CommentUpdateJob.perform_later(self, @user) }
belongs_to :user
belongs_to :product
scope:rating_desc, -> { order(rating: :desc) }
end
и вот comment_spec, что им пытаются проверить
require 'rails_helper'
describe Comment do
before do
@product = Product.create!(name: "race bike", description: "fast race bike")
@user = User.create!(email: "[email protected]", password: "Maggie1!")
@product.comments.create!(rating: 1, user: @user, body: "Awful bike!")
end
it "is invalid without a user"
expect(build(:comment, user:nil)).to_not be_valid
end
end
Пожалуйста, помогите !!
/Users/jerryhoglen/.rvm/gems/ruby-2.3.1/gems/activesupport-5.0.0.1/lib/active_support/dependencies.rb:87:in 'load ':/Пользователи/jerryhoglen/Desktop/nameofapp /spec/models/comment_spec.rb:15: синтаксическая ошибка, неожиданное keyword_end, ожидающее окончания ввода (SyntaxError) @ZhongZheng –