Skip to content

Instantly share code, notes, and snippets.

@tbuehlmann
Created April 6, 2021 10:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tbuehlmann/5a26afd795189979d8cb69970a64ced9 to your computer and use it in GitHub Desktop.
Save tbuehlmann/5a26afd795189979d8cb69970a64ced9 to your computer and use it in GitHub Desktop.
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(false) do
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
gem 'activerecord', '6.1.3.1'
gem 'sqlite3'
gem 'rspec'
end
require 'active_record'
require 'rspec'
ActiveRecord::Base.establish_connection(adapter: 'sqlite3', database: ':memory:')
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts do |t|
t.string :title
end
end
Post = Class.new(ActiveRecord::Base)
RSpec.describe do
it '#previous_changes' do
post = Post.create!(title: 'foo')
post.update!(title: 'bar')
expect(post.previous_changes).to eq('title' => ['foo', 'bar'])
end
end
RSpec::Core::Runner.invoke
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment