Skip to content

Instantly share code, notes, and snippets.

View jferris's full-sized avatar

Joe Ferris jferris

  • thoughtbot, inc.
  • Cambridge, MA
View GitHub Profile
require 'spec_helper'
describe 'products/_prime_purchase.html.erb' do
it "tries to sell the user on Prime" do
view.stubs(currently_viewing_subscription_product?: false)
view.stubs(current_user_has_active_subscription?: false)
view.stubs(subscription_product: stub('subscription_product', name: 'foo'))
render template: 'products/_prime_purchase'
@jferris
jferris / benchmark.rb
Created December 5, 2011 15:20 — forked from sikachu/benchmark.rb
Compare between not define a method in subclass and define a method in subclass and call #super
require 'benchmark'
class Base
def foo
true
end
end
class Implicit < Base
end
@jferris
jferris / dependency_injection.rb
Created December 2, 2011 14:45 — forked from croaky/dependency_injection.rb
Dependency Injection in Ruby
module TaxCodeStrategies
class UnitedStates
def call(id)
"US-#{id}"
end
end
class Brazil
def call(id)
"#{id}-BR"
Factory.define :gallery do |f|
f.name "Gallery Name"
end
Factory.define :region do |f|
f.name "Telugu"
end
@jferris
jferris / gist:726204
Created December 2, 2010 22:22 — forked from dball/gist:726192
Factory.define(:estimate_with_items) do |f|
# ...
f.passing(true).ignore
f.after_create do |e|
e.items << Factory(:estimate_item, :estimate => e, :inspection => true, :op => Factory(:inspection_op, :dealer => e.dealer)).tap do |item|
inspection = item.inspections.first
location = inspection.locations.first
outcome = inspection.failures.detect { |outcome| outcome.performed == passing }
location.create_data!(:inspection_failure_id => outcome.id, :created_by => 'factory')
notify_deploy_environments = %w(staging production)
notify_deploy_roles = %w(solo app_master)
if notify_deploy_environments.include?(@configuration[:environment]) && notify_deploy_roles.include?(node['instance_role'])
# Notify Hoptoad of deploy
run "cd #{release_path} && rake hoptoad:deploy TO=#{@configuration[:environment]} REVISION=#{@configuration[:revision]} REPO=#{@configuration[:repository]}"
end