Retrospring/spec/integration/answer_uniqueness_spec.rb

15 lines
374 B
Ruby
Raw Normal View History

2023-01-01 12:21:14 -08:00
# frozen_string_literal: true
require "rails_helper"
describe "Answer uniqueness" do
let(:user) { FactoryBot.build(:user) }
let(:question) { FactoryBot.create(:question) }
subject { 2.times { user.answer(question, "random") } }
it "does not allow answering the same question twice" do
2023-01-01 12:30:41 -08:00
expect { subject }.to raise_error(ActiveRecord::RecordInvalid)
2023-01-01 12:21:14 -08:00
end
end