Hi all, I'm having a problem where stubbed static methods aren't properly becoming "unstubbed". I have tried manually unstubbing them, but it still doesn't work.
Spec is as follows: it "creates user accounts for unknown users" do Notification.stub(:deliver_routed) User.should_receive(:create).with({:email => "sa...@etestflight.com"}) User.should_receive(:create).with({:email => "j...@etestflight.com"}) User.stub!(:find_by_email).with("sa...@etestflight.com") { nil } User.stub!(:find_by_email).with("j...@etestflight.com") { nil } User.stub!(:find_by_email).with("b...@etestflight.com") { User.new } begin post :route, :id => "37", :email_addresses => "sa...@etestflight.com, j...@etestflight.com, b...@etestflight.com" ensure User.unstub! :find_by_email #User.unstub! :method_missing User.rspec_reset end end It will pass, but then another spec fails with: "undefined method `find_by_email' for Object:Class". The other spec passes when I create a database User and rely on the real definition of User.find_by_email *(defined by method_missing in MongoMapper's Document module)* in this spec instead of stubbing out the calls to find_by_email. As you can see, I tried calling "unstub!" on find_by_email, and calling rspec_reset, and it doesn't make any difference (other spec still fails). I even tried un-stubbing method_missing (since that's what defines the real find_by_email) and it complains that that was never stubbed. I am running Rails 3 beta 4 with RSpec and rspec-rails beta 13 (tried pointing Gemfile to the GIT repository and did a 'bundle install', but it still installed beta 13 instead of 15 for some reason). Here is a list of the gems I have installed (via bundle show) Gems included by the bundle: * abstract (1.0.0) * actionmailer (3.0.0.beta4) * actionpack (3.0.0.beta4) * activemodel (3.0.0.beta4) * activerecord (3.0.0.beta4) * activeresource (3.0.0.beta4) * activesupport (3.0.0.beta4) * arel (0.4.0) * bcrypt-ruby (2.1.2) * bson (1.0.3) * bson_ext (1.0.1) * builder (2.1.2) * bundler (1.0.0.beta.2) * capistrano (2.5.19) * capybara (0.3.8 35e81a4) * cucumber (0.8.3) * cucumber-rails (0.3.2 b75110d) * culerity (0.2.10) * database_cleaner (0.5.2 7ea99d7) * devise (1.1.rc1 88ab2fe) * diff-lcs (1.1.2) * erubis (2.6.6) * factory_girl (1.3.0) * factory_girl_rails (1.0) * faker (0.3.1) * ffi (0.6.3) * gherkin (2.0.2) * highline (1.5.2) * i18n (0.4.1) * jnunemaker-validatable (1.8.4) * joint (0.3.2 11a094d) * json_pure (1.4.3) * mail (2.2.5) * mime-types (1.16) * mongo (1.0.3) * mongo_mapper (0.8.2) * net-scp (1.0.2) * net-sftp (2.0.4) * net-ssh (2.0.23) * net-ssh-gateway (1.0.1) * nokogiri (1.4.2.1) * plucky (0.3.2) * polyglot (0.3.1) * rack (1.2.1) * rack-test (0.5.4) * rails (3.0.0.beta4 f8720a0) * railties (3.0.0.beta4) * rake (0.8.7) * rspec (2.0.0.beta.13) * rspec-core (2.0.0.beta.13) * rspec-expectations (2.0.0.beta.13) * rspec-mocks (2.0.0.beta.13) * rspec-rails (2.0.0.beta.13) * selenium-webdriver (0.0.24) * term-ansicolor (1.0.5) * thor (0.13.7) * treetop (1.4.8) * trollop (1.16.2) * tzinfo (0.3.22) * wand (0.2.1) * warden (0.10.7) * webrat (0.7.1) Thank you! Pat
_______________________________________________ rspec-users mailing list rspec-users@rubyforge.org http://rubyforge.org/mailman/listinfo/rspec-users