README.rdoc in visionmedia-jspec-1.1.3 vs README.rdoc in visionmedia-jspec-1.1.4

- old
+ new

@@ -6,27 +6,36 @@ to core prototypes, async request support, and incredibly sexy syntax, tons of matchers and much more. == Features -* Sexiest syntax of them all +* Highly readable * Framework / DOM independent +* Rhino support +* Async support +* Ruby JavaScript testing server * Nested describes * Does not pollute core object prototypes -* Async support * Extremely simple and intuitive matcher declaration * Over 45 core matchers * Allows parens to be optional when using matchers to increase readability -* Several helpful formatters (dom, console, terminal, ...) +* Several helpful formatters (DOM, Console, Terminal, ...) * Assertion graphs displaying how many, and which assertions pass or failed * Default / customizable evaluation contexts * DOM sandbox support * Great looking default DOM theme * `jspec` command-line utility for auto-running specs, and initializing project templates * Profiling * Tiny (15 kb compressed, 1000-ish LOC) +== Features Coming Soon + +* 'Spy' or 'Proxy' assertions. person.should.receive('addPet').with('suki').and_return(['suki']) +* Grammar-less option. Dislike JSpec's grammar? well we will soon have grammar-less support, + which in turn will make your specs look much like traditional JavaScript BDD frameworks: + expect(this).to('be_coming', 'soon') + == Example describe 'ShoppingCart' var cart @@ -52,12 +61,12 @@ == Installation Simply download JSpec and include JSpec.css and JSpec.js in your markup. Head over to the downloads section on Github, clone this public repo, or add JSpec as a git submodule with in your project. Alternatively JSpec is -also available as a Ruby Gem, which also provides the `jspec` executable. To -install as a gem simply: +also available as a Ruby Gem (though this is not required), which also +provides the `jspec` executable. To install as a gem simply: $ sudo gem install visionmedia-jspec At which point you may: $ jspec init myproject @@ -68,11 +77,11 @@ <script> function runSuites() { JSpec .exec('spec.core.js') .exec('spec.jquery.js') - .run() + .run({ failuresOnly : true }) .report() } </script> <body onLoad="runSuites()"> ... @@ -82,48 +91,49 @@ each release. == Options You may alter the way JSpec operates by assigning options via the -JSpec.options hash, or by passing string-based option values via the -query string. For example JSpec.options.failuresOnly = true, and ?failuresOnly=1 -will both work. +JSpec.options hash, by passing string-based option values via the +query string, or passing a hash to run(). For example +JSpec.options.failuresOnly = true, and ?failuresOnly=1 will both work. -* profile {bool} when enabled, uses console.time() in order to display performance information in your console log as specs are completed. -* failuresOnly {bool} displays only failing specs, making them quick to discover and fix -* reportToId {string} an element id to report to when using the DOM formatter +* profile {bool} when enabled, uses console.time() in order to display performance information in your console log as specs are completed. (DOM, Console) +* failuresOnly {bool} displays only failing specs, making them quick to discover and fix (DOM, Terminal) +* reportToId {string} an element id to report to when using the DOM formatter (DOM) == Matchers * Core - - equal === - - be_a, be_an have constructor of x - - be_at_least >= - - be_at_most <= - - be_null == null - - be_empty length of 0 - - be_true == true - - be_false == false - - be_type be type of x - - be_greater_than > - - be_less_than < - - throw_error should throw an error, optionally supply the error string for comparison - - have object should have n of property (person.should.have(2, 'pets')) - - have_at_least object should have at least n of property - - have_at_most object should have a maximum n of property - - have_within object should have within n..n of property (person.should.have_within(1..3, 'pets') - - have_length length of n - - have_prop object should have property x, optionally supplying an expected value - - have_property strict version of have_prop - - be_within checks if n is within the range passed - - include include substring, array element, or hash key - - match string should match regexp x - - respond_to property x should be a function - - eql, be matches simple literals (strings, numbers) with == . - However composites like arrays or 'hashes' are recursively matched, - meaning that [1, 2, [3]].should_eql([1, 2, [3]]) will be true. + - equal, be === + - be_a, be_an have constructor of x + - be_an_instance_of instanceof x + - be_at_least >= + - be_at_most <= + - be_null == null + - be_empty length of 0 + - be_true == true + - be_false == false + - be_type be type of x + - be_greater_than > + - be_less_than < + - throw_error should throw an error, optionally supply the error string for comparison + - have object should have n of property (person.should.have(2, 'pets')) + - have_at_least object should have at least n of property + - have_at_most object should have a maximum n of property + - have_within object should have within n..n of property (person.should.have_within(1..3, 'pets') + - have_length length of n + - have_prop object should have property x, optionally supplying an expected value + - have_property strict version of have_prop + - be_within checks if n is within the range passed + - include include substring, array element, or hash key + - match string should match regexp x + - respond_to property x should be a function + - eql matches simple literals (strings, numbers) with == + However composites like arrays or 'hashes' are recursively matched, + meaning that [1, 2, [3]].should_eql([1, 2, [3]]) will be true. * jQuery - have_tag, have_one have exactly one tag - have_tags, have_many have more than one tag @@ -292,26 +302,21 @@ ... == Formatters To change a formatter simply alter the options hash like below, assigning -a new constructor: +a new constructor, or pass it within the hash to run(): JSpec.options.formatter = JSpec.formatters.Console -=== DOM - -Clean attractive HTML reporting +OR -=== Console + JSpec + .exec('...') + .run({ formatter : JSpec.formatters.Terminal }) + .report() -Reporting utilizing the console object (tested using Firebug and Safari 4) - -=== Terminal - -Coming soon - == Custom Matchers First lets create a simple equality matcher. In the case below JSpec is smart enough to realize this is simply a binary operator, and simply transforms this into 'actual === expected' @@ -374,16 +379,55 @@ $ jspec help Or for specific usage: $ jspec help run +== Rhino + +JSpec provides transparent support for Rhino, while using the Terminal formatter. +Simply create a JavaScript file with contents similar to below, and then execute +the command following it: + + load('lib/jspec.js') + + JSpec + .exec('spec/spec.grammar.js') + .exec('spec/spec.core.js') + .run({ formatter : JSpec.formatters.Terminal, failuresOnly : true }) + .report() + +Initialize project with: + $ jspec init myproject --template rhino + +Run with: + $ jspec run --rhino + +Or bind (automated testing): + $ jspec --rhino + +== Server + +The Ruby JavaScript testing server included with JSpec simply runs +the spec suites within each browser you specify, while reporting result +back to the terminal. It is essentially the same as using the DOM formatter +and auto-testing each browser, however results are centralized to the terminal, +removing the need to manually view each browser's output. + +Initialize project with: + $ jspec init myproject --template server + +Run with: + $ jspec run --server + == More Information * Syntax comparison with other frameworks http://gist.github.com/92283 - * Get the TextMate bundle at https://github.com/visionmedia/jspec.tmbundle/tree - * For more information consult the JSpec source code documentation or visit http://visionmedia.github.com/jspec + +== Known Issues + +* Opera likes to break for various reasons ... we are working on fixing these compat issues == License (The MIT License)