Skip to content

Instantly share code, notes, and snippets.

View ianwhite's full-sized avatar

Ian White ianwhite

View GitHub Profile
module VisitorHelper
# give this method an object or collection, optional other arguments, and a block. When you call visit within that block, the block itself will be called with the argument(s)
#
# <ul>
# <% visit tree do |node| %>
# <li>
# <%= node.name %>
# <ul><% visit node.children %></ul>
# </li>
# <% end %>
Smoke.feed(:twitter) do
url "http://twitter.com/statuses/user_timeline/14431882.rss"
discard :title, /(@|#)/
end
Smoke.feed(:delicious) do
url "http://feeds.delicious.com/v2/rss/bschwarz?count=15"
end
Smoke.data(:flickr) do
ary.each do |i|
puts i
end.any? or puts 'none'
# just using ruby (see below) makes for a pretty easy fix in this case, but it could
# get pretty ugly pretty quick which a real world case. Having a 'One True Namespace'
# for conditions would keep the ugly at bay.
#
# So, I think I like the idea of using named_scope as a namespace for conditions (ie
# Luke's idea)
class Tag
has_many :taggings
end
# Snippet from inherit_views Rakefile
#
# The cruise (CI) task runs 'doc:publish' if the build passes
# This runs rdoc, and pushes to gh-pages (using grancher) if the
# doc dir is newer than the gh-pages ref in the local git repo
require 'hanna/rdoctask'
require 'garlic/tasks'
require 'grancher/task'
# Example of pickle: http://github.com/ianwhite/pickle
#
# Just knocked this up to provide an acceptance test for a bug. Took 2 mins
#
# All but the very first step, and the webrat steps, are pickle steps (there are 'category' and 'area' factories)
Feature: Fix bug #98, Categories should be able to have same title, when in different areas
Scenario: I should be able to create two categories called 'General Images' within two different areas
Given I am logged in as an admin
xenon:~/dev/ianwhite/response_for(master)$ garlic shell
Garlic interactive session: type shell commands
garlic:> cd vendor/plugins/repsonse_for
vendor/plugins/repsonse_for: no such directory
garlic:> cd vendor/plugins/response_for
garlic:vendor/plugins/response_for> ruby spec/controllers/*.rb
2.1-stable:
...................................................................................................
Finished in 0.680104 seconds
# example of a 'matrix' set of target versions with garlic
#
# just for kicks I stuck in all the 2.x stable branches, + some 3 different rspecs
#
# a better example would be keeping rspec constant, and where you have 2 real
# app dependencies
garlic do
repo 'nested_has_many_through', :path => '.'
@ianwhite
ianwhite / gist:28376
Created November 24, 2008 04:19
auto generate scoped versions of your webrat steps
# Stick this in features/step_definitions/scoped_webrat_steps.rb
#
# If your webrat steps defines:
#
# When /^I press "(.*)"$/ do |link|
# clicks_link(link)
# end
#
# Then this will also define:
#
class TheController < ActionController::Base
self.view_paths = [File.join(File.dirname(__FILE__), '../fixtures/views')]
def index
respond_to do |format|
format.html do
@html = true
end
format.atom do
@atom = true