On 29 March 2017 at 10:10, Dan Fitzpatrick <dan / eparklabs.com> wrote:

> On Mar 28, 2017, at 5:42 PM, Matthew Kerwin <matthew / kerwin.net.au> wrote:
>
> >
> > Sounds like you've been cargo-culting your tests, instead of just.. you
> know.. writing them. There's no obligation to have any of that sort of
> complexity:
> >
> > https://gist.github.com/phluid61/b3b22ede9f72350d1cb374de1ec2d97b
> >
> > Cheers
> > --
> >   Matthew Kerwin
> >
>
> Thanks!
>
> This is what I was attempting to avoid (http://stackoverflow.com/
> questions/1759021/test-modules-with-testunit#1759140):
>
> class TestClass
>   include MyModule
> end
>
> class TestMyModule < Unit::Test::TestCase
>   def setup
>     @instance = TestClass.new
>   end
>
>   def test_my_func
>     assert_equal(5, @instance.my_func) # test the output value given the
> input params
>   end
> end
>
> According to my searches, that is the popular way to test methods. But
> then again most modules do not extend self.
>
> Dan
>
>
Yeah, if you're testing instance methods defined in a module, rigging up a
dummy class and a dummy instance is definitely the way to go.  (I'm not
going to call it a mock or a stub, because there's a whole world of
terminology arguments to be had there <
https://en.wikipedia.org/wiki/Test_double>.)

Cheers
-- 
  Matthew Kerwin
  http://matthew.kerwin.net.au/
(supressed text/html)
Unsubscribe: <mailto:ruby-talk-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>