[rspec-users] Can I construct the controller myself in a controller spec?
zach.dennis at gmail.com
Fri Mar 6 11:24:35 EST 2009
On Fri, Mar 6, 2009 at 3:05 AM, Matt Wynne <matt at mattwynne.net> wrote:
> On 5 Mar 2009, at 15:24, Ben Mabey wrote:
>> David Chelimsky wrote:
>>> On Thu, Mar 5, 2009 at 3:31 AM, Matt Wynne <matt at mattwynne.net> wrote:
>>> Maybe we should make this easier by providing some facility in the
>>> mock framework to express the following in one statement:
>>> @authenticator = stub('authenticator')
>>> Sure, you could make that a one liner:
>>> Authenticator.stub!(:new).and_return(@authenticator =
>>> But I mean something like:
>>> @authenticator = Authenticator.stub!
>>> I don't think *that* is the answer - but something that concise would be
>> I like the conciseness, but it isn't very clear what it is doing IMO.
>> Perhaps something a little more intention-revealing like:
>> @authenticator = Authenticator.stub_new!
> I think I must mostly use constructor injection, as I don't really seem to
> have a pattern for this, but if I did I guess it would be something like
> extend StubbingHelpers
> describe "blah"
> before(:each) do
> @authenticator = mock_new_authenticator( :foo => bar )
> which is implemented like
> def stub_new_authenticator( *args )
> result = mock(Authenticator, *args)
> I guess having something like that would be nice.
This is how I do it,
> Matt Wynne
> rspec-users mailing list
> rspec-users at rubyforge.org
More information about the rspec-users