circleci / bond

spying for tests
128 stars 28 forks source link

Better support for stubbing private fns #36

Closed smaant closed 6 years ago

smaant commented 6 years ago

Some people have a problem using bond for private functions because of pretty cryptic syntax, this PR adds a bit better support. Before private fn stubbing/checking looked like:

(deftest foo-is-called
+  (with-stub! [[foo/foo (fn [x] "foo")]]
+    (is (= "foo" (#'foo/foo 1)))
+    (is (= [1] (-> @#'foo/foo bond/calls first :args)))))

Notice the difference in calling private function and checking stub args. Now it'll be possible to have the same (#'foo/foo) syntax for both.

codecov[bot] commented 6 years ago

Codecov Report

Merging #36 into master will decrease coverage by 1.4%. The diff coverage is 75%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #36      +/-   ##
==========================================
- Coverage     100%   98.59%   -1.41%     
==========================================
  Files           1        1              
  Lines          69       71       +2     
  Branches        0        1       +1     
==========================================
+ Hits           69       70       +1     
- Partials        0        1       +1
Impacted Files Coverage Δ
src/bond/james.cljc 98.59% <75%> (-1.41%) :arrow_down:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 6d00f5a...8243081. Read the comment docs.

gordonsyme commented 6 years ago

Neat!

I've added some commits to enable spying private functions and a missing test case, wdyt?

I also threw in a commit for some trivial stuff, we should squash that into your main change before the merge.

smaant commented 6 years ago

Awesome! Thanks for your commits! I somehow was under impression that spying should also work. I'll squash everything and merge.