Skip to content

Instantly share code, notes, and snippets.


Sean Todd descentintomael

View GitHub Profile
descentintomael / log_test_helpers.rb
Created Jun 10, 2016
Some test helpers to make sure something is or isn't logged
View log_test_helpers.rb
module LogTestHelpers
def exclude_from_logs(*hits, &block)
exclude_from_other_logs(test_log_path, *hits, &block)
alias :expect_logs_to_not_include :exclude_from_logs
def exclude_from_other_logs(log_path=test_log_path, *hits, &block)
lines_to_scan = scan_logs log_path, &block
regex = Regexp.union *hits
descentintomael / spec_error_raiser.rb
Created Jun 10, 2016
Simple method for raising custom errors in tests to test error handling
View spec_error_raiser.rb
def new_error(message = 'oops', klass = RuntimeError)
raise klass, message
return $!

Keybase proof

I hereby claim:

  • I am descentintomael on github.
  • I am sean_todd ( on keybase.
  • I have a public key whose fingerprint is B512 CAA8 B053 DFFB B789 C81F A8D9 F6D6 BA96 61D1

To claim this, I am signing this object:

View sub_method_test.rb
class A
def a
def b
def a
descentintomael / date_scopes.rb
Created Mar 12, 2014
This adds in a set of date related scopes for any timestamp column. Date type columns aren't yet supported.
View date_scopes.rb
module DateScopes
extend ActiveSupport::Concern
module ClassMethods
def include_date_scopes
include_date_scopes_for :created_at
def include_date_scopes_for(column, prepend_name = false)
return unless self.table_exists?
descentintomael / security_helper.rb
Last active Dec 21, 2015
A shared example for testing blacklists in controller security.
View security_helper.rb
class SecurityHelper
def self.action_names(controller, opts = {})
actions = controller.class.public_instance_methods(false).reject{|a| a.to_s.starts_with? '_'}
actions - Array(opts[:except])
def self.create_insecure_user(opts = {})
roles = User.available_roles - Array(opts[:allowed_roles]).map(&:to_s)
FactoryGirl.create :user, roles: roles
descentintomael / gist:6246800
Created Aug 16, 2013
What to add to your environment.rb to make rails server start in another time.
View gist:6246800
days = ENV['TIMECOP_DAYS'].nil? ? 0 : ENV['TIMECOP_DAYS'].to_i
minutes = ENV['TIMECOP_MINUTES'].nil? ? 0 : ENV['TIMECOP_MINUTES'].to_i + days.days + minutes.minutes
You can’t perform that action at this time.