Skip to content

Instantly share code, notes, and snippets.

View aaronjensen's full-sized avatar

Aaron Jensen aaronjensen

View GitHub Profile
# Needs Ruby 1.8.7
# gem install hipchat
# gem install xmpp4r-simple
# gem install daemons
# run with ruby zentc_to_hipchat.rb start
require 'rubygems'
require 'hipchat'
require 'xmpp4r-simple'
require 'spec_helper'
#Note that while this spec is quite sexy, it shouldn't be taken too far
#this syntax hides deeper meaning that may very well be important.
#I'm using this for a quick spike and I think it's acceptable in certain
#scenarios, but use with caution! Don't get distracted by the shiny...
describe User do
its(:user_profile) { should be }
end
group :development, :test do
# gem 'webrat'
gem 'autotest-rails'
gem 'autotest-growl'
gem "rspec-core", :git => "git://github.com/rspec/rspec-core.git"
gem "rspec-rails", '~> 2.4.1'
gem 'rr'
gem "spork", :git => "git://github.com/timcharper/spork.git"
gem "guard-spork"
gem "rb-fsevent"
# A sample Guardfile
# More info at http://github.com/guard/guard#readme
guard 'spork' do
watch('^config/application.rb$')
watch('^config/environment.rb$')
watch('^config/environments/.*\.rb$')
watch('^config/initializers/.*\.rb$')
watch('^spec/spec_helper\.rb$')
watch('^spec/factories\.rb$')
Autotest.add_hook(:initialize) {|at|
%w{.git .svn .hg .swp .DS_Store ._* tmp}.each do |exception|
at.add_exception(exception)
end
at.clear_mappings # take out the default (test/test*rb)
at.add_mapping(%r%^(spec|third_party)/.*_spec.rb$%) { |filename, _|
filename
}
@aaronjensen
aaronjensen / rspec.rake
Created April 28, 2011 06:38
run rspec in a fork off rake to prevent loading the rails environment again
# /lib/tasks/rspec.rake
namespace :fork do
task :spec do
fork do
RSpec::Core::Runner.disable_autorun!
RSpec::Core::Runner.run(['spec'], $stderr, $stdout) ? exit(0) : exit(1)
end
Process.wait
raise 'rspec failed' unless $?.exitstatus == 0
# exiting the fork can cause MySql to drop the connection
@aaronjensen
aaronjensen / teamcity.rake
Created April 28, 2011 06:53
our teamcity rake.
task :teamcity => ['teamcity:clean', 'teamcity:setup', 'barista:brew', 'fork:spec', 'teamcity:cucumber', 'jasmine:ci']
namespace :teamcity do
task :setup do
RAILS_ENV = 'test'
Rake::Task['db:drop'].invoke
Rake::Task['db:create'].invoke
Rake::Task['db:schema:load'].invoke
end
var z="http://gist.github.com/",y=document.write,x=$("body"),w=$("p.gist").map(function(b,a){a=$(a);var c=$("a",a),u=c.attr("href");if(c.length&&u.indexOf(z)==0)return{p:a,id:u.substring(z.length)}}).get(),v=function(){if(w.length==0)document.write=y;else{var b=w.shift();document.write=function(){document.write=function(a){b.p.replaceWith(a);v()}};x.append('<scr'+'ipt src="'+z+b.id+'.js"></scr'+'ipt>')}};v();
@aaronjensen
aaronjensen / gist:1219565
Created September 15, 2011 15:31
testing cookie deletes in rails
describe MyController do
let(:cookies) { mock('cookies') }
context "when my page is visited" do
it "should delete my cookie" do
controller.stub!(:cookies).and_return(cookies)
cookies.should_receive(:delete).with(cookie, :domain => '.mydomain.com')
get "my_action"
@aaronjensen
aaronjensen / gist:2019573
Created March 12, 2012 03:41 — forked from RobinClowers/gist:2018620
Rspec mock AAA extension
require 'rspec'
# is it really this simple?
RSpec::Matchers.define :have_received do |method_name|
match do |actual|
@args ||= []
@method_name ||= method_name
actual.received_message?(@method_name, *@args)
end