Skip to content

Instantly share code, notes, and snippets.

njero - http://neverlet.be
sutto - http://blog.ninjahideout.com
zapnap - http://blog.zerosum.org
tpope - http://tpope.net
reinh - http://reinh.com
bryanl - http://smartic.us
linoj - http://www.vaporbase.com
technicalpickles - http://technicalpickles.com
MaD15 - enlightsolutions.com/
qrush - http://litanyagainstfear.com/
# Standard cascade of JSON dependencies.
# Cascades from fastest performing & hardest dependency management (odd C libraries)
# to slowest performing & easiest dependency management (pure Ruby)
# Meant for libraries like TwitterSearch & LeGit
def cascade_require(*libs)
require libs.shift.to_s
rescue LoadError
libs.empty? ? raise : retry
end
Scenario: Viewing events atom feed
Given a future special event exists with a title of "Barcamp Boston"
Given a future recurring event exists with a title of "Hackfest"
When I go to events.atom
Then I should see an entry for "Barcamp Boston"
And I should see an entry for "Hackfest"
Then /^I should not see an entry for for "(.*)"$/ do |title|
assert_select 'events event title', :text => title, :count => 0
end
# sudo gem install faker
desc "Load db with test data"
task :lorem => ['db:reset', :environment] do
require 'factory_girl'
require 'faker'
Factory.define :lorem_post, :class => :post do |post|
post.title { Faker::Lorem.sentence }
post.body { Faker::Lorem.paragraphs.join(' ') }
@croaky
croaky / .gems
Created September 9, 2009 00:08 — forked from bmizerany/.gems
rack_hoptoad

The problem is that it's hard to achieve the same result as Shoulda/Remarkable matchers using only RSpec:

it {
  user = User.new
  user.should be_invalid
  user.errors[:email].should include("can't be blank")
}

It would be nice however, if we provide something like this:

@croaky
croaky / new.rb
Created November 9, 2010 18:46 — forked from jferris/new.rb
FactoryGirl.define do
sequence :email do |n|
"user#{n}@example.com"
end
factory :user, :aliases => [:author] do
email
password "test"
end
@croaky
croaky / new.rb
Created November 9, 2010 18:56 — forked from jferris/new.rb
describe Message do
FactoryGirl.create :account, :name => "My Account" do
create :user
create :project do
build :message, :author => :user
end
end
# examples
end
@croaky
croaky / gist:1385953
Created November 22, 2011 15:36 — forked from mperham/gist:1379464
Flexibility without Dependency Injection
class TaxCode
GENERATORS = {
:us => lambda { |id| "US-#{id}" },
:br => lambda { |id| "#{id + 9}-BRA" },
}
def self.generate(code, id)
gen = GENERATORS[code] || raise ArgumentError, "No generator for country #{code}"
gen.call(id)
end
@croaky
croaky / HOW_TO.md
Created March 16, 2012 05:43 — forked from michaeldauria/gist:2048022
Migrate from Copycopter 1.0 (hosted by thoughtbot) to Copycopter 2.0 (open source, deploy your own instance)

Use the latest version of the copycopter_client gem:

gem 'copycopter_client', '2.0.0'

Export your published drafts from copycopter.com:

RAILS_ENV=production bundle exec rake copycopter:export

This will create a config/locales/copycopter.yml file.