slagyr / speclj

pronounced "speckle": a TDD/BDD framework for Clojure.
MIT License
459 stars 58 forks source link

Diff for maps #53

Closed edtsech closed 11 years ago

edtsech commented 11 years ago

I've added diffs for map. Not the best solution because we compare maps as well as other data structures twice because we call -coll-difference twice, but it can be improved in future.

Current state:

     Expected contents: {:date "10. 10. 2013 8:01", :type "Vol�n�", :description "d�lka hovoru 0:05", :income false, :absolute-price "1 000"}
                   got: {:date "10. 10. 2013 8:10", :type "Vol�n�", :description "d�lka hovoru 0:05", :income false, :absolute-price "1 000"}
               missing: [[:date "10. 10. 2013 8:01"]]
                 extra: [[:date "10. 10. 2013 8:10"]]

 Expected contents: {:errors ["* callfirewall add/src 777333111 jiz existuje."], :response {:status 200, :body "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<job id=\"5089\">\n  \t<update id=\"1\">\n    \t<timestamp>2013-05-16 10:37:47</timestamp>\n     \t<status>ERROR</status>\n     \t<description>* callfirewall add/src 777333111 jiz existuje.</description>\n   \t</update>\n</job>"}, :parsed-body {:content [{:content [{:content ["2013-05-16 10:37:47"], :attrs nil, :tag :timestamp} {:content ["OK"], :attrs nil, :tag :status} {:content ["* callfirewall add/src 777333111 jiz existuje."], :attrs nil, :tag :description}], :attrs {:id "1"}, :tag :update}], :attrs {:id "5089"}, :tag :job}}
                   got: {:errors ["* callfirewall add/src 777333111 jiz existuje."], :response {:status 200, :body "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<job id=\"5089\">\n  \t<update id=\"1\">\n    \t<timestamp>2013-05-16 10:37:47</timestamp>\n     \t<status>ERROR</status>\n     \t<description>* callfirewall add/src 777333111 jiz existuje.</description>\n   \t</update>\n</job>"}, :parsed-body {:tag :job, :attrs {:id "5089"}, :content [{:tag :update, :attrs {:id "1"}, :content [{:tag :timestamp, :attrs nil, :content ["2013-05-16 10:37:47"]} {:tag :status, :attrs nil, :content ["ERROR"]} {:tag :description, :attrs nil, :content ["* callfirewall add/src 777333111 jiz existuje."]}]}]}}
               missing: [[:parsed-body {:content [{:content [{:content ["2013-05-16 10:37:47"], :attrs nil, :tag :timestamp} {:content ["OK"], :attrs nil, :tag :status} {:content ["* callfirewall add/src 777333111 jiz existuje."], :attrs nil, :tag :description}], :attrs {:id "1"}, :tag :update}], :attrs {:id "5089"}, :tag :job}]]
                 extra: [[:parsed-body {:tag :job, :attrs {:id "5089"}, :content [{:tag :update, :attrs {:id "1"}, :content [{:tag :timestamp, :attrs nil, :content ["2013-05-16 10:37:47"]} {:tag :status, :attrs nil, :content ["ERROR"]} {:tag :description, :attrs nil, :content ["* callfirewall add/src 777333111 jiz existuje."]}]}]}]]

New state

     Expected contents: {:date "10. 10. 2013 8:01", :type "Vol�n�", :description "d�lka hovoru 0:05", :income false, :absolute-price "1 000"}
                   got: {:date "10. 10. 2013 8:10", :type "Vol�n�", :description "d�lka hovoru 0:05", :income false, :absolute-price "1 000"}
               missing: {:date "10. 10. 2013 8:01"}
                 extra: {:date "10. 10. 2013 8:10"}

     Expected contents: {:errors ["* callfirewall add/src 777333111 jiz existuje."], :response {:status 200, :body "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<job id=\"5089\">\n  \t<update id=\"1\">\n    \t<timestamp>2013-05-16 10:37:47</timestamp>\n     \t<status>ERROR</status>\n     \t<description>* callfirewall add/src 777333111 jiz existuje.</description>\n   \t</update>\n</job>"}, :parsed-body {:content [{:content [{:content ["2013-05-16 10:37:47"], :attrs nil, :tag :timestamp} {:content ["OK"], :attrs nil, :tag :status} {:content ["* callfirewall add/src 777333111 jiz existuje."], :attrs nil, :tag :description}], :attrs {:id "1"}, :tag :update}], :attrs {:id "5089"}, :tag :job}}
                   got: {:errors ["* callfirewall add/src 777333111 jiz existuje."], :response {:status 200, :body "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<job id=\"5089\">\n  \t<update id=\"1\">\n    \t<timestamp>2013-05-16 10:37:47</timestamp>\n     \t<status>ERROR</status>\n     \t<description>* callfirewall add/src 777333111 jiz existuje.</description>\n   \t</update>\n</job>"}, :parsed-body {:tag :job, :attrs {:id "5089"}, :content [{:tag :update, :attrs {:id "1"}, :content [{:tag :timestamp, :attrs nil, :content ["2013-05-16 10:37:47"]} {:tag :status, :attrs nil, :content ["ERROR"]} {:tag :description, :attrs nil, :content ["* callfirewall add/src 777333111 jiz existuje."]}]}]}}
               missing: {:parsed-body {:content [{:content [nil {:content ["OK"]}]}]}}
                 extra: {:parsed-body {:content [{:content [nil {:content ["ERROR"]}]}]}}

Thanks!

slagyr commented 11 years ago

Thanks for the pull request! Sorry it took so long to merge.