[rspec-users] before(:all) to set up mocks and stubs
caifara.subscribe at gmail.com
Thu Jul 15 04:02:30 EDT 2010
Thanks for your answers. I'll use a fixture replacement to set up the environment.
I know that this (using before(:all) to setup a state) is not a best practice. In this case however, I would consider my approach to be acceptable as the pdf takes a long time to generate. All tests run on the same pdf so generating it 30 times would be a waste of time and effort.
Using mocks and stubs made the generating part even more efficient. Making real objects will do the job just a tiny bit slower. I can live with that. Thanks again.
Op 14-jul-2010, om 00:19 heeft David Chelimsky het volgende geschreven:
> On Jul 13, 2010, at 7:25 AM, Ivo Dancet wrote:
>> I'm upgrading an application to rspec2/rails3. A certain suite of tests, that generates a pdf document, uses a before(:all) filter to set the environment using mocks and stubs. Then the pdf gets generated and after that all the tests run on that same pdf document. In rspec2 it seems like I can only use mocks and stubs in in before(:each) filters (thus not in before(:all) filters). Has this been changed, or is this supposed to work (I may be doing something wrong)?
> This should never have worked. Mocks and stubs are cleared out after each example, which means that even if you set them up before(:all), they'll only be set for the first example that runs, after which they go away.
> It sounds like you were unknowingly exploiting an unintentional feature.
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users