sproutapp / pavlov

A BDD framework for your Elixir projects
MIT License
129 stars 7 forks source link

Readme: include example of `passthrough` option for mocking. #24

Closed mattfreer closed 9 years ago

mattfreer commented 9 years ago

When mocking a common requirement is for the mock to retain all other functions in the original module. The README has been updated to include information and an example of how this can be achieved.

inf0rmer commented 9 years ago

Thanks for this! Meck options are in fact provided by default but I had forgotten to state it in the documentation. Support for :passthrough is really important though, maybe it would be cool to add a spec that formalises the behaviour. What do you think?

mattfreer commented 9 years ago

From what I can see the only Meck option that is passed through by default is :no_link. So you do need to manually pass the :passthrough option from your tests if you want to retain all other functions of the module in the mock. I'm happy to add a spec that demonstrates this if you like?

inf0rmer commented 9 years ago

Oh, yeah, I wasn't saying that you didn't have to pass it in, I was just saying it would be great to have a test that shows that passing :passthrough indeed makes retains all other original functions. The spec is just a way to formalise the contract so that future changes to the code don't break this behaviour.

mattfreer commented 9 years ago

Ok cool, yeah totally agree a test is necessary! I'll update the pull request tonight.

inf0rmer commented 9 years ago

Thanks a lot!

mattfreer commented 9 years ago

@inf0rmer I've added some tests to formalise the behaviour, and updated the commit message.

inf0rmer commented 9 years ago

Fantastic, this looks great! Thanks a lot.