What is the difference between these two ways of mocking (with and without the string): mock(''Object'') and mock(Object) ? Scott
On 4/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:> What is the difference between these two ways of mocking (with and > without the string): > > mock(''Object'') > > and > > mock(Object) > > ? > > ScottIIRC, using the #mock method, there is really no difference (are you observing any difference?). Using the Spec::Rails mock_model method, you must use the class instead of a String. There *was* talk at one point of adding a feature that would allow you to run examples w/ a command line switch that would look for all the mocks created w/ mock(Type) and report back if the type didn''t actually support the expected methods. But that''s not present so there''s really no diff now.> _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
What exactly does the mock_model do which is different from the regular mock ? Scott On Apr 20, 2007, at 11:29 AM, David Chelimsky wrote:> On 4/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote: >> What is the difference between these two ways of mocking (with and >> without the string): >> >> mock(''Object'') >> >> and >> >> mock(Object) >> >> ? >> >> Scott > > IIRC, using the #mock method, there is really no difference (are you > observing any difference?). Using the Spec::Rails mock_model method, > you must use the class instead of a String. > > There *was* talk at one point of adding a feature that would allow you > to run examples w/ a command line switch that would look for all the > mocks created w/ mock(Type) and report back if the type didn''t > actually support the expected methods. But that''s not present so > there''s really no diff now. > > >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On 4/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:> > What exactly does the mock_model do which is different from the > regular mock ?It stubs out a bunch of stuff commonly required by rails. Take a look at the code for details - just search for "def mock_model" in the rspec plugin (I''d tell you exactly where to look but it''s moved around a couple of times so it depends on which version you have).> > > Scott > > On Apr 20, 2007, at 11:29 AM, David Chelimsky wrote: > > > On 4/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote: > >> What is the difference between these two ways of mocking (with and > >> without the string): > >> > >> mock(''Object'') > >> > >> and > >> > >> mock(Object) > >> > >> ? > >> > >> Scott > > > > IIRC, using the #mock method, there is really no difference (are you > > observing any difference?). Using the Spec::Rails mock_model method, > > you must use the class instead of a String. > > > > There *was* talk at one point of adding a feature that would allow you > > to run examples w/ a command line switch that would look for all the > > mocks created w/ mock(Type) and report back if the type didn''t > > actually support the expected methods. But that''s not present so > > there''s really no diff now. > > > > > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >
On Apr 20, 2007, at 12:26 PM, David Chelimsky wrote:> On 4/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote: >> >> What exactly does the mock_model do which is different from the >> regular mock ? > > It stubs out a bunch of stuff commonly required by rails. Take a look > at the code for details - just search for "def mock_model" in the > rspec plugin (I''d tell you exactly where to look but it''s moved around > a couple of times so it depends on which version you have).I know I''ve seen it before in the rspec code, so I''ll search for it again. Thanks David, Scott> >> >> >> Scott >> >> On Apr 20, 2007, at 11:29 AM, David Chelimsky wrote: >> >>> On 4/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote: >>>> What is the difference between these two ways of mocking (with and >>>> without the string): >>>> >>>> mock(''Object'') >>>> >>>> and >>>> >>>> mock(Object) >>>> >>>> ? >>>> >>>> Scott >>> >>> IIRC, using the #mock method, there is really no difference (are you >>> observing any difference?). Using the Spec::Rails mock_model method, >>> you must use the class instead of a String. >>> >>> There *was* talk at one point of adding a feature that would >>> allow you >>> to run examples w/ a command line switch that would look for all the >>> mocks created w/ mock(Type) and report back if the type didn''t >>> actually support the expected methods. But that''s not present so >>> there''s really no diff now. >>> >>> >>>> _______________________________________________ >>>> rspec-users mailing list >>>> rspec-users at rubyforge.org >>>> http://rubyforge.org/mailman/listinfo/rspec-users >>>> >>> _______________________________________________ >>> rspec-users mailing list >>> rspec-users at rubyforge.org >>> http://rubyforge.org/mailman/listinfo/rspec-users >> >> _______________________________________________ >> rspec-users mailing list >> rspec-users at rubyforge.org >> http://rubyforge.org/mailman/listinfo/rspec-users >> > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users
On 4/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote:> > On Apr 20, 2007, at 12:26 PM, David Chelimsky wrote: > > > On 4/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote: > >> > >> What exactly does the mock_model do which is different from the > >> regular mock ? > > > > It stubs out a bunch of stuff commonly required by rails. Take a look > > at the code for details - just search for "def mock_model" in the > > rspec plugin (I''d tell you exactly where to look but it''s moved around > > a couple of times so it depends on which version you have). > > I know I''ve seen it before in the rspec code, so I''ll search for it > again.To be clear - it''s in the Spec::Rails code, not rspec core.> > Thanks David, > > Scott > > > > > >> > >> > >> Scott > >> > >> On Apr 20, 2007, at 11:29 AM, David Chelimsky wrote: > >> > >>> On 4/20/07, Scott Taylor <mailing_lists at railsnewbie.com> wrote: > >>>> What is the difference between these two ways of mocking (with and > >>>> without the string): > >>>> > >>>> mock(''Object'') > >>>> > >>>> and > >>>> > >>>> mock(Object) > >>>> > >>>> ? > >>>> > >>>> Scott > >>> > >>> IIRC, using the #mock method, there is really no difference (are you > >>> observing any difference?). Using the Spec::Rails mock_model method, > >>> you must use the class instead of a String. > >>> > >>> There *was* talk at one point of adding a feature that would > >>> allow you > >>> to run examples w/ a command line switch that would look for all the > >>> mocks created w/ mock(Type) and report back if the type didn''t > >>> actually support the expected methods. But that''s not present so > >>> there''s really no diff now. > >>> > >>> > >>>> _______________________________________________ > >>>> rspec-users mailing list > >>>> rspec-users at rubyforge.org > >>>> http://rubyforge.org/mailman/listinfo/rspec-users > >>>> > >>> _______________________________________________ > >>> rspec-users mailing list > >>> rspec-users at rubyforge.org > >>> http://rubyforge.org/mailman/listinfo/rspec-users > >> > >> _______________________________________________ > >> rspec-users mailing list > >> rspec-users at rubyforge.org > >> http://rubyforge.org/mailman/listinfo/rspec-users > >> > > _______________________________________________ > > rspec-users mailing list > > rspec-users at rubyforge.org > > http://rubyforge.org/mailman/listinfo/rspec-users > > _______________________________________________ > rspec-users mailing list > rspec-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/rspec-users >