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

Prerequisite with dynamic arguments #467

Open
viebel opened this issue Apr 26, 2020 · 2 comments
Open

Prerequisite with dynamic arguments #467

viebel opened this issue Apr 26, 2020 · 2 comments

Comments

@viebel
Copy link

viebel commented Apr 26, 2020

I'd like to be able to define prerequisite with a dynamic argument and access this argument in the mocking value. For instance, I'd like to be able to write something like this:

(defn bar [x])
(defn foo [x]
  (bar x))

(fact
 (foo 2) => 2
 (provided (bar anything) => anything))

The problem in this code is that the anything after the arrow doesn't have the value of the anything before the arrow.

Does my request make sense?

@viebel
Copy link
Author

viebel commented Oct 1, 2020

Could anyone help on this one?

@philomates
Copy link
Collaborator

metaconstants might do something similar.

like

(defn bar [x])
(defn foo [x]
  (bar x))

(fact
 (foo 2) => ..some-arg..
 (provided (bar ..some-arg..) => ..some-arg..))

Are you somehow trying to express strong constraints between what flows in and out of subcalls? I generally try to avoid such tests because it doesn't test results but rather implementation, so when you refactor your implementation you have to update all your tests.

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

No branches or pull requests

2 participants