Skip to content

Instantly share code, notes, and snippets.

View toch's full-sized avatar
🐱

Christophe Philemotte toch

🐱
View GitHub Profile
@toch
toch / pg_jsonb.rb
Created May 26, 2016 16:06
A Hanami Coercer for PG JSONB Datatype
require "hanami/model/coercer"
require "sequel"
require "sequel/extensions/pg_json"
class PGJsonB < Hanami::Model::Coercer
def self.dump(hash_map)
::Sequel.pg_jsonb(hash_map)
end
def self.load(jsonb)
@toch
toch / ensure_teardown.rb
Created July 12, 2016 14:40
Test how we can release resources or processes when an exception is raised during test
require "minitest/autorun"
def raise_an_exception
raise "Raised!"
end
module Minitest
module Ensure
def ensure_to_call_after(name)
old_test_method = instance_method("test_#{name}")