dox Executable Documentation

Wrap responses

No wrapping necessary

Given the box container 'inner' responding 'World'
Given the box container 'outer' responding 'Hello $inner'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be 'Hello World'

Link target

Given the box container 'inner' responding '<a href="here">Here</a>'
Given the box container 'outer' responding 'Go $inner'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be 'Go <a href="?_inner[!]=here&_=inner">Here</a>'

Link arguments

Given the box container 'inner' responding '<a href="?foo=bar">Here</a>'
Given the box container 'outer' responding 'Go $inner'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be 'Go <a href="?_inner[foo]=bar&_=inner">Here</a>'

Link targets other box

Given the box container 'inner' responding '<a href="there" target="other">Two</a>'
Given the box container 'outer' responding 'Go $inner'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be 'Go <a href="?_other[!]=there&_=other">Two</a>'

Link targets parent box

Given the box container 'outer' responding 'Go $inner'
Given the box container 'inner' responding 'Even $further'
Given the box container 'further' responding '<a href="there?foo=bar" target="_parent">Further</a>'
Given 'outer' contains 'inner'
Given 'inner' contains 'further'
When I get the response from 'outer'
Then the response should be 'Go Even <a href="?_inner[!]=there&_inner[foo]=bar&_=inner">Further</a>'

Link targets parents parent box

Given the box container 'outer' responding 'Go $inner'
Given the box container 'inner' responding 'Even $further'
Given the box container 'further' responding '<a href="there?foo=bar" target="_parent_parent">Further</a>'
Given 'outer' contains 'inner'
Given 'inner' contains 'further'
When I get the response from 'outer'
Then the response should be 'Go Even <a href="there?foo=bar">Further</a>'

Do not wrap links with other targets

Given the box container 'inner' responding '<a href="there" target="_other">Two</a>'
Given the box container 'outer' responding 'Go $inner'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be 'Go <a href="there" target="_other">Two</a>'

Recursive wrapping

Given the box container 'one' responding 'One $two'
Given the box container 'two' responding '<a href="here?foo=bar">Two</a> $three'
Given the box container 'three' responding '<a href="there?me=you">Three</a>'
Given 'one' contains 'two'
Given 'two' contains 'three'
When I get the response from 'one'
Then the response should be 'One <a href="?_two[!]=here&_two[foo]=bar&_=two">Two</a> ' . '<a href="?_two[_three][!]=there&_two[_three][me]=you&_two[_]=three&_=two">Three</a>'

Form without action and method

Given the box container 'outer' responding '$inner'
Given the box container 'inner' responding '<form></form>'
Given 'outer' contains 'inner'
Given the request argument '_some/key' is 'foo'
When I get the response from 'outer'
Then the response should be '<form action="?_some[key]=foo&_inner[do]=post&_=inner"></form>'

Form with action

Given the box container 'outer' responding '$inner'
Given the box container 'inner' responding ' <form action="there?me=you#here" method="get"> <input name="foo" value="bar"/> <textarea name="foo[one]"></textarea> <select id="here" name="foo[two]"></select> <button name="do" value="that">Go</button> </form>'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be ' <form action="?_inner[!]=there&_inner[me]=you&_inner[do]=get&_=inner#here" method="get"> <input name="_inner[foo]" value="bar"/> <textarea name="_inner[foo][one]"></textarea> <select id="here" name="_inner[foo][two]"></select> <button name="_inner[do]" value="that">Go</button> </form>'

Wrap body

Given the box container 'outer' responding ' <html> <head><title>Hello World</title></head> <body><p>$inner</p></body> </html>'
Given the box container 'inner' responding ' <html> <head><title>Ignored</title></head> <body><em>Hello World</em></body> </html>'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be ' <html> <head><title>Hello World</title></head> <body><p><em>Hello World</em></p></body> </html>'

Always unpack body

Given the box container 'outer' responding '$inner'
Given the box container 'inner' responding '<html><body>Hello World</body></html>'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be 'Hello World'

Complex dom

Given the box container 'outer' responding '$inner'
Given the box container 'inner' responding ' <html><body><p>Hello</p> <div><form action="here?foo=bar"> <a href="there?one=two">Click</a> </form></div> </body></html>'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be '<p>Hello</p> <div><form action="?_inner[!]=here&_inner[foo]=bar&_inner[do]=post&_=inner"> <a href="?_inner[!]=there&_inner[one]=two&_=inner">Click</a> </form></div>'

