Skip to content

Instantly share code, notes, and snippets.

Myron Marston myronmarston

Block or report user

Report or block myronmarston

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View simplecov_setup.rb
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
Bundler 1.6.2 --standalone bug
View output
$ ./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
View learn_sequel_model_spec.rb
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?!
@myronmarston
myronmarston / sequel_example_spec.rb
Last active Aug 29, 2015
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.
View sequel_example_spec.rb
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
View block_weirdness.rb
puts RUBY_DESCRIPTION
class SuperClass
def foo
"foo"
end
end
class SubClass < SuperClass
def foo(arg)
View Gemfile
# A sample Gemfile
source "https://rubygems.org"
gem 'celluloid'
gem 'rspec'
View exit_with_status.rb
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
View failure_example.txt
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 Aug 1, 2014
How to prevent before(:all) hooks in RSpec
View no_before_all_hooks.rb
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
You can’t perform that action at this time.