I would like to ask for Your experience how to handle mocking class method only for one specific test. Scenario is: I have unit test suite and in one of the test I have mocked a class method, and I want this class method to be only mocked in this specific test. But this mock applies to all test files while I run rake test:units. I thought about doing like this with setup and teardown: class SomeTest < ... def setup #here ovveride class method body in runtime end def teardown #and here bring back class method body in runtime end end But I''m not sure if this is the way it should be done ? And the reason why I need to do it this way is because in some particular tests I need to mock the class method and in other i don''t. In my case it is about calls to sandbox. In some tests I check if they are made correctly and in other I test only logic flow and I don''t want to make real calls to sandbox. Thanks for any ideas. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Apr 23, 8:33 am, mariek <marek.byt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> And the reason why I need to do it this way is because in some > particular tests I need to mock the class method and in other i don''t. > In my case it is about calls to sandbox. In some tests I check if they > are made correctly and in other I test only logic flow and I don''t > want to make real calls to sandbox. > > Thanks for any ideas. >use something like mocha, rr or the mocking in rspec ? Fred> -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en.-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Check out flexmock as well http://flexmock.rubyforge.org/ On Fri, Apr 23, 2010 at 11:09 AM, Frederick Cheung <frederick.cheung-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > > On Apr 23, 8:33 am, mariek <marek.byt...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> And the reason why I need to do it this way is because in some >> particular tests I need to mock the class method and in other i don''t. >> In my case it is about calls to sandbox. In some tests I check if they >> are made correctly and in other I test only logic flow and I don''t >> want to make real calls to sandbox. >> >> Thanks for any ideas. >> > > use something like mocha, rr or the mocking in rspec ? > > Fred >> -- >> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. >> To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> For more options, visit this group athttp://groups.google.com/group/rubyonrails-talk?hl=en. > > -- > You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. > For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.