Comments (7)
@youroff I pushed some examples in my pr: #75 and it works :)
from mock.
Merged #75.
@youroff Did you get it to work as expected?
from mock.
You must mock both - get/1 if you calling it without arguments from code or both get/1 and get/2, if you using both variants of calling, because mocking makes module in background and defines functions which you passed to with_mock and knows nothing about module you are mocking.
In example you define get/2, which creates the following module(I'm simplifying a bit now):
defmodule HigherMath do
get(x, m) ->
:uh
end
end
from mock.
Ok, but how mock definition would look like? Just two entries in a Keyword with the same key? Like this?
[get: fn (x) -> :ok end, get: fn (x, m) -> :ok end]
from mock.
I don't know exactly how to do it using Mock, I personally using :meck directly.
So using multiple calls to :meck.expect you could achieve what you want :)
from mock.
But I think your variant with two entries would work
from mock.
Yup, thanks guys!
from mock.
Related Issues (20)
- defdelegate problem HOT 1
- Feature Request: Capture arguments
- assert_called with pattern matching HOT 10
- Assert called doesn't work on second function call
- Tests sometimes fail with `** (MatchError) no match of right hand side value: false` HOT 4
- Proposal: clearer calls assertions with pattern matching HOT 2
- Enable passing the caller module attributes to with_mocks macro HOT 1
- Proposal: add `assert_not_called` macro HOT 2
- Return different values depending on number of times a function is called HOT 5
- Cannot mock Logger.error/1 HOT 1
- Mocking the same function in 2 separate tests while async: false makes test fail.
- Feature Request: Support per-process mocking HOT 3
- Publish README with Documentation
- Feature request: support for `on_exit` style teardown with `setup_with_mocks`
- Typo in the Mock module. Location: `call_history` doc
- Problem with mock function HOT 1
- No Release to hex.pm since May, 2021 HOT 1
- Problems with Elixir 1.14.5 HOT 1
- Assert called does not assert equality when an argument is a map
- Mock is crashing process in umbella project HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mock.