This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RailsBestPractices | |
module Macros | |
def self.included(base) | |
# Calling of "include RailsBestPractices::Macros" will make all macros available as | |
# class methods within describe { ... } | |
base.extend(ClassMethods) | |
end | |
module ClassMethods |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# instead of Time.now (or watever class methods of Time), we use: | |
LocalTime.now |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Someone | |
class << self | |
def say | |
$stdin.each_line do |line| | |
$stdout << "someone says '#{line}' @ #{Time.now}" | |
end | |
end | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Usages: | |
# | |
# 1. Obtain benchmark results by repeating :spec by running the default number (5) of times | |
# $ rake benchmark[spec] | |
# | |
# 2. Obtain benchmark results by repeating :spec by running it 2 times | |
# $ rake benchmark[spec,2] | |
# | |
task :benchmark, :task, :times do |t, args| | |
times, task = (args.times || 5).to_i.method(:times), args.task |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class TweetObserver < ActiveRecord::Observer | |
observe :post, :implementation, :question | |
def after_create(model) | |
tweet(model.tweet_title, model.tweet_path) | |
end | |
private | |
def tweet(title, path) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/home/ty.archlinux/.rvm/rubies/ruby-1.8.7-p302/lib/ruby/1.8/yaml.rb:133:in `load': syntax error on line 23, col -1: ` ' :cd': "\E[J:ce=\E[K:cl=\E[H\E[J:cm=\E[%i%d;%dH:ct=\E[3g:\" (ArgumentError) | |
' :do': "^J:nd=\E[C:pt:rc=\E8:rs=\Ec:sc=\E7:st=\EH:up=\EM:\" | |
' :le': "^H:bl=^G:cr=^M:it#8:ho=\E[H:nw=\EE:ta=^I:is=\E)0:\" | |
' :li#33:co#127:am:xn:xv:LP:sr': "\EM:al=\E[L:AL=\E[%dL:\" | |
' :cs': "\E[%i%d;%dr:dl=\E[M:DL=\E[%dM:im=\E[4h:ei=\E[4l:mi:\" | |
' :IC': "\E[%d@:ks=\E[?1h\E=:ke=\E[?1l\E>:vi=\E[?25l:\" | |
' :ve': "\E[34h\E[?25h:vs=\E[34l:ti=\E[?1049h:te=\E[?1049l:\" | |
' :us': "\E[4m:ue=\E[24m:so=\E[3m:se=\E[23m:mb=\E[5m:\" | |
' :md': "\E[1m:mr=\E[7m:me=\E[m:ms:\" | |
' :Co#8:pa#64:AF': "\E[3%dm:AB=\E[4%dm:op=\E[39;49m:AX:\" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if Rails.env.test? | |
ActionDispatch::Callbacks.before do | |
CrossStub.refresh :file => Rails.root.join('tmp', 'crossstub.cache') | |
end | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'RMagick' | |
require 'capybara' | |
require 'capybara/dsl' | |
# ================================================================ | |
# Collect input args | |
# ================================================================ | |
begin |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# features/support/cucumber_fuubar_patch.rb | |
module Cucumber::Cli::Configuration::Patch | |
def self.included(base) | |
base.class_eval do | |
alias_method :_orig_formatter_class, :formatter_class | |
def formatter_class(format) | |
if format == 'Cucumber::Formatter::Fuubar' | |
require 'cucumber/formatter/fuubar' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Have u ever found urself doing this: | |
class Thing | |
def size=(size) | |
@size = size | |
end | |
def size | |
@size | |
end | |
end |