-
Notifications
You must be signed in to change notification settings - Fork 76
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
Use $callers to use expectations made in the calling process #53
Conversation
Added to the section of the docs on explicit allowances
Fix travis.yml config to run multiple checks (and remove ignored versions)
1. Let’s do a version check that sets the tag
2. No need
3. I think only there but that’s a good point. It should be documented
elsewhere.
…--
*José Valim*
www.plataformatec.com.br
Skype: jv.ptec
Founder and Director of R&D
|
Okay, updated with a version check to set the tags to exclude. |
lib/mox.ex
Outdated
defp caller_pid do | ||
case Process.get(:"$callers") do | ||
nil -> self() | ||
pids when is_list(pids) -> List.last(pids) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should actually pass a list to the server and start looking up from head to tail. :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay makes sense, I think we can treat self()
as the first in the list of $callers
and pass that whole list to the server. Then on the server we can check for any allowances set in the list of the pid's, falling back to the last entry in the passed in callers
. I'll work on that tonight/this weekend.
test/mox_test.exs
Outdated
@@ -495,7 +540,7 @@ defmodule MoxTest do | |||
|
|||
{:ok, child_pid} = | |||
Task.start_link(fn -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of using assert_default_raise
, we should rather change to a spawn_link
or call Process.delete(:"$callers")
.
Perfect. Although I think we should get the first entry (self()) in case of
no matches (the current behavior).
--
*José Valimwww.plataformatec.com.br
<http://www.plataformatec.com.br/>Founder and Director of R&D*
|
I still need to fix up the But isn't defaulting to the last caller (which will be the test process in these cases) cleaner?
|
I don't think it matters in the current code because the only scenario where it will use the default is when we don't have any allowances or expectations and that means both first or last will fail anyway? |
Also condense check and add comments
❤️ 💚 💙 💛 💜 |
Awesome, thanks! |
My first implementation passed the result of
Process.get(:"$callers")
in to the server for processing but it felt cleaner to do that call inMox
itself.Questions:
$callers
set?assert_default_raise/2
System.version/0
$callers
documented anywhere besides the Elixir 1.8 release notes?