doc/rdoc/classes/Assertion.html in quarry-0.3.0 vs doc/rdoc/classes/Assertion.html in quarry-0.4.0
- old
+ new
@@ -1,101 +1,171 @@
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
-<html>
- <head>
- <title>Class: Assertion</title>
- <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
- <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
- <script language="JavaScript" type="text/javascript">
- // <![CDATA[
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <title>Class: Assertion</title>
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
+ <script type="text/javascript">
+ // <![CDATA[
- function toggleSource( id )
- {
- var elem
- var link
+ function popupCode( url ) {
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
+ }
- if( document.getElementById )
- {
- elem = document.getElementById( id )
- link = document.getElementById( "l_" + id )
- }
- else if ( document.all )
- {
- elem = eval( "document.all." + id )
- link = eval( "document.all.l_" + id )
- }
- else
- return false;
+ function toggleCode( id ) {
+ if ( document.getElementById )
+ elem = document.getElementById( id );
+ else if ( document.all )
+ elem = eval( "document.all." + id );
+ else
+ return false;
- if( elem.style.display == "block" )
- {
- elem.style.display = "none"
- link.innerHTML = "show source"
- }
- else
- {
- elem.style.display = "block"
- link.innerHTML = "hide source"
- }
- }
+ elemStyle = elem.style;
+
+ if ( elemStyle.display != "block" ) {
+ elemStyle.display = "block"
+ } else {
+ elemStyle.display = "none"
+ }
- function openCode( url )
- {
- window.open( url, "SOURCE_CODE", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=480,width=750" ).focus();
- }
- // ]]>
- </script>
- </head>
+ return true;
+ }
+
+ // Make codeblocks hidden by default
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
+
+ // ]]>
+ </script>
- <body>
- <table width="100%" border='0' cellpadding='0' cellspacing='0' class='banner'><tr>
- <td class="file-title"><span class="file-title-prefix">Class</span><br />Assertion</td>
- <td align="right">
- <table cellspacing="0" cellpadding="2">
- <tr valign="top">
- <td>In:</td>
- <td>
-<a href="../files/lib/quarry/assertion_rb.html">lib/quarry/assertion.rb</a>
- </td>
- </tr>
- <tr>
- <td>Parent:</td>
- <td>
-Exception
- </td>
- </tr>
- </table>
- </td>
+</head>
+<body>
+
+
+
+ <div id="classHeader">
+ <table class="header-table">
+ <tr class="top-aligned-row">
+ <td><strong>Class</strong></td>
+ <td class="class-name-in-header">Assertion</td>
</tr>
- </table>
- <!-- banner header -->
+ <tr class="top-aligned-row">
+ <td><strong>In:</strong></td>
+ <td>
+ <a href="../files/lib/quarry/assert_rb.html">
+ lib/quarry/assert.rb
+ </a>
+ <br />
+ </td>
+ </tr>
+ <tr class="top-aligned-row">
+ <td><strong>Parent:</strong></td>
+ <td>
+ Exception
+ </td>
+ </tr>
+ </table>
+ </div>
+ <!-- banner header -->
+
<div id="bodyContent">
- <div id="content">
- <div class="description"><p>
-<a href="Assertion.html">Assertion</a> object is a special subclass of
-Exception, used to raise assertion errors.
+
+
+ <div id="contextContent">
+
+ <div id="description">
+ <p>
+<a href="Assertion.html">Assertion</a> is a special subclass of Exception
+used to raise assertion errors.
</p>
-</div>
+<p>
+Assertions are generally invoked via the assert or should functors. For
+instance to assert that 4 == 4 use:
+</p>
+<pre>
+ 4.assert == 4
+</pre>
+<p>
+If the assertion does not hold true an <a
+href="Assertion.html">Assertion</a> exception will be raised.
+</p>
+<p>
+You can also create your own assertion "macros" simply by
+defining applicable methods resuing previous assertion methods.
+</p>
+<pre>
+ class Module
+ def should_be_enumerable(module)
+ should < Enumerable
+ instance_methods.should.include?('each')
+ end
+ end
+</pre>
+<p>
+As fancy as assertion functors may seem, under the hood they translate into
+quite simple code. Consider this valid macro:
+</p>
+<pre>
+ def assert_fail_every_time
+ raise Assertion, "this will fail every time"
+ end
+</pre>
+<p>
+Not very useful, but completely valid.
+</p>
+<h2>Concerning Nomenclature</h2>
+<p>
+Unfortunately there‘s a bit of rift in the naming scheme of assertion
+methods. With TDD the term ‘assert’ became the standard.
+However, with the advent of BDD, ‘should’ has become the
+dominant term.
+</p>
+<p>
+If I had my druthers I would probably have picked ‘must’ since
+it is short and carries the semantics of enforcement.
+</p>
+ </div>
+ </div>
+ </div>
- <div class="sectiontitle">Classes and Modules</div>
- Class <a href="Assertion/False.html" class="link">Assertion::False</a><br />
+
+ <!-- if includes -->
+
+ <div id="section">
+
+ <div id="class-list">
+ <h3 class="section-bar">Classes and Modules</h3>
+
+ Class <a href="Assertion/False.html" class="link">Assertion::False</a><br />
Class <a href="Assertion/True.html" class="link">Assertion::True</a><br />
+ </div>
-</div>
+
+
+
+ <!-- if method_list -->
+
+
</div>
- </body>
+
+<div id="validator-badges">
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
+</div>
+
+</body>
</html>
\ No newline at end of file