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

Consider using :mox instead of or along with :meck #254

Open
antonmi opened this issue Jan 11, 2018 · 3 comments
Open

Consider using :mox instead of or along with :meck #254

antonmi opened this issue Jan 11, 2018 · 3 comments

Comments

@antonmi
Copy link
Owner

antonmi commented Jan 11, 2018

No description provided.

@danielfoxp2
Copy link

Hey, I don't have any suggestions about this enhancement. I am here just to thank you for this great work that is ESpec. ExUnit is very powerful and works very good. But I love the RSpec DSL and the ESpec is almost the same. So, for you @antonmi and every other person who put the effort to doing this happens I leave here my deepest appreciation and respect. (I was not search you on twitter to say this because I am currently log out there and I am lazy =p)

I just finish the instalation on my environment (which is not a simple environ...) and everything just worked... no headaches.

Thanks again. Hope you the best.

@antonmi
Copy link
Owner Author

antonmi commented Jan 25, 2018

Thanks, Daniel!
I’m very appreciated it!

@leifg
Copy link

leifg commented Mar 16, 2018

I think the suggestion is great. Espec already works with mox but you need to write some boilerplate code and there is possible namespace collision.

import Mox
# ...
it "passes"
  defmock(MyMock, for: MyImpl)
  expect(MyMock, :call, fn -> :ok end) # expect from Mox
  MyMock.call()
  verify!(OptimizationJobMock)
end

The verify! part is not necessary in ExUnit as you can just use a setup function to hook in verify_on_exit!. But this will result in an error in espec:

** (ArgumentError) on_exit/2 callback can only be invoked from the test process
      lib/ex_unit/callbacks.ex:287: ExUnit.Callbacks.on_exit/2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants