Permalink
Browse files

- significant updates to run.js

- use MIT license
- update dependencies
- update README
- add Cakefile
- add contrib scripts
- add simple.html
  • Loading branch information...
brianmhunt committed Dec 8, 2012
1 parent ac2bd19 commit e25d9100d70e4fccf817a8f54d1d8e1e8739e9dd
View
@@ -1 +0,0 @@
-test/
View
@@ -1,5 +1,3 @@
language: node_js
node_js:
- - 0.4
- - 0.6
- 0.8
View
@@ -0,0 +1,90 @@
+#
+# Cakefile
+# --------
+#
+# Targets:
+#
+# test:
+# print some pretty colors on the console
+#
+# toast:
+# create the javascript files in the build/ directory
+#
+#
+# Based on sample cakefile at
+# https://github.com/kompiro/Cakefile-Sample/
+
+{spawn} = require 'child_process'
+{log} = require 'util'
+fs = require 'fs'
+glob = require 'glob'
+_ = require 'lodash'
+coffee = require 'coffee-script'
+
+SRC_DIR = 'lib'
+COFFEE_SRC = ['casper-chai.coffee']
+DEST = 'build/casper-chai'
+UGLIFY_CMD = './node_modules/uglify-js2/bin/uglifyjs2'
+
+task 'test', 'Print some pretty colors to the console', (options) ->
+ cmd = 'casperjs'
+ args = ["test/run.js"]
+ log "Cake is running: #{cmd} #{args.join(" ")}"
+ spawn cmd, args, customFds: [0, 1, 2]
+
+task 'deploy', 'Publish a patch release on npm (increments patch number)', ->
+ semver = require('semver')
+
+ # read package.json
+ pkg = JSON.parse(fs.readFileSync('package.json', "utf8"))
+
+ # get and increment version
+ version = pkg.version
+ pkg.version = semver.inc(version, 'patch')
+
+ # notify of version change and write new package.json
+ console.log "version incrementing from #{version} => #{pkg.version}"
+ fs.writeFileSync("package.json", JSON.stringify(pkg, null, 2), "utf8")
+
+ # build latest version
+ invoke 'toast'
+
+ # publish
+ args = ['publish']
+ spawn "npm", args, customFds: [0,1,2]
+
+
+
+task 'toast', "Build the project into the build/ dir", (options) ->
+ source_dir = require('path').join(__dirname, SRC_DIR)
+ version = JSON.parse(fs.readFileSync("package.json")).version
+ console.log "Compiling version #{version}"
+ sources = []
+
+ # Get all source files. Preserve the order in COFFEE_SRC
+ _.each(COFFEE_SRC, (src) ->
+ _.each(glob.sync(src, cwd: source_dir), (filename) ->
+ if filename not in sources
+ sources.push(filename)
+ )
+ )
+
+ # get the source as a string
+ source = _.map(sources, (src_file) ->
+ src_file = require('path').join(SRC_DIR, src_file)
+ console.log "Compiling #{src_file}."
+ js = coffee.compile fs.readFileSync(src_file, 'utf8')
+ return "\n// -- from: #{src_file} -- \\\\\n" + js
+ ).join("\n")
+
+ contents = source
+
+ console.log "Writing #{DEST}.js"
+ fs.writeFileSync("#{DEST}.js", contents, 'utf8')
+
+ # minify the content
+ console.log "Creating minified #{DEST}.min.js"
+ args = ["#{DEST}.js", '-o', "#{DEST}.min.js", '-m', '--lint']
+ spawn UGLIFY_CMD, args, customFds: [0, 1, 2]
+
+
View
@@ -1,14 +1,19 @@
- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
- Version 2, December 2004
+Copyright (C) 2012 Brian M Hunt
- Copyright (C) 2012 Domenic Denicola <domenic@domenicdenicola.com>
+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:
- Everyone is permitted to copy and distribute verbatim or modified
- copies of this license document, and changing it is allowed as long
- as the name is changed.
-
- DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
- TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
-
- 0. You just DO WHAT THE FUCK YOU WANT TO.
+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.
View
165 README.md
@@ -1,169 +1,24 @@
-# Sinon.JS Assertions for Chai
+# Casper.JS Assertions for Chai
-**Sinon–Chai** provides a set of custom assertions for using the [Sinon.JS][] spy, stub, and mocking framework with the
-[Chai][] assertion library. You get all the benefits of Chai with all the powerful tools of Sinon.JS.
+**Casper–Chai** provides a set of custom assertions for use with [CasperJS][].
+You get all the benefits of [Chai][] to test using CasperJS.
-Instead of using Sinon.JS's assertions:
-
-```javascript
-sinon.assertCalledWith(mySpy, "foo");
-```
-
-or awkwardly trying to use Chai's `should` or `expect` interfaces on spy properties:
-
-```javascript
-mySpy.calledWith("foo").should.be.ok;
-expect(mySpy.calledWith("foo")).to.be.ok;
-```
+Instead of using Casper's Tester:
you can say
```javascript
-mySpy.should.have.been.calledWith("foo");
-```
-
-
-## Assertions
-
-All of your favorite Sinon.JS assertions made their way into Sinon–Chai. We show the `should` syntax here; the `expect`
-equivalent is also available.
-
-<table>
- <tr>
- <th>Sinon.JS property/method</th>
- <th>Sinon–Chai assertion</th>
- </tr>
- <tr>
- <td>called</td>
- <td>spy.should.have.been.called</td>
- </tr>
- <tr>
- <td>calledOnce</td>
- <td>spy.should.have.been.calledOnce</td>
- </tr>
- <tr>
- <td>calledTwice</td>
- <td>spy.should.have.been.calledTwice</td>
- </tr>
- <tr>
- <td>calledThrice</td>
- <td>spy.should.have.been.calledThrice</td>
- </tr>
- <tr>
- <td>calledBefore</td>
- <td>spy1.should.have.been.calledBefore(spy2)</td>
- </tr>
- <tr>
- <td>calledAfter</td>
- <td>spy1.should.have.been.calledAfter(spy2)</td>
- </tr>
- <tr>
- <td>calledWithNew</td>
- <td>spy.should.have.been.calledWithNew</td>
- </tr>
- <tr>
- <td>alwaysCalledWithNew</td>
- <td>spy.should.always.have.been.calledWithNew</td>
- </tr>
- <tr>
- <td>calledOn</td>
- <td>spy.should.have.been.calledOn(context)</td>
- </tr>
- <tr>
- <td>alwaysCalledOn</td>
- <td>spy.should.always.have.been.calledOn(context)</td>
- </tr>
- <tr>
- <td>calledWith</td>
- <td>spy.should.have.been.calledWith(...args)</td>
- </tr>
- <tr>
- <td>alwaysCalledWith</td>
- <td>spy.should.always.have.been.calledWith(...args)</td>
- </tr>
- <tr>
- <td>calledWithExactly</td>
- <td>spy.should.always.have.been.calledWithExactly(...args)</td>
- </tr>
- <tr>
- <td>alwaysCalledWithExactly</td>
- <td>spy.should.always.have.been.calledWithExactly(...args)</td>
- </tr>
- <tr>
- <td>returned</td>
- <td>spy.should.have.returned(returnVal)</td>
- </tr>
- <tr>
- <td>alwaysReturned</td>
- <td>spy.should.have.always.returned(returnVal)</td>
- </tr>
- <tr>
- <td>threw</td>
- <td>spy.should.have.thrown(errorObjOrErrorTypeStringOrNothing)</td>
- </tr>
- <tr>
- <td>alwaysThrew</td>
- <td>spy.should.have.always.thrown(errorObjOrErrorTypeStringOrNothing)</td>
- </tr>
-</table>
-
-For more information on the behavior of each assertion, see
-[the documentation for the corresponding spy methods][spymethods]. These of course work on not only spies, but
-individual spy calls, stubs, and mocks as well.
-
-
-## Installation and Usage
-
-### Node
-
-Do an `npm install sinon-chai` to get up and running. Then:
-
-```javascript
-var chai = require("chai");
-var sinonChai = require("sinon-chai");
-
-chai.use(sinonChai);
+***
```
-You can of course put this code in a common test fixture file; for an example using [Mocha][], see
-[the Sinon–Chai tests themselves][fixturedemo].
-
### AMD
-Sinon–Chai supports being used as an [AMD][] module, registering itself anonymously (just like Chai). So, assuming you
-have configured your loader to map the Chai and Sinon–Chai files to the respective module IDs `"chai"` and
-`"sinon-chai"`, you can use them as follows:
-
-```javascript
-define(function (require, exports, module) {
- var chai = require("chai");
- var sinonChai = require("sinon-chai");
-
- chai.use(sinonChai);
-});
-```
-
-### `<script>` tag
-
-If you include Sinon–Chai directly with a `<script>` tag, after the one for Chai itself, then it will automatically plug
-in to Chai and be ready for use. Note that you'll want to get the latest browser build of Sinon.JS as well:
-
-```html
-<script src="chai.js"></script>
-<script src="sinon-chai.js"></script>
-<script src="sinon.js"></script>
-```
-
-### Ruby on Rails
-
-Thanks to [Cymen Vig][], there's now [a Ruby gem][] of Sinon–Chai that integrates it with the Rails asset pipeline!
-
+Casper–Chai supports being used as an [AMD][] module, registering itself
+anonymously (just like Chai). So, assuming you have configured your loader to
+map the Chai and Casper–Chai files to the respective module IDs `"chai"` and
+`"casper-chai"`, you can use them as follows:
-[Sinon.JS]: http://sinonjs.org/
+[CasperJS]: http://casperjs.org/
[Chai]: http://chaijs.com/
-[spymethods]: http://sinonjs.org/docs/#spies-api
[Mocha]: http://visionmedia.github.com/mocha/
-[fixturedemo]: https://github.com/domenic/sinon-chai/tree/master/test/
[AMD]: https://github.com/amdjs/amdjs-api/wiki/AMD
-[Cymen Vig]: https://github.com/cymen
-[a Ruby gem]: https://github.com/cymen/sinon-chai-rails
View
@@ -0,0 +1,35 @@
+
+// -- from: lib/casper-chai.coffee -- \\
+
+/*
+Chai assertions for CasperJS
+
+Copyright (C) 2012 Brian M Hunt
+
+ Repository: http://github.com/brianmhunt/casper-chai.git
+ License: MIT (see LICENSE.txt)
+*/
+
+
+(function() {
+ var casperChai;
+
+ casperChai = function(_chai, utils) {
+ return _chai.Assertion.addProperty('inDOM', function() {
+ var selector;
+ selector = this._obj;
+ return this.assert(casper.exists(selector), 'expected selector #{this} to be in the DOM', 'expected selector #{this} to not be in the DOM');
+ });
+ };
+
+ if (typeof require === "function" && typeof exports === "object" && typeof module === "object") {
+ module.exports = casperChai;
+ } else if (typeof define === "function" && define.amd) {
+ define(function() {
+ return casperChai;
+ });
+ } else {
+ chai.use(casperChai);
+ }
+
+}).call(this);
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit e25d910

Please sign in to comment.