Skip to content

Instantly share code, notes, and snippets.

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
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
# A sample Gemfile
source "https://rubygems.org"
gem 'celluloid'
gem 'rspec'
@myronmarston
myronmarston / cancel_all_failed.rb
Created June 25, 2014 20:32
Cancel all failed jobs in qless
def cancel_all_failed_jobs(redis)
qless = Qless::Client.new(redis: redis)
qless.jobs.failed.each do |key, count|
puts "#{key}: #{count}"
while (jobs = qless.jobs.failed(key, 0, 1000).fetch("jobs")).any?
qless.bulk_cancel(jobs.map(&:jid))
end
end
end
puts RUBY_DESCRIPTION
class SuperClass
def foo
"foo"
end
end
class SubClass < SuperClass
def foo(arg)
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 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
@myronmarston
myronmarston / output
Created May 10, 2014 07:05
Demonstration of using built in matchers from within a custom matcher
Run options: include {:focus=>true}
All examples were filtered out; ignoring {:focus=>true}
Using built in matchers from custom ones
fails when the word does not end with the given letter (FAILED - 1)
fails when the word does not start with the given letter (FAILED - 2)
can match properly
Failures:
@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