Skip to content

Instantly share code, notes, and snippets.

@r7kamura
Created September 20, 2018 12:09
Show Gist options
  • Save r7kamura/83c922e9a16b173000fadc3bbeb49ab0 to your computer and use it in GitHub Desktop.
Save r7kamura/83c922e9a16b173000fadc3bbeb49ab0 to your computer and use it in GitHub Desktop.
require "bundler/inline"
gemfile do
source "https://rubygems.org"
gem "activerecord", "5.2.1", require: "active_record"
gem "sqlite3"
end
ActiveRecord::Base.establish_connection(
adapter: "sqlite3",
database: ":memory:",
)
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Migration[4.2].create_table :ar42s do |t|
t.timestamps
end
ActiveRecord::Migration[5.2].create_table :ar52s do |t|
t.timestamps
end
class Ar42 < ActiveRecord::Base
end
class Ar52 < ActiveRecord::Base
end
require "minitest/autorun"
class ExampleTest < Minitest::Test
def test_ar42_timestamps_nullability
created_at_column = Ar42.columns[1]
assert(created_at_column.null)
end
def test_ar52_timestamps_nullability
created_at_column = Ar52.columns[1]
assert(!created_at_column.null)
end
end
@r7kamura
Copy link
Author

r7kamura commented Sep 20, 2018

-- create_table(:ar42s)
D, [2018-09-20T21:08:26.601571 #16295] DEBUG -- :    (1.6ms)  SELECT sqlite_version(*)
D, [2018-09-20T21:08:26.602120 #16295] DEBUG -- :    (0.4ms)  CREATE TABLE "ar42s" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
   -> 0.0047s
-- create_table(:ar52s)
D, [2018-09-20T21:08:26.602546 #16295] DEBUG -- :    (0.1ms)  CREATE TABLE "ar52s" ("id" integer PRIMARY KEY AUTOINCREMENT NOT NULL, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
   -> 0.0004s
Run options: --seed 31879

# Running:

F.

Finished in 0.004420s, 452.4887 runs/s, 452.4887 assertions/s.

  1) Failure:
ExampleTest#test_ar42_timestamps_nullability [/Users/r7kamura/Desktop/test.rb:36]:
Expected false to be truthy.

2 runs, 2 assertions, 1 failures, 0 errors, 0 skips

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment