Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-03 Thread J. B. Rainsberger
On Tue, Feb 2, 2010 at 19:00, Frank Lakatos m...@franklakatos.com wrote: Hi guys, been following for about 3 weeks, first question - This might help a little: http://bit.ly/ONpXE To bring things back to Rails, I use mock_model whenever I want to design controller behavior without relying on

Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-03 Thread Matt Wynne
On 3 Feb 2010, at 11:35, J. B. Rainsberger wrote: I find this rule of thumb helpful: stub unless you're certain to want to verify this time that the client invoke the server correctly, and never, never mock multiple methods at once. Right, because the mock (should_receive) is an assertion,

Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-03 Thread David Chelimsky
On Wed, Feb 3, 2010 at 8:18 AM, Matt Wynne m...@mattwynne.net wrote: On 3 Feb 2010, at 11:35, J. B. Rainsberger wrote: I find this rule of thumb helpful: stub unless you're certain to want to verify this time that the client invoke the server correctly, and never, never mock multiple methods

Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-03 Thread me
Ok, so these ideas seem kind of natural to me, which is nice: mock_models being used to mock non-tested models stub for queries and/or well-tested methods, should_receives for commands While reading over Dave Astlels, I kind of got concerned because of something he states that I feel I'm

Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-03 Thread David Chelimsky
On Wed, Feb 3, 2010 at 8:52 AM, m...@franklakatos.com wrote: Ok, so these ideas seem kind of natural to me, which is nice: mock_models being used to mock non-tested models stub for queries and/or well-tested methods, should_receives for commands While reading over Dave Astlels, I kind of

Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-03 Thread me
To say thank you for all your constuctive feedback would not be enough; all these insights are really helping me to get the provebial it. Dave, I completely agree that the mock_model(ActiveRecord) was bizzare, but my specs kept failing because @projects was to receive .build, and it

Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-03 Thread Nicolás Sanguinetti
On Wed, Feb 3, 2010 at 2:07 PM, m...@franklakatos.com wrote: I absolutely love the idea of encapsulated the daisy chained calls (c_u.comp.project) into a controller methods so all i gotta do is stub that out. Oooh, I hate that one :) You're adding lots of small methods that actually don't

Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-03 Thread J. B. Rainsberger
2010/2/3 Nicolás Sanguinetti godf...@gmail.com: On Wed, Feb 3, 2010 at 2:07 PM,  m...@franklakatos.com wrote: I absolutely love the idea of encapsulated the daisy chained calls (c_u.comp.project) into a controller methods so all i gotta do is stub that out. Oooh, I hate that one :) You're

[rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-02 Thread Frank Lakatos
Hi guys, been following for about 3 weeks, first question - I've been spending the last couple of months learning RSpec and Cucumber and I'm just finally starting to see the big picture, at least I think I am. But I've got some questions I was hoping you guys can clear up. I'm sure this

Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-02 Thread Andrei Erdoss
Hello Frank, From my understanding these are the roles of should_receive and stub. should_receive checks to make sure that a method or a property is called. To this you can specify the arguments that it gets called (.with()), what it returns (.and_return) and how many times this happens (.once,

Re: [rspec-users] When to use Factories, Mock Models, Mocks Stubs

2010-02-02 Thread Adam Sroka
On Tue, Feb 2, 2010 at 9:53 PM, Andrei Erdoss erd...@gmail.com wrote: Hello Frank, From my understanding these are the roles of should_receive and stub. should_receive checks to make sure that a method or a property is called. To this you can specify the arguments that it gets called