Skip to content

Instantly share code, notes, and snippets.

@ordinaryzelig
ordinaryzelig / minitest_spec_expectations.md
Last active June 4, 2025 17:59
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
@aemkei
aemkei / LICENSE.txt
Last active March 7, 2025 20:08 — forked from 140bytes/LICENSE.txt
Binary Tetris - 140byt.es
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE>
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@typeoneerror
typeoneerror / blah.sqlite
Created January 19, 2012 19:12
making sqlite cli not suck
sqlite> .mod col
sqlite> .headers on
@ryanb
ryanb / index.js.erb
Created December 16, 2011 23:22
Infinite scrolling solution covered in revised episode #114: http://railscasts.com/episodes/114-endless-page-revised
$('#products').append('<%= j render(@products) %>');
<% if @products.next_page %>
$('.pagination').replaceWith('<%= j will_paginate(@products) %>');
<% else %>
$('.pagination').remove();
<% end %>
@flashingpumpkin
flashingpumpkin / ssh-host-complete.sh
Created December 8, 2011 14:26
Auto completing for some commands from your hosts file
#!/bin/bash
# Choose one
complete -W "$(grep -E '^[0-9]' /etc/hosts | awk '{ print $2 }')" ssh scp rsync ping
complete -W "$(grep -E '^ssh' ~/.bash_history | awk '{ print $2 }')" ssh scp rsync
complete -W "$(grep -E '^(\w)' ~/.ssh/known_hosts | awk '{ print $1 }' | sort -u | cut -d ',' -f 1)" ssh scp rsync ping
@blueheadpublishing
blueheadpublishing / erb_import_subtemplates.rb
Created December 6, 2011 19:00
ERB Subtemplating Script: Import ERB From Within ERB
# This script will take the file book.html.erb and parse it. When it encounters
# <%= import('your_file.html.erb') %> it will parse the file and stream
# it into the parent erb file.
require "erb"
class ErbImportSubtemplate
def self.import(file)
# Parse the source erb file
@brentertz
brentertz / rvm2rbenv.txt
Created November 21, 2011 23:00
Switch from RVM to RBENV
## Prepare ###################################################################
# Remove RVM
rvm implode
# Ensure your homebrew is working properly and up to date
brew doctor
brew update
## Install ###################################################################
@BPScott
BPScott / readme.md
Last active February 7, 2024 16:16
Github suggestion: Per-organization email overrides

This totally happened, y'all can stop +1ing this now. GitHub Blog post. Direct link to settings where you can set this.


#Per-organization / per-repo email overrides - A feature suggestion

Here the concepts "organization" and "user" are interchangeable, I'm talking about an entity that owns a repo, whether it is jQuery or John Resig. I'll stick to using organization as it best represents my original use-case.

##TL;DR

@equivalent
equivalent / factories_inside_rails_console.rb
Created November 10, 2011 18:44
use factories inside rails console
require 'factory_girl'
require 'faker' #if needed
Dir[Rails.root.to_s + '/spec/factories/**/*.rb'].each {|file| require file }