Skip to content

Instantly share code, notes, and snippets.

View jstirk's full-sized avatar

Jason Stirk jstirk

View GitHub Profile
@jstirk
jstirk / rcov.rake
Created January 11, 2011 06:41 — forked from alexdreher/rcov.rake
rcov rake task for Rails 3, cucumber, rspec
# Forked to get it working with Rails 3 and RSpec 2
# Updated to aggregate Cucumber and rspec correctly
# Updated to not fail in production when Cucumber, rspec aren't available
#
# From http://github.com/jaymcgavren
#
# Save this as rcov.rake in lib/tasks and use rcov:all =>
# to get accurate spec/feature coverage data
#
# Use rcov:rspec or rcov:cucumber
# This was ripped from one of our Webrat suites - Capybara would be similar, but slightly different...
Then /^I should( not)? see "([^\"]*)" in (.+)$/ do |negatory, text, area|
within(selector_for(area)) do |content|
if negatory.blank? then
content.should contain(text)
else
content.should_not contain(text)
end
end
end
# 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
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"
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' )
# Let Facebooker get Cucumber all set up
require 'facebooker/rails/cucumber'
@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
@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 / 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 / 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\\] "