Skip to content

Commit

Permalink
Added the expectThat.mocha NPM package and an example for use.
Browse files Browse the repository at this point in the history
  • Loading branch information
dmohl committed Jan 16, 2012
1 parent 17f4947 commit d9bd9ba
Show file tree
Hide file tree
Showing 18 changed files with 592 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
describe "Example Mocha Specifications", ->
foo = "bar"
describe "When testing should equal", ->
expectThat -> foo.should equal "bar"
describe "When testing shouldnt equal", ->
expectThat -> foo.shouldnt equal "baz"
describe "When testing for true", ->
expectThat -> (foo is "bar").should be true
expectThat -> (foo is "baz").shouldnt be true
describe "When testing for false", ->
expectThat -> (foo is "baz").should be false
expectThat -> (foo is "bar").shouldnt be false
describe "When testing to and be", ->
expectThat -> foo.should be equal to "bar"
expectThat -> foo.shouldnt be equal to "bah"
describe "When testing for null or undefined", ->
testNull = null
testUndefined = undefined
expectThat -> (testNull is null).should be true
expectThat -> (testNull isnt null).shouldnt be true
expectThat -> (testUndefined is undefined).should be true
expectThat -> (testUndefined is undefined).shouldnt be false
describe "When testing for throw", ->
expectThat -> (-> throw "test exception").should throwException
expectThat -> (-> throw "test exception").should throwException "test exception"
describe "When testing for greater than", ->
expectThat -> 10.should be greaterThan 9
expectThat -> 9.1.shouldnt be greaterThan 10
describe "When testing for less than", ->
expectThat -> 10.should be lessThan 11
expectThat -> 10.1.shouldnt be lessThan 10
22 changes: 22 additions & 0 deletions NuGet/ExpectThat.Mocha/Content/Scripts/Specs/index.html.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<html>
<head>
<meta charset="utf-8">
<title>Mocha Tests</title>
<link rel="stylesheet" href="https://raw.github.com/visionmedia/mocha/master/mocha.css" />
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="https://raw.github.com/visionmedia/mocha/master/mocha.js"></script>
<script type="text/javascript" src="../../lib/expectThat.mocha.js"></script>
<script>mocha.setup('bdd')</script>
<script src="./min/example.spec.js"></script>
<script>
$(function () {
mocha
.run()
.globals(['foo', 'bar']) // acceptable globals
})
</script>
</head>
<body>
<div id="mocha"></div>
</body>
</html>
18 changes: 18 additions & 0 deletions NuGet/ExpectThat.Mocha/ExpectThat.Jasmine.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0"?>
<package xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<metadata xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
<id>ExpectThat.Mocha</id>
<version>0.2.2.2</version>
<authors>Daniel Mohl</authors>
<requireLicenseAcceptance>false</requireLicenseAcceptance>
<description>ExpectThat for Mocha is an expressive, self-documenting assertion library for CoffeScript/JavaScript.</description>
<summary>ExpectThat for Mocha is an expressive, self-documenting assertion library for CoffeScript/JavaScript.</summary>
<language>en-US</language>
<projectUrl>https://github.com/dmohl/expectThat</projectUrl>
<licenseUrl>https://github.com/dmohl/expectThat/blob/master/MIT.License</licenseUrl>
<tags>JavaScript CoffeeScript ExpectThat Mocha</tags>
</metadata>
<files>
<file src="Content\Scripts\Specs\*.pp" target="content\Scripts\Specs"/>
</files>
</package>
4 changes: 4 additions & 0 deletions NuGet/ExpectThat.Mocha/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
c:\nuget\nuget.exe pack .\ExpectThat.Mocha.nuspec
md c:\nuget\ExpectThat.Mocha\
copy .\*.nupkg c:\nuget\ExpectThat.Mocha\ /Y
pause
5 changes: 3 additions & 2 deletions example/mocha-node/example.spec.coffee
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
expectThat = require '../../../lib/expectThat.jasmine.js'
require("expectThat.mocha");

describe "Example Mocha Specifications", ->
foo = "bar"
describe "When testing should equal", ->
console.log expectThat.expectThatApi.version
expectThat -> foo.should equal "bar"
describe "When testing should equal", ->
expectThat -> foo.should equal "bar"
describe "When testing shouldnt equal", ->
expectThat -> foo.shouldnt equal "baz"
Expand Down
12 changes: 6 additions & 6 deletions example/mocha-node/min/example.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
(function() {
var expectThat;

expectThat = require('../../../lib/expectThat.jasmine.js');
require("expectThat.mocha");

describe("Example Mocha Specifications", function() {
var foo;
foo = "bar";
describe("When testing should equal", function() {
console.log(expectThat.expectThatApi.version);
return expectThat(function() {
return foo.should(equal("bar"));
});
});
describe("When testing should equal", function() {
return expectThat(function() {
return foo.should(equal("bar"));
});
Expand Down Expand Up @@ -87,5 +89,3 @@
});
});
});

}).call(this);

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file not shown.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions example/mocha-node/node_modules/expectThat.mocha/lib/main.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 18 additions & 0 deletions example/mocha-node/node_modules/expectThat.mocha/package.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 0 additions & 5 deletions npm/ExpectThat.Mocha/bin/expectThat.mocha

This file was deleted.

Loading

0 comments on commit d9bd9ba

Please sign in to comment.