[mocha-developer] Stubbing Constants

James Mead jamesmead44 at gmail.com
Mon Jul 23 04:21:16 EDT 2007

On 23/07/07, s.ross <cwdinfo at gmail.com> wrote:
> This may sound odd, but here's the scenario: My Rails app behaves a
> bit differently in development versus production mode. Because Ruby
> won't let me redefine constants like RAILS_ENV I thought, hmmmmmmmm,
> maybe I can just stub it and then write tests that were mode specific.
> Is this something that can be done with Mocha?

No. Not currently.

I suggest you use Module#const_set for your tests and make sure you reset at
the end of the test OR setup a new environment which mirrors your
production.rb file in which you can run tests.


More information about the mocha-developer mailing list