Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Docs around mocking based on parts of the input #123

Merged
merged 3 commits into from
Sep 18, 2020

Conversation

mrjoelkemp
Copy link
Contributor

I had the very case that I included as a bullet point in the docs. I didn't see an obvious way to do it with Mock because the examples were assuming you wanted to mock based on the exact input value. I wanted to mock based on parts of the input value. I figured out how to do it with Mock and thought it would be helpful for others to have explicit docs around this.

Happy to change any of the language. Thanks for the great library.

@coveralls
Copy link

coveralls commented Sep 17, 2020

Coverage Status

Coverage remained the same at 100.0% when pulling 5809dba on mrjoelkemp:patch-1 into 0e07a6e on jjh42:master.

README.md Outdated
test "mock functions with multiple returns" do
with_mock(Map, [
get: fn
(%{}, url) ->
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of creating a whole different section for this, maybe simply updat ethe documentation above to be

     get: fn
        (%{}, "http://example.com") ->
        (%{}, "http://example.org") ->
        (%{}, url) -> foo(url)
def foo(url) do
   cond do
   end
end

Let me know what you think!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks for the suggestion.

@Olshansk Olshansk merged commit ad69c01 into jjh42:master Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants