Skip to content

@stephancom /Gemfile
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Example of problem with rspec 2 + rails 3.1 + ruby 1.9.2 + factory_girl
gem 'rails', '3.1.0.rc4'
group :development, :test do
gem 'rspec-rails', '~> 2.6.1'
end
group :test do
gem 'factory_girl_rails'
gem 'rspec'
end
factory_girl (2.0.1)
factory_girl_rails (1.1.0)
factory_girl (~> 2.0.0)
railties (>= 3.0.0)
...
rspec (2.6.0)
rspec-core (~> 2.6.0)
rspec-expectations (~> 2.6.0)
rspec-mocks (~> 2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
diff-lcs (~> 1.1.2)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
actionpack (~> 3.0)
activesupport (~> 3.0)
railties (~> 3.0)
rspec (~> 2.6.0)
class OtherModel < ActiveRecord::Base
after_create :some_slow_method, :on => :create
private
def some_slow_method
# do something that takes a while
end
end
require 'spec_helper'
describe OtherModel do
before(:each) do
@other_model = Factory.create :other_model
end
it "should work right" do
@other_model.true_thing.should be_true
end
end
stephan$ ruby -v ; rails -v ; rspec -v
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.7.0]
Rails 3.1.0.rc4
2.6.4
stephan$ rspec spec/models/some_model_spec.rb spec/models/other_model_spec.rb
.F
Failures:
1) Comment
Failure/Error: @other_model = Factory(:other_model)
NameError:
undefined local variable or method `some_slow_method' for #<OtherModel:0x00000106ff72e0>
# ./spec/models/comment_spec.rb:5:in `block (2 levels) in <top (required)>'
Finished in xx.xx seconds
2 examples, 1 failure
stephan$ rspec spec/models/other_model_spec.rb spec/models/some_model_spec.rb
..
Finished in xx.xx seconds
2 examples, 0 failures
require 'spec_helper'
describe SomeModel do
before(:each) do
OtherModel.any_instance.stub(:some_slow_method)
@some_model = Factory.create :some_model
end
it "should handle some_model normally" do
@some_model.true_thing.should be_true
end
end
@stephancom
Owner

LOTS of detail has been omitted here. I've experimented with lots of different settings in my gemfile, including working straight from master. The terminal output is faked, based on my real output, to illustrate the issue.

seems like it may be related to rspec/rspec-mocks#54

also tried unstubbing manually in an after(:all) or after(:each) block, wonder if it's related to this as well: rspec/rspec-mocks#68

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.