2017-12-11 04:05:11 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-12-11 02:58:18 +00:00
|
|
|
require "spec_helper"
|
|
|
|
|
|
|
|
if ENV["DB"] == "postgres" || JsonVersion.table_exists?
|
|
|
|
RSpec.describe Fruit, type: :model, versioning: true do
|
|
|
|
describe "have_a_version_with_changes matcher" do
|
|
|
|
it "works with Fruit because Fruit uses JsonVersion" do
|
|
|
|
# As of PT 9.0.0, with_version_changes only supports json(b) columns,
|
|
|
|
# so that's why were testing the have_a_version_with_changes matcher
|
|
|
|
# here.
|
|
|
|
banana = Fruit.create!(color: "Red", name: "Banana")
|
2018-12-04 21:10:35 +00:00
|
|
|
banana.update!(color: "Yellow")
|
2017-12-11 02:58:18 +00:00
|
|
|
expect(banana).to have_a_version_with_changes(color: "Yellow")
|
|
|
|
expect(banana).not_to have_a_version_with_changes(color: "Pink")
|
|
|
|
expect(banana).not_to have_a_version_with_changes(color: "Yellow", name: "Kiwi")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|