Read more

Stubbed class methods in RSpec 1 remain stubbed in other examples

Henning Koch
June 12, 2011Software engineer at makandra GmbH

I encountered a bug in RSpec 1.x where stubbed class methods ("static methods") would not be unstubbed before the next example, causing it to fail. This behavior can come and go as you edit your specs, since this can change the order in which RSpec evaluates your .rb files.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

I was not able to find a fix for this behavior. Calling #rspec_reset und #unstub!(:method) on the class after the example did not help. I know for sure that stubbing static methods has not been a problem in many other projects. I encountered the bug while working on Cucumber Factory Show archive.org snapshot .

This might be fixed Show archive.org snapshot in RSpec 2.

Posted by Henning Koch to makandra dev (2011-06-12 14:17)