forked from nathansobo/screw-unit
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
copious documentation and examples, following tim's lead
- Loading branch information
Nick Kallen
committed
May 12, 2008
1 parent
3a278fe
commit 6504f7a
Showing
17 changed files
with
535 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,68 @@ | |||
<html> | |||
<!-- | |||
This file is a fully-functioning example test case. Try opening this file in Firefox, Safari, | |||
or Internet Explorer to see what a running test looks like. | |||
This file demonstrates the the components involved in writing a simple test, such as: | |||
* The necessary HTML to run a test (with the required <script> and <link rel="stylesheet"> tags), | |||
* A "custom matcher" (i.e., a custom assertion) to make your tests more readable, | |||
* And, a simple test with the necessary boiler-plate code to get you up and running. | |||
Typically, these components are separated out into multiple files. To see what a more typical suite | |||
of tests look like, look at the larger example in the examples/ directory. | |||
--> | |||
<head> | |||
<!-- These are all of the necessary javascript and css files required to run your tests --> | |||
<script src="lib/jquery-1.2.3.js"></script> | |||
<script src="lib/jquery.fn.js"></script> | |||
<script src="lib/jquery.print.js"></script> | |||
<script src="lib/screw.builder.js"></script> | |||
<script src="lib/screw.matchers.js"></script> | |||
<script src="lib/screw.events.js"></script> | |||
<script src="lib/screw.behaviors.js"></script> | |||
<link rel="stylesheet" href="lib/screw.css"> | |||
|
|||
<script type="text/javascript"> | |||
// Here is the system under test (SUT)--that is, your application code that you would like | |||
// to test. | |||
function foo() { | |||
return 2; | |||
} | |||
</script> | |||
|
|||
<script type="text/javascript"> | |||
// Here is a Custom Matcher. A custom matcher is a custom assertion, | |||
// tailored to your application; these help to make your tests more readable. | |||
Screw.Matchers["be_even"] = { | |||
match: function(expected, actual) { | |||
return actual % 2 == 0; | |||
}, | |||
failure_message: function(expected, actual, not) { | |||
return 'expected ' + $.print(actual) + (not ? ' not' : '') + ' to be even'; | |||
} | |||
} | |||
</script> | |||
|
|||
<script type="text/javascript"> | |||
// Here is a sample test. Note that all tests are wrapped in | |||
// "Screw.Unit(function() { ... })". | |||
Screw.Unit(function() { | |||
// Tests are organized into 'describes' and 'its', following the style of RSpec. | |||
describe("foo", function() { | |||
it("returns 2", function() { | |||
// 'equal' is one among many matchers provided with the Screw.Unit distribution. It | |||
// is smart enough to compare arrays, objects, and primitives. | |||
expect(foo()).to(equal, 2); | |||
}); | |||
}); | |||
|
|||
describe("an undefined variable", function() { | |||
// Here is a use of the custom matcher defined above. | |||
it("is not defined", function() { | |||
expect(2).to(be_even); | |||
expect(3).to_not(be_even); | |||
}); | |||
}); | |||
}); | |||
</script> | |||
</head> | |||
<body></body> | |||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,22 @@ | |||
Copyright (c) 2008 Nick Kallen | |||
|
|||
Permission is hereby granted, free of charge, to any person | |||
obtaining a copy of this software and associated documentation | |||
files (the "Software"), to deal in the Software without | |||
restriction, including without limitation the rights to use, | |||
copy, modify, merge, publish, distribute, sublicense, and/or sell | |||
copies of the Software, and to permit persons to whom the | |||
Software is furnished to do so, subject to the following | |||
conditions: | |||
|
|||
The above copyright notice and this permission notice shall be | |||
included in all copies or substantial portions of the Software. | |||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | |||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES | |||
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | |||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | |||
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | |||
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | |||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | |||
OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.