Skip to content

Instantly share code, notes, and snippets.

View bsodmike's full-sized avatar

Michael de Silva bsodmike

View GitHub Profile
@ordinaryzelig
ordinaryzelig / minitest_spec_expectations.md
Last active March 23, 2025 21:22
How to write MiniTest::Spec expectations

I'm a fan of MiniTest::Spec. It strikes a nice balance between the simplicity of TestUnit and the readable syntax of RSpec. When I first switched from RSpec to MiniTest::Spec, one thing I was worried I would miss was the ability to add matchers. (A note in terminology: "matchers" in MiniTest::Spec refer to something completely different than "matchers" in RSpec. I won't get into it, but from now on, let's use the proper term: "expectations").

Understanding MiniTest::Expectations

Let's take a look in the code (I'm specifically referring to the gem, not the standard library that's built into Ruby 1.9):

# minitest/spec.rb

module MiniTest::Expectations
@ralph
ralph / install.sh
Created February 20, 2012 11:09
Install Ruby 1.9.3-p125 with falcon patchset, without XCode
brew install https://raw.github.com/adamv/homebrew-alt/master/duplicates/autoconf.rb
brew link autoconf
brew install https://raw.github.com/adammw/homebrew-alt/automake/duplicates/automake.rb
brew link automake
rvm cleanup all
rvm install 1.9.3-perf --patch falcon,debug
@gautamrege
gautamrege / notify.js
Created January 28, 2012 14:43
Notification node server
var express = require('express')
, app = express.createServer()
, io = require('socket.io').listen(app);
app.use(express.bodyParser());
app.listen(13002);
var connections = {}
@bradmontgomery
bradmontgomery / rvm_apache_passenger.txt
Created January 10, 2012 04:45
RVM + Apache + passenger setup for Ubuntu
# Install rvm system-wide
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )
# Update the packages
apt-get update
apt-get upgrade
apt-get install build-essential
# get the packages required by ruby
rvm pkg install zlib
require "money"
class Decorator < BasicObject
undef_method :==
def initialize(component)
@component = component
end
def method_missing(name, *args, &block)
@clooth
clooth / michaels_helper.rb
Created December 13, 2011 13:01
how about this
module ApplicationHelper
def markdown(text, *renderer)
case renderer[0]
props = {
hard_wrap: true,
gh_blockcode: true,
safe_links_only: true,
filter_html: true
}
when :authored
@sinisterchipmunk
sinisterchipmunk / LICENSE
Last active October 23, 2024 21:10
tar, gzip, and untar files using ruby in memory without tempfiles
Copyright (C) 2011 by Colin MacKenzie IV
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
@cmhobbs
cmhobbs / notifier.rb
Created August 16, 2011 21:22
Resque multiple failure notifier via postmark
# this goes in lib/resque/failure/notifier.rb
require 'resque/failure/multiple'
require 'resque/failure/redis'
require 'postmark'
require 'mail'
module Resque
module Failure
class Notifier < Base
@jcasimir
jcasimir / filters.markdown
Created July 22, 2011 18:14
Controller Filters

Controller Filters

The Rails REST implementation dictates the default seven actions for your controllers, but frequently we want to share functionality across multiple actions or even across controllers. Controller filters are the easiest way to do that.

Before, After, and Around

There are three types of filters implemented in Rails:

  • a before_filter runs before the controller action
  • an after_filter runs after the controller action
@bryckbost
bryckbost / gist:1040263
Created June 22, 2011 14:54
Capybara 1.0 and Chrome
# env.rb
Capybara.register_driver :selenium do |app|
Capybara::Selenium::Driver.new(app, :browser => :chrome)
end
Download chromedriver from http://code.google.com/p/selenium/downloads/list
mv chromedriver to /usr/local/bin so it's in your path.