       expect(hydrator.setTarget 'api').to.be.instanceOf OVirtApi
 
 
-  describe "#hydrateNode", ->
-
-    it '''should call #hydrateCollectionLink and return undefined if node value
-    is a collection link''', ->
-      hydrator = getDeHydrator
-        isCollectionLink: yes, hydrateCollectionLink: 'defined'
-
-      expect(do hydrator.hydrateNode).to.be.undefined
-      expect(hydrator.isCollectionLink).to.be.called.once
-      expect(hydrator.hydrateCollectionLink).to.be.called.once
-
-    it '''should call #hydrateSearchOption and return undefined if node is a
-    search option''', ->
-      hydrator = getDeHydrator
-        isSearchOption: yes, hydrateSearchOption: 'defined'
-
-      expect(do hydrator.hydrateNode).to.be.undefined
-      expect(hydrator.isSearchOption).to.be.called.once
-      expect(hydrator.hydrateSearchOption).to.be.called.once
-
-    it '''should call #hydrateSpecialObject and return undefined if node is a
-    special object''', ->
-      hydrator = getDeHydrator
-        isSpecialObject: yes, hydrateSpecialObject: 'defined'
-
-      expect(do hydrator.hydrateNode).to.be.undefined
-      expect(hydrator.isSpecialObject).to.be.called.once
-      expect(hydrator.hydrateSpecialObject).to.be.called.once
-
-
-  describe "#hydrateCollectionLink", ->
-
-    it "should return collection object", ->
-      hydrator = do getHydrator
-      result = hydrator.hydrateCollectionLink '/api/link', testCollection.link
-      expect(result).to.be.instanceOf OVirtCollection
-
-    it "should register created collection", ->
-      hydrator = do getHydrator
-      hydrator.hydrateCollectionLink '/api/link', testCollection.link
-
-      expect(hydrator.registerIn).to.have.been.called.once
-      expect(hydrator._collections['/api/link'].instances[testCollection.name])
-        .to.be.instanceOf OVirtCollection
-
-
-  describe "#hydrateSearchOption", ->
-
-    it "should return search options", ->
-      hydrator = do getHydrator
-      result = hydrator.hydrateSearchOption '/api/link', testCollection.search
-      expect(result).to.be.equal testCollection.searchOptions
-
-    it "should register search options", ->
-      hydrator = do getHydrator
-      hydrator.hydrateSearchOption '/api/link', testCollection.search
-
-      expect(hydrator.registerIn).to.have.been.called.once
-      expect(hydrator._collections['/api/link'].searchOptions)
-        .to.have.property testCollection.name, testCollection.searchOptions
-
-
-  describe "#hydrateSpecialObject", ->
-
-    it '''should return special object as a resource if node
-    is a special object''', ->
-      hydrator = do getHydrator
-      result = hydrator.hydrateSpecialObject 'xpath', specialObject
-
-      expect(result).to.be.instanceOf OVirtResource
-
-    it '''should register special object instance to corresponding
-    collection''', ->
-      hydrator = do getHydrator
-      hydrator.hydrateSpecialObject 'xpath', specialObject
-
-      expect(hydrator.registerIn).to.have.been.called.once
-      expect(hydrator._collections['xpath'].specialObjects)
-        .to.have.property(testCollection.name)
-        .to.have.property("blank")
-        .to.be.instanceOf OVirtResource
-
-
-  describe "#registerIn", ->
-
-    it "should throw error on incomplete parameters", ->
-      hydrator = do getHydrator
-      expect(hydrator.registerIn).to.throw Error,
-        "You should specify both property and value to register in"
-      expect(-> hydrator.registerIn 'one').to.throw Error,
-        "You should specify both property and value to register in"
-
-    it "should throw error if wrong namespace specified", ->
-      hydrator = do getHydrator
-      hydrator.property = 'property'
-      expect(-> hydrator.registerIn 'property', 'key', 'subject')
-        .to.throw Error, "Wrong namespace to register in"
-
-    it "should throw error if object specified without a namespace", ->
-      hydrator = do getHydrator
-      expect(-> hydrator.registerIn hydrator._collections, 'value')
-        .to.throw Error, "You should specify a namespace to register in existing object"
-
-    it "should set property to subject if path is not specified", ->
-      hydrator = do getHydrator
-      hydrator.registerIn 'propertyName', 'value'
-      expect(hydrator).to.have.property 'propertyName', 'value'
-
-    it "should create property if not existed and string specified", ->
-      hydrator = do getHydrator
-      hydrator.registerIn 'propertyName', 'value'
-      expect(hydrator).to.have.property 'propertyName', 'value'
-
-    it "should assign subject to proper namespace", ->
-      hydrator = do getHydrator
-      hydrator.registerIn hydrator._collections, 'path', 'to', 'ns', 'value'
-      expect(hydrator._collections).to.have.property 'path'
-      expect(hydrator._collections.path).to.have.property 'to'
-      expect(hydrator._collections.path.to).to.have.property 'ns', 'value'
-
-    it "shouldn't overwrite namespaces if existed", ->
-      hydrator = do getHydrator
-      hydrator.registerIn hydrator._collections, 'path', 'to', 'value 1'
-      hydrator.registerIn hydrator._collections, 'path', 'for', 'value 2'
-      expect(hydrator._collections.path).to.have.property 'to', 'value 1'
-      expect(hydrator._collections.path).to.have.property 'for', 'value 2'
-
-
-  describe "#isSearchOption", ->
-
-    it "should match only valid search rel attributes", ->
-      hydrator = do getHydrator
-      expect(hydrator.isSearchOption "api/search").to.be.true
-      expect(hydrator.isSearchOption "apisearch").to.be.false
-      expect(hydrator.isSearchOption "api/search!").to.be.false
-
-    it "should treat leading slash as an error", ->
-      hydrator = do getHydrator
-      expect(hydrator.isSearchOption "api/search/").to.be.false
+  describe "Node hydration", ->
+
+    describe "#hydrateNode", ->
+
+      it "should call #hydrateCollectionLink and return undefined if node " +
+      "value is a collection link", ->
+        hydrator = getDeHydrator
+          isCollectionLink: yes, hydrateCollectionLink: 'defined'
+
+        expect(do hydrator.hydrateNode).to.be.undefined
+        expect(hydrator.isCollectionLink).to.be.called.once
+        expect(hydrator.hydrateCollectionLink).to.be.called.once
+
+      it "should call #hydrateSearchOption and return undefined if node is " +
+      "a search option", ->
+        hydrator = getDeHydrator
+          isSearchOption: yes, hydrateSearchOption: 'defined'
+
+        expect(do hydrator.hydrateNode).to.be.undefined
+        expect(hydrator.isSearchOption).to.be.called.once
+        expect(hydrator.hydrateSearchOption).to.be.called.once
+
+      it "should call #hydrateSpecialObject and return undefined if node is " +
+      "a special object", ->
+        hydrator = getDeHydrator
+          isSpecialObject: yes, hydrateSpecialObject: 'defined'
+
+        expect(do hydrator.hydrateNode).to.be.undefined
+        expect(hydrator.isSpecialObject).to.be.called.once
+        expect(hydrator.hydrateSpecialObject).to.be.called.once
+
+
+    describe "#hydrateCollectionLink", ->
+
+      it "should return collection object", ->
+        hydrator = do getHydrator
+        result =
+          hydrator.hydrateCollectionLink '/api/link', testCollection.link
+        expect(result).to.be.instanceOf OVirtCollection
+
+      it "should register created collection", ->
+        hydrator = do getHydrator
+        hydrator.hydrateCollectionLink '/api/link', testCollection.link
+
+        expect(hydrator.registerIn).to.have.been.called.once
+        expect(hydrator._collections['/api/link'].instances)
+          .to.have.property(testCollection.name)
+          .to.be.instanceOf OVirtCollection
+
+
+    describe "#hydrateSearchOption", ->
+
+      it "should return search options", ->
+        hydrator = do getHydrator
+        result =
+          hydrator.hydrateSearchOption '/api/link', testCollection.search
+        expect(result).to.be.equal testCollection.searchOptions
+
+      it "should register search options", ->
+        hydrator = do getHydrator
+        hydrator.hydrateSearchOption '/api/link', testCollection.search
+
+        expect(hydrator.registerIn).to.have.been.called.once
+        expect(hydrator._collections['/api/link'].searchOptions)
+          .to.have.property testCollection.name, testCollection.searchOptions
+
+
+    describe "#hydrateSpecialObject", ->
+
+      it "should return special object as a resource if node " +
+      "is a special object", ->
+        hydrator = do getHydrator
+        result = hydrator.hydrateSpecialObject 'xpath', specialObject
+
+        expect(result).to.be.instanceOf OVirtResource
+
+      it "should register special object instance to corresponding " +
+      "collection", ->
+        hydrator = do getHydrator
+        hydrator.hydrateSpecialObject 'xpath', specialObject
+
+        expect(hydrator.registerIn).to.have.been.called.once
+        expect(hydrator._collections['xpath'].specialObjects)
+          .to.have.property(testCollection.name)
+          .to.have.property("blank")
+          .to.be.instanceOf OVirtResource
+
+
+    describe "#registerIn", ->
+
+      it "should throw error on incomplete parameters", ->
+        hydrator = do getHydrator
+        expect(hydrator.registerIn).to.throw Error,
+          "You should specify both property and value to register in"
+        expect(-> hydrator.registerIn 'one').to.throw Error,
+          "You should specify both property and value to register in"
+
+      it "should throw error if wrong namespace specified", ->
+        hydrator = do getHydrator
+        hydrator.property = 'property'
+        expect(-> hydrator.registerIn 'property', 'key', 'subject')
+          .to.throw Error, "Wrong namespace to register in"
+
+      it "should throw error if object specified without a namespace", ->
+        hydrator = do getHydrator
+        expect(-> hydrator.registerIn hydrator._collections, 'value')
+          .to.throw Error,
+            "You should specify a namespace to register in existing object"
+
+      it "should set property to subject if path is not specified", ->
+        hydrator = do getHydrator
+        hydrator.registerIn 'propertyName', 'value'
+        expect(hydrator).to.have.property 'propertyName', 'value'
+
+      it "should create property if not existed and string specified", ->
+        hydrator = do getHydrator
+        hydrator.registerIn 'propertyName', 'value'
+        expect(hydrator).to.have.property 'propertyName', 'value'
+
+      it "should assign subject to proper namespace", ->
+        hydrator = do getHydrator
+        hydrator.registerIn hydrator._collections, 'path', 'to', 'ns', 'value'
+        expect(hydrator._collections).to.have.property 'path'
+        expect(hydrator._collections.path).to.have.property 'to'
+        expect(hydrator._collections.path.to).to.have.property 'ns', 'value'
+
+      it "shouldn't overwrite namespaces if existed", ->
+        hydrator = do getHydrator
+        hydrator.registerIn hydrator._collections, 'path', 'to', 'value 1'
+        hydrator.registerIn hydrator._collections, 'path', 'for', 'value 2'
+        expect(hydrator._collections.path).to.have.property 'to', 'value 1'
+        expect(hydrator._collections.path).to.have.property 'for', 'value 2'
 
 
   describe "#getSearchHrefBase", ->
 
     it "should return href base for specified pattern", ->
       hydrator = do getHydrator