Assets

Given the box container 'inner' responding 'not me'
Given the box container 'outer' responding '$inner'
Given the box container 'other' in 'root/in/here' responding ' <link href="some/favico.png" rel="icon" type="image/png"/> <link href="../my/styles.css" rel="stylesheet"/> <script src="some/script.js"/> <script src="/absolute/path.js"/> <img src="some/pic.jpg"/>'
Given 'outer' contains 'inner'
Given the request argument '_inner/!' is 'in/here/other'
When I get the response from 'outer'
Then the response should be ' <link href="in/here/some/favico.png" rel="icon" type="image/png"/> <link href="in/my/styles.css" rel="stylesheet"/> <script src="in/here/some/script.js"/> <script src="/absolute/path.js"/> <img src="in/here/some/pic.jpg"/>'

Merge head

Given the box container 'outer' responding ' <html> <head> <title>I stay</title> <script src="outer/script.js"/> <script src="duplicate.js"/> <script>alert("bar");</script> </head> </html> '
Given the box container 'inner' responding ' <html> <head> <title>I am ignored</title> <script src="script.js"/> <script src="duplicate.js"/> <script>alert("foo");</script> </head> </html>'
Given 'outer' contains 'inner'
When I get the response from 'outer'
Then the response should be ' <html> <head> <title>I stay</title> <script src="outer/script.js"/> <script src="duplicate.js"/> <script>alert("bar");</script> <script src="script.js"/><script>alert("foo");</script></head> </html>'

Boxes with default request arguments

Given the box container 'outer' responding 'Hello $inner'
Given the box container 'inner' responding '$name'
Given 'outer' contains 'inner' with array('name' => 'World')
When I get the response from 'outer'
Then the response should be 'Hello World'

Wrap box list

Given the box container 'outer' responding '$inner'
Given the box container 'inner' responding '$list'
Given the box container 'item' responding '<a href="?foo=bar">$name</a>'
Given 'outer' contains 'inner'
Given 'inner' contains a collection 'list'
Given 'inner' has in 'list' a 'item' with array('name' => 'One')
Given 'inner' has in 'list' a 'item' with array('name' => 'Two')
Given 'inner' has in 'list' a 'item' with array('name' => 'Three')
When I get the response from 'outer'
Then the response should be '<a href="?_inner[_list][_0][foo]=bar&_inner[_list][_]=0&_inner[_]=list&_=inner">One</a> ' . '<a href="?_inner[_list][_1][foo]=bar&_inner[_list][_]=1&_inner[_]=list&_=inner">Two</a> ' . '<a href="?_inner[_list][_2][foo]=bar&_inner[_list][_]=2&_inner[_]=list&_=inner">Three</a>'

List with headers

Given the box container 'outer' responding ' <html> <head> <title>Outer</title> </head> <body></body> </html>'
Given the box container 'inner' responding '<html><head><script src="$foo"/></head><body></body></html>'
Given 'outer' contains a collection 'list'
Given 'outer' has in 'list' a 'inner' with array('foo' => 'one')
Given 'outer' has in 'list' a 'inner' with array('foo' => 'bar')
Given 'outer' has in 'list' a 'inner' with array('foo' => 'bar')
When I get the response from 'outer'
Then the response should be ' <html> <head> <title>Outer</title> <script src="one"/><script src="bar"/></head> <body></body> </html>'

Merge on load handlers

Given the box container 'outer' responding '<html> <head></head> <body onload="me_using(document.body);"> My Body $one $two </body></html>'
Given the box container 'one' responding '<html><body onload="this_using(document.body);"> This Body. </body></html>'
Given the box container 'two' responding '<html><body onload="that_using(top.document.body);"> That Body </body></html>'
Given 'outer' contains 'one'
Given 'outer' contains 'two'
When I get the response from 'outer'
Then the response should be similar to '<html> <head></head> <body onload="me_using(document.body);this_using(top.document.getElementById(\'box-uniqid\'));that_using(top.document.getElementById(\'box-uniqid\'));"> My Body <div id="box-uniqid"> This Body. </div> <div id="box-uniqid"> That Body </div> </body></html>'