I would like to suggest that a future version of Kerodon have
something like text? but checking for a substring, rather than
equality. I have been running my tests against my real-world
templates, so I get failures for stuff like this:

FAIL in (anyone-can-view-frontpage) (core_test.clj:15)
expected: (text? "Hello World")
  actual: "\n  \n    Discovery Kids Camp Planner\n\n    \n    \n
\n    \n    \n    \n    \n    \n    \n    \n    \n    \n\n    \n    \n
\n    \n      /* these are styles that the code will change on a per
page basis, such as \n      the background-image of the top banner.
This is changed by the code and frontenders\n      should  not touch
this block. */\n    \n\n  \n  \n\n    Hello World\n\n    \n\t\n
\n    \n\n  \n\n\n\n\n"


But "Hello World" is there, so I wish I could make this test work.

I notice you have these macros to do look for the match:


(defmacro validate [comparator generator expected exp-msg]
  `(fn [state# msg#]
     (try (let [value# (~generator state#)]
            (clojure.test/do-report {:actual value#
                                     :type (if (~comparator value#
~expected)
                                             :pass
                                             :fail)
                                     :message msg#
                                     :expected (quote ~exp-msg)}))
          (catch java.lang.Throwable t#
            (clojure.test/do-report {:actual t#
                                     :type :error
                                     :message msg#
                                     :expected (quote ~exp-msg)})))
     state#))

(defmacro text? [expected]
  `(validate =
             #(apply str (enlive/texts (:enlive %)))
             ~expected
             (~'text? ~expected)))


But I think what is needed is a way to define a re-match and pass that
in and have something like re-find pull out a match, if any.

I could possibly write this myself and send you a pull request but I
am relatively new to Clojure and I worry that I will do a bad job of
it.








On Feb 20, 8:58 am, larry google groups <lawrencecloj...@gmail.com>
wrote:
> > It was a bug in kerodon that happens when a ring response has a :body
> > that is a not a string (in this case a lazyseq). Reported and fixed by
> > Travis Vachon athttps://github.com/xeqi/kerodon/pull/6, I just had
> > lost track of making a release for it.
> > Fixed as part of [kerodon "0.1.0"].
>
> Fantastic! All the errors that I was struggling with last night are now
> gone! This is great!
>
>
>
>
>
>
>
> On Tuesday, February 19, 2013 11:52:39 PM UTC-5, Nelson Morris wrote:
>
> > It was a bug in kerodon that happens when a ring response has a :body
> > that is a not a string (in this case a lazyseq). Reported and fixed by
> > Travis Vachon athttps://github.com/xeqi/kerodon/pull/6, I just had
> > lost track of making a release for it.
>
> > Fixed as part of [kerodon "0.1.0"].
>
> > On Tue, Feb 19, 2013 at 4:37 PM, AtKaaZ <atk...@gmail.com <javascript:>>
> > wrote:
> > > oh sorry I meant:
> > > => (doall 1)
> > > IllegalArgumentException Don't know how to create ISeq from:
> > java.lang.Long
> > >     clojure.lang.RT.seqFrom (RT.java:505)
> > >     clojure.lang.RT.seq (RT.java:486)
> > >     clojure.core/seq (core.clj:133)
> > >     clojure.core/dorun (core.clj:2780)
> > >     clojure.core/doall (core.clj:2796)
>
> > > On Tue, Feb 19, 2013 at 11:36 PM, AtKaaZ <atk...@gmail.com <javascript:>>
> > wrote:
>
> > >> => (dorun 1)
> > >> IllegalArgumentException Don't know how to create ISeq from:
> > >> java.lang.Long  clojure.lang.RT.seqFrom (RT.java:505)
> > >> nil
> > >> IllegalArgumentException Don't know how to create ISeq from:
> > >> java.lang.Long
> > >>     clojure.lang.RT.seqFrom (RT.java:505)
> > >>     clojure.lang.RT.seq (RT.java:486)
> > >>     clojure.core/seq (core.clj:133)
> > >>     clojure.core/dorun (core.clj:2780)
> > >>     random.learning.backtick.backtick1/eval2879 (NO_SOURCE_FILE:1)
>
> > >> On Tue, Feb 19, 2013 at 11:30 PM, larry google groups
> > >> <lawrenc...@gmail.com <javascript:>> wrote:
>
> > >>> Hmm, even stranger. If I wrap "app" in doall in an attempt to make the
> > >>> lazyseq error go away, I get:
>
> > >>> ERROR in (anyone-can-view-frontpage) (RT.java:494)
> > >>> Uncaught exception, not in assertion.
> > >>> expected: nil
> > >>>   actual: java.lang.IllegalArgumentException: Don't know how to create
> > >>> ISeq from: ring.middleware.cookies$wrap_cookies$fn__1637
> > >>>  at clojure.lang.RT.seqFrom (RT.java:494)
> > >>>     clojure.lang.RT.seq (RT.java:475)
> > >>>     clojure.core$seq.invoke (core.clj:133)
> > >>>     clojure.core$dorun.invoke (core.clj:2725)
> > >>>     clojure.core$doall.invoke (core.clj:2741)
> > >>>     mpdv_clojure.core_test/fn (core_test.clj:13)
>
> > >>> On Feb 19, 2:24 pm, larry google groups <lawrencecloj...@gmail.com>
> > >>> wrote:
> > >>> > I was trying to follow this video, which adds some nice tests for
> > >>> > Friend:
>
> > >>> >http://www.clojurewebdevelopment.com/videos/friend-interactive-form
>
> > >>> > But Kerodon gives me an error, and points to line 13 of my test
> > code:
>
> > >>> > ERROR in (anyone-can-view-frontpage) (impl.clj:73)
> > >>> > Uncaught exception, not in assertion.
> > >>> > expected: nil
> > >>> >   actual: java.lang.ClassCastException: clojure.lang.LazySeq cannot
> > be
> > >>> > cast to java.lang.String
> > >>> >  at kerodon.impl$include_parse.invoke (impl.clj:73)
> > >>> >     kerodon.core$visit.doInvoke (core.clj:8)
> > >>> >     clojure.lang.RestFn.invoke (RestFn.java:423)
> > >>> >     mpdv_clojure.core_test/fn (core_test.clj:13)
>
> > >>> > But line 13 starts with the first inside line of this function:
>
> > >>> > (deftest anyone-can-view-frontpage
> > >>> >   (-> (session app)
> > >>> >       (visit  "/")
> > >>> >       (has (text? "Hello World"))))
>
> > >>> > And I think my definition of app is fairly straightforward:
>
> > >>> > (defroutes app-routes
> > >>> >   (ANY "/" request (index request))
> > >>> >   (GET "/section/" request (section request))
> > >>> >   (GET "/admin" request (friend/authorize #{::admin} (admin
> > request)))
> > >>> >   (GET "/login" request (login request))
> > >>> >   (friend/logout (GET "/logout" _ (ring.util.response/redirect
> > "/")))
> > >>> >   (GET "/ok" request (ok request))
> > >>> >   (route/resources "/")
> > >>> >   (route/not-found "Page not found"))
>
> > >>> > (def app
> > >>> >   (-> app-routes
> > >>> >       (friend/authenticate
> > >>> >        {:workflows [(workflows/interactive-form)]
> > >>> >         :credential-fn (partial credentials/bcrypt-credential-fn
> > >>> > users)})
> > >>> >       handler/site))
>
> > >>> > Can anyone tell me where I went wrong?
>
> > >>> > Please note, Friend is working great for this app -- it correctly
> > >>> > protects a page until I supply the correct username/password. The
> > >>> > problem I have here is with Kerodon, not Friend.
>
> > >>> --
> > >>> --
> > >>> You received this message because you are subscribed to the Google
> > >>> Groups "Clojure" group.
> > >>> To post to this group, send email to 
> > >>> clo...@googlegroups.com<javascript:>
> > >>> Note that posts from new members are moderated - please be patient
> > with
> > >>> your first post.
> > >>> To unsubscribe from this group, send email to
> > >>> clojure+u...@googlegroups.com <javascript:>
> > >>> For more options, visit this group at
> > >>>http://groups.google.com/group/clojure?hl=en
> > >>> ---
> > >>> You received this message because you are subscribed to the Google
> > Groups
> > >>> "Clojure" group.
> > >>> To unsubscribe from this group and stop receiving emails from it, send
> > an
> > >>> email to clojure+u...@googlegroups.com <javascript:>.
> > >>> For more options, visithttps://groups.google.com/groups/opt_out.
>
> > >> --
> > >> Please correct me if I'm wrong or incomplete,
> > >> even if you think I'll subconsciously hate it.
>
> > > --
> > > Please correct me if I'm wrong or incomplete,
> > > even if you think I'll subconsciously hate it.
>
> > > --
> > > --
> > > You received this message because you are subscribed to the Google
> > > Groups "Clojure" group.
> > > To post to this group, send email to clo...@googlegroups.com<javascript:>
> > > Note that posts from new members are moderated - please be patient with
> > your
> > > first post.
> > > To unsubscribe from this group, send email to
> > > clojure+u...@googlegroups.com <javascript:>
> > > For more options, visit this group at
> > >http://groups.google.com/group/clojure?hl=en
> > > ---
> > > You received this message because you are subscribed to the Google
> > Groups
> > > "Clojure" group.
> > > To unsubscribe from this group and stop receiving emails from it, send
> > an
> > > email to clojure+u...@googlegroups.com <javascript:>.
> > > For more options, visithttps://groups.google.com/groups/opt_out.

-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to