-      expect(hydrator.getSearchHrefBase "/api/templates?search={query}").to.be.equal "/api/templates?search="
+      expect(hydrator.getSearchHrefBase "/api/templates?search={query}")
+        .to.be.equal "/api/templates?search="
 
     it "should properly process hrefs with from parts", ->
       hydrator = do getHydrator
-      expect(hydrator.getSearchHrefBase "/api/events;from={event_id}?search={query}").to.be.equal "/api/events;from={event_id}?search="
+      href = "/api/events;from={event_id}?search={query}"
+      expect(hydrator.getSearchHrefBase href)
+          .to.be.equal "/api/events;from={event_id}?search="
 
     it "should return undefined for invalid patterns", ->
       hydrator = do getHydrator
       expect(hydrator.getSearchHrefBase "").to.be.undefined
-      expect(hydrator.getSearchHrefBase "/api/templates={query}").to.be.undefined
-      expect(hydrator.getSearchHrefBase "/api/temp????lates?search={query}").to.be.undefined
-      expect(hydrator.getSearchHrefBase "?/api/templates?search={query}").to.be.undefined
+      expect(hydrator.getSearchHrefBase "/api/templates={query}")
+        .to.be.undefined
+      expect(hydrator.getSearchHrefBase "/api/temp????lates?search={query}")
+        .to.be.undefined
+      expect(hydrator.getSearchHrefBase "?/api/templates?search={query}")
+        .to.be.undefined
 
 
   describe "#getRootElementName", ->

      expect(-> hydrator.unfolded "not an object").to.not.throw Error


  describe "links detection", ->

    describe "#isLink", ->
      hydrator = do getHydrator

      expect(hydrator.getRootElementName spam: Spam: 'SPAM').to.be.equal 'spam'

    it "should return undefined for hashes without single root element", ->
      expect(hydrator.getRootElementName spam: 'SPAM', eggs: 'SPAM')
        .to.be.undefined

    it "should return undefined for empty hashes", ->
      expect(hydrator.getRootElementName {}).to.be.undefined
