Skip to content

Instantly share code, notes, and snippets.

@lardawge
Created November 17, 2010 20:12
Show Gist options
  • Save lardawge/703988 to your computer and use it in GitHub Desktop.
Save lardawge/703988 to your computer and use it in GitHub Desktop.
Failing specs with rails 3.0.3 commit f1c13b0 example
class Joins < ActiveRecord::Base
belongs_to :parent
belongs_to :child
validates_presence_of :parent_id, :child_id
end
class Parent < ActiveRecord::Base
has_many :joins
has_many :children,
:though => :joins
after_destroy :delete_associated
private
def delete_associated
joins.each do |join|
if join.child
join.child.destroy
end
join.destroy
end
end
end
context '.destroy' do
it 'deletes its joins and its children' do
parent = Factory :parent
2.times do
parent.joins.children << Factory(:children)
end
parent.reload
children_ids = editorial.joins_ids.collect(&:id)
parent.destroy
expect { parent.reload }.to raise_error(ActiveRecord::RecordNotFound) #passes
parent.joins.collect(&:id).each do |each|
expect { Joins.find each }.to raise_error(ActiveRecord::RecordNotFound) #fail
end
parent.children.collect(&:id).each do |each|
expect { Child.find each }.to raise_error(ActiveRecord::RecordNotFound) #fail
end
end
end
Failure/Error: expect { Joins.find each }.to raise_error(ActiveRecord::RecordNotFound)
expected ActiveRecord::RecordNotFound but nothing was raised
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-expectations-2.1.0/lib/rspec/expectations/fail_with.rb:29:in `fail_with'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-expectations-2.1.0/lib/rspec/expectations/handler.rb:21:in `handle_matcher'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-expectations-2.1.0/lib/rspec/expectations/extensions/kernel.rb:27:in `should'
# ./spec/models/model_spec.rb:756:in `block (5 levels) in <top (required)>'
# ./spec/models/model_spec.rb:755:in `each'
# ./spec/models/model_spec.rb:755:in `block (4 levels) in <top (required)>'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:42:in `instance_eval'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:42:in `block (2 levels) in run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:81:in `call'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:81:in `with_around_hooks'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:39:in `block in run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:75:in `call'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:75:in `block in with_pending_capture'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:74:in `catch'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:74:in `with_pending_capture'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example.rb:38:in `run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:261:in `block in run_examples'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:257:in `map'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:257:in `run_examples'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:231:in `run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:232:in `block in run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:232:in `map'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:232:in `run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:232:in `block in run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:232:in `map'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/example_group.rb:232:in `run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:27:in `block (2 levels) in run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:27:in `map'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:27:in `block in run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/reporter.rb:12:in `report'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/command_line.rb:24:in `run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:55:in `run_in_process'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:46:in `run'
# /Users/lar/.rvm/gems/ruby-1.9.2-p0@fail_rails3/gems/rspec-core-2.1.0/lib/rspec/core/runner.rb:10:in `block in autorun'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment