Skip to content

Instantly share code, notes, and snippets.

View nruth's full-sized avatar

Nicholas Rutherford nruth

View GitHub Profile
@nruth
nruth / clonetab.rb
Created July 18, 2010 20:25
OSX open new terminal tab @ current pwd
#!/usr/bin/env ruby
require 'fileutils'
extend FileUtils
cmd1 = "tell application \"System Events\" to tell process \"Terminal\" to keystroke \"t\" using command down"
cmd2 = "tell application \"Terminal\" to do script \"cd #{pwd}\" in the front window"
`osascript -e '#{cmd1}' -e '#{cmd2}'`
@nruth
nruth / Rakefile
Created July 18, 2010 17:11
Heroku bundle downloader -- just add cron
require 'rake'
APP_NAME = 'heroku_app_name'
BACKUP_PATH = '.'
namespace "heroku" do
desc "create a new Heroku bundle and download it, name with timestamp - only use with single bundle addon"
task "backup" do
require 'fileutils'
Given /^#{capture_model} has a question: "([^\"]*)"$/ do |model_name, question|
model = model! model_name
store_model "question", '', model.questions.make(:question => question)
end
Given /^#{capture_model} has a question$/ do |model_name|
model = model! model_name
factory, name_or_index = *parse_model(%Q(question)) #pickle internals
store_model factory, name_or_index, model.questions.make
end
@nruth
nruth / dynamic_show_hide_help_boxes.feature
Created May 24, 2010 02:10
capybara hidden element has_content example
@ignore-hidden-elements
Feature: Div help content hiding and revealing
In order to keep help text available but neatly tucked away when not needed
As a designer
I want javascript to detect div.help and hide it and its contents, replacing with a link to reveal it again
Background:
#this is a rails app with a Page model and a path_to entry for visiting them in features like this (using Pickle for cucumber / machinist integration)
Given a page exists with content: "<div class='help'>foobar</div>"
@nruth
nruth / alias_step.rb
Created November 20, 2009 18:27
Cucumber Step general alias for Then/When/Given
#defines Step, which is the generic When/Then/Given, since they actually have no meaning to cucumber, they're just fluff for human eyes
#written by Ian White, observed by yours truly
module AliasStep
def Step(arg)
When arg
end
end
World(AliasStep)
Given I am on the page links page
When I follow "New Link"
Then I should be on the new page link page
When I fill in "Text" with "Fresh Fruit"
And I fill in "Path" with "fruit"
And I press "Create"
Then 1 page link should exist
When I go to the homepage