Skip to content

Instantly share code, notes, and snippets.

original_process = Process.pid
SimpleCov.at_exit do
if Process.pid == original_process
SimpleCov.result.format!
end
end
@myronmarston
myronmarston / output
Created May 1, 2014 04:24
Bundler 1.6.2 --standalone bug
$ ./script.sh
+ rm -rf ./tmp/repro-bundle-standalone-load-path-failure
+ mkdir -p ./tmp/repro-bundle-standalone-load-path-failure
+ cd ./tmp/repro-bundle-standalone-load-path-failure
+ bundle env
Bundler 1.6.2
Ruby 1.8.7 (2013-06-27 patchlevel 374) [i686-darwin12.4.0]
Rubygems 2.0.3
GEM_HOME /Users/myron/.gem/ruby/1.8.7
GEM_PATH /Users/myron/.gem/ruby/1.8.7:/Users/myron/.rubies/ruby-1.8.7-p374/lib/ruby/gems/1.8
@myronmarston
myronmarston / sequel_example_spec.rb
Last active August 29, 2015 14:01
Example showing how to use Sequel without a singleton database. It uses two DB connections -- one that represents a sharded connections (e.g. to connect to many DBs with the same schema) and then a second connection to an individual database with a different schema.
require 'sequel/model'
Sequel.extension :arbitrary_servers, :server_block
non_sharded = Sequel.connect \
adapter: 'mysql2',
host: "localhost",
database: "vanguard_non_sharded",
user: 'root',
password: nil
require "sequel"
# Connect to the DB to make sequel happy. It expects a DB connection when you subclass Sequel::Model
DB = Sequel.sqlite
# Use the module to avoid naming collisions with other specs.
module LearnSequelModelSpec
# Where can I safely declare this class without specifying
# the database for it?!
puts RUBY_DESCRIPTION
class SuperClass
def foo
"foo"
end
end
class SubClass < SuperClass
def foo(arg)
# A sample Gemfile
source "https://rubygems.org"
gem 'celluloid'
gem 'rspec'
require "rspec/exit_matchers/version"
# expect { exit(1) }.to exit_with_status(1)
module RSpec
module ExitMatchers
class ExitWithStatus
def initialize(expected_status)
@expected_status = expected_status
end
185) Operations page
Failure/Error: let(:admin) { create(:admin) }
ActiveRecord::StatementInvalid:
PG::Error: ERROR: relation "admins" does not exist
LINE 5: WHERE a.attrelid = '"admins"'::regclass
^
: SELECT a.attname, format_type(a.atttypid, a.atttypmod),
pg_get_expr(d.adbin, d.adrelid), a.attnotnull, a.atttypid, a.atttypmod
FROM pg_attribute a LEFT JOIN pg_attrdef d
ON a.attrelid = d.adrelid AND a.attnum = d.adnum
@myronmarston
myronmarston / no_before_all_hooks.rb
Created August 1, 2014 15:58
How to prevent before(:all) hooks in RSpec
module PreventContextHooks
def before(*args)
disallow_context_or_all_hooks(args.first)
super
end
def after(*args)
disallow_context_or_all_hooks(args.first)
super
end