Skip to content

Instantly share code, notes, and snippets.

@ianks
Created November 30, 2016 00:02
Show Gist options
  • Save ianks/ba1f7175754780168c2a6618f13c95ec to your computer and use it in GitHub Desktop.
Save ianks/ba1f7175754780168c2a6618f13c95ec to your computer and use it in GitHub Desktop.
# frozen_string_literal: true
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required.'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'activerecord', '5.0.0'
gem 'sqlite3'
end
require 'active_record'
require 'minitest/autorun'
require 'logger'
# Ensure backward compatibility with Minitest 4
Minitest::Test = MiniTest::Unit::TestCase unless defined?(Minitest::Test)
# This connection will do for database-independent bug reports.
ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:'
ActiveRecord::Base.logger = Logger.new(STDOUT)
ActiveRecord::Schema.define do
create_table :posts, force: true do |t|
end
end
class Post < ActiveRecord::Base
end
class BugTest < Minitest::Test
def test_psych_to_json_returns_valid_json
post = Post.new
json = Psych.to_json(post)
puts json
parsed = JSON.parse(json)
assert_instance_of Hash, parsed
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment