Skip to content

Instantly share code, notes, and snippets.

View craigw's full-sized avatar
🦄

Craig R Webster craigw

🦄
View GitHub Profile
@craigw
craigw / gist:70422
Created February 25, 2009 21:24 — forked from codahale/gist:70417
#!/usr/bin/env ruby
# Let's just worry about what's done to Array directly, and not the insanity
# in any of the parent classes.
$existing_methods = []
def print_methods(library)
new_methods = ([].methods.sort - [].class.superclass.methods.sort) - $existing_methods
for method in new_methods
task :cruise do
execute_tasks %W(configure_cruise gems:unpack gems:build db:migrate)
trace = ARGV.include?("--trace") ? '--trace' : ''
puts %x[rake RAILS_ENV=cucumber db:migrate #{trace}].strip
execute_tasks %W(spec features)
end
# This playing about lead to the following plugin:
# http://github.com/craigw/callback_after_commit/tree/master
# use that instead.
module TransactionCommitCallback
def self.included(base)
base.send(:alias_method, :transaction_without_callbacks,
:transaction)
end
@craigw
craigw / image.feature
Created July 3, 2009 13:05
Testing for a thumbnail in a view
Then I should see the thumbnail "ponies.png"
if @widget.save
flash[:info] = "Your widget has been saved."
flash[:notice] = "There are now #{Widget.count} widgets."
redirect_to @widget and return
else
flash.now[:warning] = "I couldn't save your widget."
render :action => "edit"
end
<%= flash.sort.collect do |level, message|
content_tag(:p, message, :class => "flash #{level}", :id => "flash_#{level}")
end.join %>
<p class="flash info" id="flash_info">Your widget has been saved.</p>
<p class="flash notice" id="flash_notice">There are now 29 widgets.</p>
Time.now
Monkey.find(:all)
@widget.to_s
Time.now.to_f
chicken = Chicken.new
class << chicken
def hide
# ...
end
end
chicken.hide