Skip to content

Instantly share code, notes, and snippets.

View jasoares's full-sized avatar

João Soares jasoares

View GitHub Profile
@jasoares
jasoares / minitest_spec_expectations.md
Created March 14, 2012 19:49 — forked from ordinaryzelig/minitest_spec_expectations.md
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
@jasoares
jasoares / Command line
Created March 14, 2012 21:58 — forked from txus/Command line
Test Framework Benchmark
$ gem install minitest rspec
$ time ruby rspec.rb && time ruby minispec.rb && time ruby minitest.rb
................
Finished in 0.01554 seconds
16 examples, 0 failures
ruby rspec.rb 0.21s user 0.08s system 99% cpu 0.290 total
-------------------------------
@jasoares
jasoares / git_tricks.rb
Created March 27, 2012 03:17
git general trick various objectives
git push [remotename] [localbranch]:[remotebranch]
git pull [remotename] [localbranch]:[remotebranch]
git push [remotename] nil:[remotebranch] => git push [remotename] :[remotebranch] # deletes a remote branch
git pull [remotename] [unexistentlocalbranch]:[remotebranch] # pulls a new remote branch
@jasoares
jasoares / gist:2217790
Created March 27, 2012 16:42
Ruby Exceptions Hierarchy
Object
+--Exception
+--NoMemoryError
+--ScriptError
| +--LoadError
| +--NotImplementedError
| +--SyntaxError
+--SecurityError # Was a StandardError in 1.8
+--SignalException
| +--Interrupt
@jasoares
jasoares / .tmux.conf
Created April 13, 2012 19:37 — forked from josephj/.tmux.conf
My .tmux.conf
# General configuration.
# $ tmux show-options -g
set -g base-index 1
set -g display-time 5000
set -g repeat-time 1000
set -g status-keys vi
set -g status-utf8 on
set -g status-bg black
set -g status-fg white
set -g status-justify left
@jasoares
jasoares / rspec-syntax-cheat-sheet.rb
Created April 28, 2012 18:35 — forked from dnagir/rspec-syntax-cheat-sheet.rb
RSpec 2 syntax cheat sheet by example
# RSpec 2.0 syntax Cheet Sheet by http://ApproachE.com
# defining spec within a module will automatically pick Player::MovieList as a 'subject' (see below)
module Player
describe MovieList, "with optional description" do
it "is pending example, so that you can write ones quickly"
it "is already working example that we want to suspend from failing temporarily" do
pending("working on another feature that temporarily breaks this one")
@jasoares
jasoares / gist:2582480
Created May 3, 2012 01:48
Git ChangeLog Generator
#!/bin/sh
# Converts git log to a ChangeLog file.
git log --pretty=format:"%ai %aN %n%n%x09* %s%d%n" > ChangeLog
@jasoares
jasoares / cucumber_init.sh
Created May 4, 2012 17:41
Cucumber init script for non rails applications
#!/bin/bash
# Create the directory structure
mkdir -p features/step_definitions
mkdir -p features/support
# Create a placeholder for the step_definitions folder
touch features/step_definitions/"$(basename `pwd`)_steps.rb"
# Create the environment file
@jasoares
jasoares / syntax_highlighting.py
Created May 16, 2012 05:47 — forked from JeanMertz/syntax_highlighting.py
Ruby on Rails syntax highlight switcher for Sublime Text 2
import sublime, sublime_plugin
import os
class DetectFileTypeCommand(sublime_plugin.EventListener):
""" Detects current file type if the file's extension isn't conclusive """
""" Modified for Ruby on Rails and Sublime Text 2 """
""" Original pastie here: http://pastie.org/private/kz8gtts0cjcvkec0d4quqa """
def on_load(self, view):
filename = view.file_name()
@jasoares
jasoares / case_statement_ruby.rb
Created May 17, 2012 03:14
Ruby case statement tests
module TestUtils
# def self.case_with_colon_1_8_7(obj)
# return case obj
# when String: puts "String"; "String"
# when Symbol: puts "Symbol"; "Symbol"
# when Fixnum: puts "Fixnum"; "Fixnum"
# when Range : puts "Range" ; "Range"
# end
# end