Skip to content

spec-assertion-thrown? does not evaluate arguments in spec/nilable #103

@lennartbuit

Description

@lennartbuit

Brief

When using spec-assertion-thrown? with a programmatic nilable spec, its spec key is not evaluated.

Repro:

(ns repro
  (:require
   [clojure.spec.alpha :as spec]
   [clojure.test :refer :all]
   [nedap.utils.spec.api :refer [check!]]))

(spec/def ::a int?)

(defn check-nilable [attr value]
  (check! (spec/nilable attr) value))

(deftest my-test
  (is (spec-assertion-thrown? (spec/nilable ::a) (check-nilable ::a "twelve"))))

Expected behavior

Expect a spec assertion to be thrown for (spec/nilable ::a)

Actual behavior

Got a spec assertion thrown for (spec/nilable attr) (note that attr is not evaluated).

Reproduction steps

Run the reproduction case above.

Suspected cause

@thumbnail pointed me to #99, which fixes this evaluation for 'bare' programmatic specs. In this case it is, however, a programmatic spec being wrapped in nilable :).

Screenshot, stacktrace, etc

Environment info

Additional links

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions