Code Monkey home page Code Monkey logo

Comments (7)

spscream avatar spscream commented on August 26, 2024 1

@youroff I pushed some examples in my pr: #75 and it works :)

from mock.

Olshansk avatar Olshansk commented on August 26, 2024 1

Merged #75.

@youroff Did you get it to work as expected?

from mock.

spscream avatar spscream commented on August 26, 2024

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.

youroff avatar youroff commented on August 26, 2024

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.

spscream avatar spscream commented on August 26, 2024

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.

spscream avatar spscream commented on August 26, 2024

But I think your variant with two entries would work

from mock.

youroff avatar youroff commented on August 26, 2024

Yup, thanks guys!

from mock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.