fluentnode
Version:
Fluent apis for node (based on the concepts used in C#'s FluentSharp
397 lines (266 loc) • 14.2 kB
HTML
<html>
<head>
<title>assert_String.litcoffee</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, target-densitydpi=160dpi, initial-scale=1.0; maximum-scale=1.0; user-scalable=0;">
<link rel="stylesheet" media="all" href="docco.css" />
</head>
<body>
<div id="container">
<div id="background"></div>
<ul id="jump_to">
<li>
<a class="large" href="javascript:void(0);">Jump To …</a>
<a class="small" href="javascript:void(0);">+</a>
<div id="jump_wrapper">
<div id="jump_page">
<a class="source" href="Array.html">
Array.litcoffee
</a>
<a class="source" href="Boolean.html">
Boolean.litcoffee
</a>
<a class="source" href="Function.html">
Function.litcoffee
</a>
<a class="source" href="Number.html">
Number.litcoffee
</a>
<a class="source" href="Object.html">
Object.litcoffee
</a>
<a class="source" href="String.html">
String.litcoffee
</a>
<a class="source" href="_register.html">
_register.js
</a>
<a class="source" href="_to_map_and_write_Tests.html">
_to_map_and_write_Tests.litcoffee
</a>
<a class="source" href="assert_Array.html">
assert_Array.litcoffee
</a>
<a class="source" href="assert_Boolean.html">
assert_Boolean.litcoffee
</a>
<a class="source" href="assert_Function.html">
assert_Function.litcoffee
</a>
<a class="source" href="assert_Number.html">
assert_Number.litcoffee
</a>
<a class="source" href="assert_Object.html">
assert_Object.litcoffee
</a>
<a class="source" href="assert_String.html">
assert_String.litcoffee
</a>
<a class="source" href="console.html">
console.litcoffee
</a>
<a class="source" href="fs.html">
fs.litcoffee
</a>
<a class="source" href="globals.html">
globals.litcoffee
</a>
<a class="source" href="http.html">
http.litcoffee
</a>
<a class="source" href="index.html">
index.md
</a>
<a class="source" href="path.html">
path.litcoffee
</a>
<a class="source" href="process.html">
process.litcoffee
</a>
<a class="source" href="Array.test.html">
Array.test.coffee
</a>
<a class="source" href="Boolean.test.html">
Boolean.test.coffee
</a>
<a class="source" href="Function.test.html">
Function.test.coffee
</a>
<a class="source" href="Number.test.html">
Number.test.coffee
</a>
<a class="source" href="Object.test.html">
Object.test.coffee
</a>
<a class="source" href="String.test.html">
String.test.coffee
</a>
<a class="source" href="Array.test.html">
Array.test.coffee
</a>
<a class="source" href="Boolean.test.html">
Boolean.test.coffee
</a>
<a class="source" href="Function.test.html">
Function.test.coffee
</a>
<a class="source" href="Number.test.html">
Number.test.coffee
</a>
<a class="source" href="Object.test.html">
Object.test.coffee
</a>
<a class="source" href="String.test.html">
String.test.coffee
</a>
<a class="source" href="console.test.html">
console.test.coffee
</a>
<a class="source" href="fs.test.html">
fs.test.coffee
</a>
<a class="source" href="globals.test.html">
globals.test.coffee
</a>
<a class="source" href="http.test.html">
http.test.coffee
</a>
<a class="source" href="path.test.html">
path.test.coffee
</a>
<a class="source" href="process.test.html">
process.test.coffee
</a>
</div>
</li>
</ul>
<ul class="sections">
<li id="title">
<div class="annotation">
<h1>assert_String.litcoffee</h1>
</div>
</li>
<li id="section-1">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-1">¶</a>
</div>
<p>dependencies</p>
</div>
<div class="content"><div class='highlight'><pre>assert = <span class="hljs-built_in">require</span> <span class="hljs-string">'assert'</span>
<span class="hljs-built_in">require</span> <span class="hljs-string">'../Boolean'</span>
<span class="hljs-built_in">require</span> <span class="hljs-string">'../fs'</span></pre></div></div>
</li>
<li id="section-2">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-2">¶</a>
</div>
<p><strong>String::assert_Contains(target)</strong></p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::assert_Contains = <span class="hljs-function"><span class="hljs-params">(target)</span>-></span>
source = @.toString()
message = <span class="hljs-string">"expected string '<span class="hljs-subst">#{source}</span>' to contain the string/array '<span class="hljs-subst">#{target}</span>'"</span>
assert(source.contains(target), message)
@</pre></div></div>
</li>
<li id="section-3">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-3">¶</a>
</div>
<p><strong>String::assert_Not_Contains(target)</strong></p>
</div>
<div class="content"><div class='highlight'><pre><span class="hljs-attribute">String</span>::assert_Not_Contains = <span class="hljs-function"><span class="hljs-params">(target)</span>-></span>
source = @.toString()
message = <span class="hljs-string">"expected string '<span class="hljs-subst">#{source}</span>' to not contain the string '<span class="hljs-subst">#{target}</span>'"</span>
assert(source.indexOf(target) == -<span class="hljs-number">1</span>, message)
@
<span class="hljs-attribute">String</span>::assert_Is_Equal_To = <span class="hljs-function"><span class="hljs-params">(target)</span>-></span>
source = @.toString()
assert.equal(source, target)
@
<span class="hljs-attribute">String</span>::assert_Is_Not_Equal_To = <span class="hljs-function"><span class="hljs-params">(target)</span>-></span>
assert.notDeepEqual(@.toString(), target.toString())
@
<span class="hljs-attribute">String</span>::assert_Is_Json = <span class="hljs-function">-></span>
contents = @.toString()
<span class="hljs-keyword">try</span>
json = JSON.parse(contents)
<span class="hljs-keyword">return</span> json
<span class="hljs-keyword">catch</span>
<span class="hljs-keyword">throw</span> <span class="hljs-string">'[assert_Is_JSON] failed to convert string to json'</span>
<span class="hljs-attribute">String</span>::assert_Is_String = <span class="hljs-function">=></span>
assert.equal(<span class="hljs-keyword">typeof</span>(@), <span class="hljs-string">'object'</span>) <span class="hljs-comment"># not the best test, but if @ is not a string there will be an run-time-error</span></pre></div></div>
</li>
<li id="section-4">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-4">¶</a>
</div>
<p>assert.equal(typeof(@), ‘array’, message) # this doesn’t work</p>
</div>
<div class="content"><div class='highlight'><pre> @ <span class="hljs-comment"># also not working as expected</span>
<span class="hljs-attribute">String</span>::assert_Length_Is = <span class="hljs-function"><span class="hljs-params">(size)</span>-></span>
message = <span class="hljs-string">"[assert_Length_Is]"</span>
assert.equal(@.length, size, message)
@
<span class="hljs-attribute">String</span>::assert_Length_Is_Not = <span class="hljs-function"><span class="hljs-params">(size)</span>-></span>
message = <span class="hljs-string">"[assert_Length_Is_Not]"</span>
assert.notEqual(@.length, size, message)
@
<span class="hljs-attribute">String</span>::assert_That_File_Exists = <span class="hljs-function">-></span>
file = @.toString()
test = file.file_Exists()
message = <span class="hljs-string">"[assert_That_File_Exists]: <span class="hljs-subst">#{file}</span>"</span>
assert(test, message)
file
<span class="hljs-attribute">String</span>::assert_That_File_Not_Exists = <span class="hljs-function">-></span>
file = @.toString()
test = file.file_Not_Exists()
message = <span class="hljs-string">"[assert_That_File_Not_Exists]: <span class="hljs-subst">#{file}</span>"</span>
assert(test, message)
file
<span class="hljs-attribute">String</span>::assert_That_Folder_Exists = <span class="hljs-function">-></span>
folder = @.toString()
test = folder.folder_Exists()
message = <span class="hljs-string">"[assert_That_Folder_Exists]: <span class="hljs-subst">#{folder}</span>"</span>
assert(test, message)
folder
<span class="hljs-attribute">String</span>::assert_That_Folder_Not_Exists = <span class="hljs-function">-></span>
folder = @.toString()
test = folder.folder_Exists().is_False()
message = <span class="hljs-string">"[assert_That_Not_Folder_Exists]: <span class="hljs-subst">#{folder}</span>"</span>
assert(test, message)
folder
<span class="hljs-attribute">String</span>::assert_Is = <span class="hljs-attribute">String</span>::assert_Is_Equal_To
<span class="hljs-attribute">String</span>::assert_Is_Not = <span class="hljs-attribute">String</span>::assert_Is_Not_Equal_To
<span class="hljs-attribute">String</span>::assert_Equals = <span class="hljs-attribute">String</span>::assert_Is_Equal_To
<span class="hljs-attribute">String</span>::assert_File_Exists = <span class="hljs-attribute">String</span>::assert_That_File_Exists
<span class="hljs-attribute">String</span>::assert_File_Not_Exists = <span class="hljs-attribute">String</span>::assert_That_File_Not_Exists
<span class="hljs-attribute">String</span>::assert_Folder_Exists = <span class="hljs-attribute">String</span>::assert_That_Folder_Exists
<span class="hljs-attribute">String</span>::assert_Folder_Not_Exists = <span class="hljs-attribute">String</span>::assert_That_Folder_Not_Exists
<span class="hljs-attribute">String</span>::assert_Size_Is = <span class="hljs-attribute">String</span>::assert_Length_Is
<span class="hljs-attribute">String</span>::assert_Size_Is_Not = <span class="hljs-attribute">String</span>::assert_Length_Is_Not</pre></div></div>
</li>
<li id="section-5">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-5">¶</a>
</div>
<hr>
</div>
</li>
<li id="section-6">
<div class="annotation">
<div class="pilwrap ">
<a class="pilcrow" href="#section-6">¶</a>
</div>
<p>back to <a href="index.html">index</a></p>
</div>
</li>
</ul>
</div>
</body>
</html>