* Hamcrest-style parameter matchers * Values returned and exceptions raised on consecutive invocations * Yields on consecutive invocations * Multiple yields on single invocation * Invocation dispatch fixed * Deprecated returning result of a Proc -- James. http://blog.floehopper.org
You''re awesome. On 6/8/07, James Mead <jamesmead44 at gmail.com> wrote:> * Hamcrest-style parameter matchers > * Values returned and exceptions raised on consecutive invocations > * Yields on consecutive invocations > * Multiple yields on single invocation > * Invocation dispatch fixed > * Deprecated returning result of a Proc > -- > James. > http://blog.floehopper.org > _______________________________________________ > mocha-developer mailing list > mocha-developer at rubyforge.org > http://rubyforge.org/mailman/listinfo/mocha-developer >-- Kevin Clark http://glu.ttono.us
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? Thanks
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. -- James. http://blog.floehopper.org
I wound up using:
class Module
def redefine_const(name, value)
__send__(:remove_const, name) if const_defined?(name)
const_set(name, value)
end
end
The changing the constant on Object:
Object.redefine_const(:RAILS_ENV, ''production'')
This fights with Mocha, but accomplishes my goal.
Thanks
On Jul 23, 2007, at 1:21 AM, James Mead wrote:
> 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.
>
> --
> James.
> http://blog.floehopper.org
> _______________________________________________
> mocha-developer mailing list
> mocha-developer at rubyforge.org
> http://rubyforge.org/mailman/listinfo/mocha-developer