Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created March 6, 2015 17:19
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 tenderlove/71176fa23d123e036f1f to your computer and use it in GitHub Desktop.
Save tenderlove/71176fa23d123e036f1f to your computer and use it in GitHub Desktop.
require 'active_record'
require 'minitest/autorun'
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Base.connection.instance_eval do
create_table(:users) do |t|
t.string :name
t.timestamps
end
end
class User < ActiveRecord::Base
end
Class.new(Minitest::Test) do
def test_blah
u = User.new
t = 1.hour.ago.utc
u.name = 'Aaron'
u.updated_at = t
u.save!
u.reload
assert_equal t, u.updated_at
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment