Skip to content

Instantly share code, notes, and snippets.

@rdunlop
rdunlop / rubocop_pre_commit_hook
Last active May 5, 2017 08:31
Ruby style guide git pre-commit hook using Rubocop as the style guide checker. Only runs on staged ruby files that have been added and/or modified. Itself passes rubocop with default settings.
#!/usr/bin/env ruby
require 'rubocop'
ADDED_OR_MODIFIED = /A|AM|^M/
# to prevent code injection: system is a dangerous call
def raise_single_quote_error
raise ArgumentError, 'Single quotes are not allowed in filenames here.'
end
@rdunlop
rdunlop / Gemfile
Created February 5, 2017 14:27
Example of using RSpec doubles with processor expecting proc
source 'https://rubygems.org'
gem 'rspec'
@rdunlop
rdunlop / increment_test.rb
Created September 20, 2016 04:06
Rails 5 increment! does not invoke callbacks
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
gemfile(true) do
source "https://rubygems.org"
# Activate the gem you are reporting the issue against.

Keybase proof

I hereby claim:

  • I am rdunlop on github.
  • I am robindunlop (https://keybase.io/robindunlop) on keybase.
  • I have a public key whose fingerprint is 7483 389D 9542 A9AF 0D05 07FF E9DE 759B E45C 6D95

To claim this, I am signing this object: