Skip to content

Instantly share code, notes, and snippets.

View dchelimsky's full-sized avatar

David Chelimsky dchelimsky

  • Retired
  • Chicago, IL, USA
View GitHub Profile
config.generators do |g|
g.orm :datamapper do |dm|
dm.timestamps = true
end
g.test_framework :rspec do |r|
r.fixtures = true
r.skip_views_specs = true
r.skip_routes_specs = false
end
[david: third_rails (exp)]$ cd vendor/rails/railties/
[david: railties (925c910...)]$ rake
(in /Users/david/projects/ruby/third_rails/vendor/rails/railties)
Loaded suite test/backtrace_cleaner_test
Started
.....
Finished in 0.002655 seconds.
5 tests, 5 assertions, 0 failures, 0 errors
Loaded suite test/boot_test
1)
Test::Unit::AssertionFailedError in 'A controller example running in integration mode support custom routes'
The generated path <"/custom_route_spec/custom_route"> did not match <"/custom_route">
If you're expecting this failure, we suggest {:=>""}.should_not be_routable
./spec/spec/rails/example/shared_routing_example_group_examples.rb:7:
2)
Test::Unit::AssertionFailedError in 'A controller example running in integration mode recognize routes with methods besides :get'
The generated path <"/rspec_on_rails_specs/update/37"> did not match <"/rspec_on_rails_specs/37">
If you're expecting this failure, we suggest {:put=>"/rspec_on_rails_specs/37"}.should_not be_routable
class Thing
def self.find_something(inputs)
# .. do stuff here
end
def self.add_something(inputs)
# .. do stuff here
end
def self.find_or_add_something(inputs)
Scenario "has three steps" do
Given "one" do
end
When "two" do
end
Then "three" do
end
class Game
attr_reader :teams
def initialize
@teams = Array.new
end
def started?
false
# how do I test this elegantly?
class Request < ActiveRecord::Base
named_scope :active, :conditions => {:status => 'active'}
named_scope :incomplete, :conditions => {:completed_at => nil}
named_scope :deliquent, lambda { {:conditions => 10.days.ago} }
def self.do_stuff_with_incomplete_requests
incomplete_requests = Request.active.incomplete.deliquent(:include => {:user})
incomplete_requests.each do |request|
# all of these variations will pass the accompanying spec using stubble
class ThingsController
def create
@thing = Thing.new(params[:thing])
if @thing.save
render :action => 'index'
else
render :action => 'new'
end
def summer_monthly_usage
@summer_monthly_usage ||= rates.summer_months_nbr.inject(0) { |sum, m| sum + monthly_usage[m - 1] }
end
module ResultCaching
def with_result_caching
begin
@methods_to_cache = []
@caching = true
yield
@caching = false
@methods_to_cache.each do |name|
alias_method "cached_#{name}", name
class_eval <<-EOF