Skip to content

Instantly share code, notes, and snippets.

View jstirk's full-sized avatar

Jason Stirk jstirk

View GitHub Profile
@jstirk
jstirk / gist:176809
Created August 28, 2009 06:54
cruise.rake
# This assumes you have the metric_fu and kablame plugins installed.
# Set the artifacts dir for development
ENV['CC_BUILD_ARTIFACTS'] ||= File.expand_path("#{RAILS_ROOT}/metrics")
rspec_base = File.expand_path("#{RAILS_ROOT}/vendor/plugins/rspec/lib")
$LOAD_PATH.unshift(rspec_base) if File.exist?(rspec_base)
require 'spec/rake/spectask'
require 'spec/rake/verify_rcov'
@jstirk
jstirk / gist:176810
Created August 28, 2009 06:54
rcov.rake
require 'cucumber/rake/task' #I have to add this
require 'spec/rake/spectask'
namespace :rcov do
Cucumber::Rake::Task.new(:cucumber) do |t|
t.rcov = true
t.rcov_opts = %w{--rails --exclude osx\/objc,gems\/,spec\/,features\/ --aggregate coverage.data}
t.rcov_opts << %[-o "coverage"]
end
@jstirk
jstirk / gist:188931
Created September 18, 2009 07:50
Bash prompt from my .bashrc file
# Add our current git branch out to our path
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
condense_path() {
pwd | sed "s/\/home\/$USER/~/" | sed -r "s|(\/?)(.[^\/]{0,3})[^\/]*(\/)|\\1\\2\\3|g"
}
PS1="\\[\\033[01;32m\\]\\u@\\h\\[\\033[01;34m\\] \$(condense_path)\\[\\033[01;33m\\]\$(parse_git_branch)\\[\\033[01;34m\\] \\\$\\[\\033[00m\\] "
@jstirk
jstirk / gist:199432
Created October 2, 2009 03:04
cucumber.rake inc. CC.rb task
$LOAD_PATH.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib') if File.directory?(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
begin
require 'cucumber/rake/task'
task :features => 'db:test:prepare'
desc "Run all features"
task :features => "features:all"
@jstirk
jstirk / checker.erb
Created October 15, 2009 22:50 — forked from ocean/checker.erb
<h1>Feeds Checker</h1>
<%
require 'hpricot'
require 'open-uri'
f1 = open("http://www.commerce.wa.gov.au/feeds/feed1.xml")
feed = Hpricot.XML(f1)
@jstirk
jstirk / facebooker_steps.rb
Created July 19, 2010 13:23
Cucumber steps for Facebooker
# Some generic steps to work with Facebooker within Cucumber
# See full post at :
# http://griffin.oobleyboo.com/archive/facebooker-and-cucumber
#
# Standard usage like :
# Background:
# Given our default User
# And I am Facebook friends with UID 2
# And I am Facebook friends with UID 3
# And I am Facebook friends with UID 100000700000000
# Let Facebooker get Cucumber all set up
require 'facebooker/rails/cucumber'
Given /^I am logged in as a Facebook user$/ do
# Initialize facebooker session
# This will set all the parameters that FB normally passes through, as well as set up
# a default Facebooker::Mock::Session. It all just magically happens from this one liner.
@integration_session = open_session
# Now, we need to specify the default options for the request - in this case, we're setting
# that the FB UID is 1, and they have the friends defined in FACEBOOK_FRIENDS - simply UIDs separated by commas.
@integration_session.default_request_params.merge!( :fb_sig_user => 1, :fb_sig_friends => '2,3' )
Scenario: Page Lists Friends
Given my default User
And I am logged in as a Facebook user
When I am on the home page
Then I should see "This will be in the canvas"
# Simulates a request which has not come via Facebook.
# For example, an API request, or webhook request.
Given /^I am not in Facebook$/ do
@integration_session = open_session
@integration_session.canvas=false
end