mocha_rails 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/Readme.md
CHANGED
@@ -6,13 +6,15 @@ MochaRails integrates the [Mocha](http://visionmedia.github.com/mocha/) JavaScri
|
|
6
6
|
|
7
7
|
MochaRails is a mountable Rails engine that serves a browser-based Mocha test suite, along with your production JavaScript files, via the Asset Pipeline.
|
8
8
|
|
9
|
-
It loads [
|
10
|
-
use another if you choose
|
11
|
-
|
9
|
+
It loads [Chai](http://chaijs.com) for assertions, although since Mocha is decoupled from the assertion library, you can
|
10
|
+
use another assertion library if you choose (or even write your own.)
|
11
|
+
|
12
|
+
The Mocha interface system allows developers to choose their style of DSL. MochaRails is hardcoded for now to the
|
13
|
+
"BDD" interface, but if you want to write in one of the other styles, open an issue and I will make it configurable.
|
12
14
|
|
13
15
|
## Installation
|
14
16
|
|
15
|
-
In your Rails >= 3.1 app, add
|
17
|
+
In your Rails >= 3.1 app, **you must add** `gem 'mocha_rails'` to your `Gemfile`:
|
16
18
|
|
17
19
|
```
|
18
20
|
group :test, :development do
|
@@ -22,23 +24,25 @@ end
|
|
22
24
|
|
23
25
|
## Configuration
|
24
26
|
|
25
|
-
To access your Mocha test suite at `/mocha`, add the following line inside your Rails `config/routes.rb`,
|
27
|
+
To access your Mocha test suite at `/mocha`, **you must add** the following line inside your Rails `config/routes.rb`,
|
26
28
|
within the block passed to `draw`.
|
27
29
|
|
28
30
|
```
|
29
31
|
mount MochaRails::Engine => "mocha" unless Rails.env.production?
|
30
32
|
```
|
31
33
|
|
32
|
-
There is nothing special about the path `/mocha`, and you can
|
34
|
+
There is nothing special about the path `/mocha`, and you can name any path you like,
|
33
35
|
as long as it doesn't conflict with any of your existing application paths.
|
34
36
|
|
35
37
|
## Adding Mocha Tests
|
36
38
|
|
37
|
-
You must create a `mocha-suite.js` or `mocha-suite.js.coffee` Sprockets manifest file in
|
39
|
+
**You must create** a `mocha-suite.js` or `mocha-suite.js.coffee` Sprockets manifest file in
|
38
40
|
one of these locations:
|
39
41
|
|
40
42
|
* `test/javascripts`
|
43
|
+
|
41
44
|
or
|
45
|
+
|
42
46
|
* `spec/javascripts`
|
43
47
|
|
44
48
|
This directory is also the location for your Mocha tests.
|
@@ -46,33 +50,32 @@ This directory is also the location for your Mocha tests.
|
|
46
50
|
Here is a sample `mocha-suite.js.coffee` manifest:
|
47
51
|
|
48
52
|
```
|
49
|
-
#= require jquery
|
50
53
|
#= require_tree .
|
51
54
|
```
|
52
55
|
|
53
|
-
Here is a sample Mocha test including
|
56
|
+
Here is a sample Mocha test including a should assertion, in a file `array-test.js.coffee` located in the same directory or below:
|
54
57
|
|
55
58
|
```
|
56
59
|
describe 'Array', ->
|
57
|
-
array = null
|
58
60
|
|
59
|
-
|
60
|
-
array = [1,2,3]
|
61
|
+
beforeEach ->
|
62
|
+
@array = [1,2,3]
|
61
63
|
|
62
64
|
describe '#indexOf()', ->
|
63
65
|
|
64
66
|
it 'should return -1 when not present', ->
|
65
|
-
|
67
|
+
@array.indexOf(4).should.equal -1
|
66
68
|
```
|
67
69
|
|
68
|
-
|
70
|
+
Create these files, start your server, and open `http://localhost:3000/mocha`. You should see Mocha's very attractive results page. If you
|
71
|
+
see a completely blank page, or an almost blank page with a few zeros in the upper right corner, check your JavaScript console for errors.
|
69
72
|
|
70
73
|
## Credits
|
71
74
|
|
72
|
-
* Chris Smith
|
75
|
+
* Chris Smith (quartzmo)
|
73
76
|
|
74
77
|
MochaRails was inspired by the design of [Jasminerice](https://github.com/bradphelan/jasminerice).
|
75
78
|
|
76
79
|
## License
|
77
80
|
|
78
|
-
MIT-LICENSE
|
81
|
+
MIT-LICENSE
|
data/lib/mocha_rails/version.rb
CHANGED