Testing Wotsit Model Versioning Implementation in PaperTrail
This test suite validates the versioning functionality of the Wotsit model in PaperTrail, focusing on timestamp recording and update operations. The tests ensure proper version history tracking and error handling during model updates.
Test Coverage Overview
Implementation Analysis
Technical Details
Best Practices Demonstrated
paper-trail-gem/paper_trail
spec/models/wotsit_spec.rb
# frozen_string_literal: true
require "spec_helper"
RSpec.describe Wotsit, versioning: true do
it "update! records timestamps" do
wotsit = described_class.create!(name: "wotsit")
wotsit.update!(name: "changed")
reified = wotsit.versions.last.reify
expect(reified.created_at).not_to(be_nil)
expect(reified.updated_at).not_to(be_nil)
end
it "update! does not raise error" do
wotsit = described_class.create!(name: "name1")
expect { wotsit.update!(name: "name2") }.not_to(raise_error)
end
end