Thanks to this week's contributors to thoughtbot projects.
Test your Ruby gem against different versions of its dependencies.
| class Customer | |
| def initialize(attrs = {}) | |
| @id = attrs[:id] | |
| @country = attrs[:country] | |
| end | |
| def tax_code | |
| TaxCodes[@country].call(@id) | |
| rescue | |
| raise "Tax codes for #{@country} not supported" |
Thanks to this week's contributors to thoughtbot projects.
Test your Ruby gem against different versions of its dependencies.
| FIREFOX_FIXTURES = [ | |
| { | |
| browser: 'Firefox', | |
| gecko_version: '20101203', | |
| os: 'Intel Mac OS X 10.6', | |
| platform: 'Macintosh', | |
| raw: 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.6; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13', | |
| version: '3.6.13' | |
| }, | |
| { |
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.
| 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 |
| describe Message do | |
| FactoryGirl.create :account, :name => "My Account" do | |
| create :user | |
| create :project do | |
| build :message, :author => :user | |
| end | |
| end | |
| # examples | |
| end |
| FactoryGirl.define do | |
| sequence :email do |n| | |
| "user#{n}@example.com" | |
| end | |
| factory :user, :aliases => [:author] do | |
| password "test" | |
| end |
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:
| rack_hoptoad |