practicalli / practicalli/clojure

Spec - understanding Explain output

Open
#203 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Makefile
Stars
117
Forks
36
PR merge metrics
No merged PRs in 30d

Description

I want to learn how to read the output of spec/explain-data. I'm sure this is full of useful information but I couldn't make heads or tails of it... it's from looking at cider inspect last result

Class: clojure.lang.PersistentArrayMap
Contents: 
  :clojure.spec.alpha/problems = ( { :path [], :pred clojure.core/map?, :val [ :com.logicgate.helpER.source/indent 4 ], :via [ :com.logicgate.helpER.specs/scenarios :com.logicgate.helpER.specs/scenario :com.logicgate.helpER.specs/specification ], :in [ 0 0 ] } { :path [], :pred clojure.core/map?, :val [ :com.logicgate.helpER.source/tag "describe" ], :via [ :com.logicgate.helpER.specs/scenarios :com.logicgate.helpER.specs/scenario :com.logicgate.helpER.specs/specification ], :in [ 0 1 ] } { :path [], :pred clojure.core/map?, :val [ :com.logicgate.helpER.source/message "Adding a user in an SSO environment" ], :via [ :com.logicgate.helpER.specs/scenarios :com.logicgate.helpER.specs/scenario :com.logicgate.helpER.specs/specification ], :in [ 0 2 ] } { :path [], :pred clojure.core/map?, :val [ :com.logicgate.helpER.source/level 0 ], :via [ :com.logicgate.helpER.specs/scenarios :com.logicgate.helpER.specs/scenario :com.logicgate.helpER.specs/specification ], :in [ 0 3 ] } { :path [], :pred clojure.core/map?, :val [ :com.logicgate.helpER.source/indent 6 ], :via [ :com.logicgate.helpER.specs/scenarios :com.logicgate.helpER.specs/scenario :com.logicgate.helpER.specs/specification ], :in [ 1 0 ] } ... )
  :clojure.spec.alpha/spec = :com.logicgate.helpER.specs/scenarios
  :clojure.spec.alpha/value = ( { :com.logicgate.helpER.source/indent 4, :com.logicgate.helpER.source/tag "describe", :com.logicgate.helpER.source/message "Adding a user in an SSO environment", :com.logicgate.helpER.source/level 0 } { :com.logicgate.helpER.source/indent 6, :com.logicgate.helpER.source/tag "describe", :com.logicgate.helpER.source/message "Navigate to Admin -> Users", :com.logicgate.helpER.source/level 1 } { :com.logicgate.helpER.source/indent 8, :com.logicgate.helpER.source/tag "describe", :com.logicgate.helpER.source/message "Click on \"+ New User\" button", :com.logicgate.helpER.source/level 2 } { :com.logicgate.helpER.source/indent 10, :com.logicgate.helpER.source/tag "describe", :com.logicgate.helpER.source/message "the \"Send Welcome Email\" checkbox input", :com.logicgate.helpER.source/level 3 } { :com.logicgate.helpER.source/indent 12, :com.logicgate.helpER.source/tag "it", :com.logicgate.helpER.source/message "is displayed", :com.logicgate.helpER.source/level 4 } ... )

"expected map, found ..." for each of those values.
The :pred says what test failed, :val tells you what it tried to test, and :via gives the "call tree" through the specs.

:com.logicgate.helpER.specs/scenarios :com.logicgate.helpER.specs/scenario :com.logicgate.helpER.specs/specification

so scenarios is (I assume) a collection of scenario and that has a specification which I expect is s/keys (most likely, given the map? predicate failure).
and your overall value was a sequence of hash maps -- scenarios, I assume, so the problem is that a value like

{ :com.logicgate.helpER.source/indent 4, :com.logicgate.helpER.source/tag "describe", :com.logicgate.helpER.source/message "Adding a user in an SSO environment", :com.logicgate.helpER.source/level 0 }

fails the scenario spec because the :in suggest collection navigation

(`0`th element, then `0`th element of that, which is a MapEntry -- the [ :com.logicgate.helpER.source/indent 4 ] pair -- and it is expecting an s/keys so it should be a hash map.

So I think the level of nesting is off -- either in the Spec or in the data structure.
seancorfield  16 hours ago

:via gives a key path and :in gives a numeric index path, then?
:in matches get-in so it would be a combination of keys and index values
:via is the path through the chain of Specs, rather than through the values (which is :in)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the spec/explain-data output shown from cider inspect last result, focusing on :pred, :val, :via, and :in and how they relate to the sample nested values. Document what each field means and clarify whether the reported nesting interpretation is correct, so a reader can understand and diagnose similar output.

Written by the indexing model from the issue text.

Assessment

Tech stack
clojure
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.