     :color "color"
     :components component-config}])
 
+(defmacro with-fake-resource [url resp-func & body]
+  `(fake/with-fake-routes-in-isolation {~url ~resp-func} ~@body))
+
 (defn- json-response [body]
   (fn [_]
     {:status 200

                    :components
                    (map :color))))))
    (testing "handles name"
      (fake/with-fake-routes-in-isolation {"http://the_host/with_components.json" (json-response {:color "green"
                                                                                                  :components [{:status "green"
                                                                                                                :description "child 1"}]})}
        (is (= [{:color :green :name "child 1" :message nil}]
               (:components (sut/with-status a-host (a-url-config-with-components "http://the_host/with_components.json"
                                                                                  {:json-path "$.components[*]"
                                                                                   :color "status"
                                                                                   :name "description"})))))))
    (testing "handles message"
      (fake/with-fake-routes-in-isolation {"http://the_host/with_components.json" (json-response {:color "green"
                                                                                                  :components [{:status "green"
                                                                                                                :description "child 1"
                                                                                                                :textualStatus "swell"}]})}
        (is (= [{:color :green :name "child 1" :message "swell"}]
               (:components (sut/with-status a-host (a-url-config-with-components "http://the_host/with_components.json"
                                                                                  {:json-path "$.components[*]"


  (testing "package-version"
    (testing "should extract value"
      (with-fake-resource "http://the_host/status.json" (json-response {:color "green"
                                                                        :version "the-package-1.0.0"
                                                                        :body ""})
        (is (= "the-package-1.0.0"
               (:package-version (sut/with-status a-host (a-url-config-with-package-version "http://%host%/status.json"
                                                                                            "version")))))))

    (testing "should handle missing value"
      (with-fake-resource "http://the_host/status.json" (json-response {:color "green"
                                                                        :body ""})
        (is (nil? (:package-version (sut/with-status a-host (a-url-config-with-package-version "http://%host%/status.json"
                                                                                               "package-version"))))))))

  (testing "components"
    (testing "return all statuses"
      (with-fake-resource "http://the_host/with_components.json" (json-response {:color "yellow"
                                                                                 :components [{:status "green"}
                                                                                              {:status "red"}
                                                                                              {:status "yellow"}]})
        (is (= [:green :red :yellow]
               (->> (sut/with-status a-host (a-url-config-with-components "http://the_host/with_components.json"
                                                                          {:json-path "$.components[*]"
