mocha_rails 0.0.2 → 0.0.3
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
@@ -10,7 +10,7 @@ It loads [Chai](http://chaijs.com) for assertions, although since Mocha is decou
|
|
10
10
|
use another assertion library if you choose (or even write your own.)
|
11
11
|
|
12
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,
|
13
|
+
"BDD" interface, but if you want to write in one of the other styles, please "+1" the open issue to make it configurable.
|
14
14
|
|
15
15
|
## Installation
|
16
16
|
|
@@ -21,39 +21,42 @@ group :test, :development do
|
|
21
21
|
gem 'mocha_rails'
|
22
22
|
end
|
23
23
|
```
|
24
|
+
MochaRails includes a convenient install generator that adds a route to `config/routes.rb` and adds a `mocha-suite.js`
|
25
|
+
Sprockets manifest file to either `spec/javascripts` or `test/javascripts`.
|
24
26
|
|
25
|
-
|
26
|
-
|
27
|
-
To access your Mocha test suite at `/mocha`, **you must add** the following line inside your Rails `config/routes.rb`,
|
28
|
-
within the block passed to `draw`.
|
27
|
+
To install the required configuration, **you must run**:
|
29
28
|
|
30
29
|
```
|
31
|
-
|
30
|
+
rails g mocha_rails:install
|
32
31
|
```
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
## Adding Mocha Tests
|
33
|
+
The generator has a single option, `--mount`, which lets you specify the route to your test suite. The default
|
34
|
+
route is `/mocha`.
|
38
35
|
|
39
|
-
|
40
|
-
one of these locations:
|
36
|
+
## Organizing your test files
|
41
37
|
|
42
|
-
|
38
|
+
Sprockets will not load two files with the same relative asset path and base name, even if they are located in different directories, such
|
39
|
+
as `app/assets/javascripts/example.js` and `test/javascripts/example.js.coffee`. In this example, the test file will
|
40
|
+
**not** be loaded.
|
43
41
|
|
44
|
-
|
42
|
+
One solution is to simply give your test files a different name, for example in `test/javascripts/mocha-suite.js`:
|
45
43
|
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
```
|
45
|
+
//= require example
|
46
|
+
//= require example-test
|
47
|
+
```
|
49
48
|
|
50
|
-
|
49
|
+
However, if you prefer to give your test files the same name as your production files, you must then use a different path:
|
51
50
|
|
52
51
|
```
|
53
|
-
|
52
|
+
//= require example
|
53
|
+
//= require test/example
|
54
54
|
```
|
55
55
|
|
56
|
-
|
56
|
+
## Adding a test
|
57
|
+
|
58
|
+
To get you started, here is a sample Mocha test with a should style assertion, to be placed in a file
|
59
|
+
`test/javascripts/array-test.js.coffee`:
|
57
60
|
|
58
61
|
```
|
59
62
|
describe 'Array', ->
|
@@ -67,7 +70,9 @@ describe 'Array', ->
|
|
67
70
|
@array.indexOf(4).should.equal -1
|
68
71
|
```
|
69
72
|
|
70
|
-
|
73
|
+
## Running
|
74
|
+
|
75
|
+
Start your server, and open `http://localhost:3000/mocha`. You should see Mocha's very attractive results page. If you
|
71
76
|
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.
|
72
77
|
|
73
78
|
## Credits
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module MochaRails
|
2
|
+
class InstallGenerator < Rails::Generators::Base
|
3
|
+
source_root File.expand_path("../templates", __FILE__)
|
4
|
+
|
5
|
+
class_option :mount, :aliases => '-m', :type => :string, :default => 'mocha', :desc => 'mounts engine at specified MOUNT route'
|
6
|
+
|
7
|
+
desc 'installs mocha_rails into your application'
|
8
|
+
def install
|
9
|
+
route "mount MochaRails::Engine => '#{options[:mount]}' unless Rails.env.production?"
|
10
|
+
|
11
|
+
test_dir = Dir.exists?(Rails.root.join "spec") ? "spec" : "test"
|
12
|
+
copy_file 'mocha-suite.js', "#{test_dir}/javascripts/mocha-suite.js"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require_tree .
|
data/lib/mocha_rails/version.rb
CHANGED
metadata
CHANGED
@@ -1,35 +1,49 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: mocha_rails
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 0
|
8
|
+
- 3
|
9
|
+
segments_generated: true
|
10
|
+
version: 0.0.3
|
6
11
|
platform: ruby
|
7
|
-
authors:
|
12
|
+
authors:
|
8
13
|
- Chris smith
|
9
14
|
autorequire:
|
10
15
|
bindir: bin
|
11
16
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
17
|
+
|
18
|
+
date: 2012-02-11 00:00:00 -07:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
15
22
|
name: rails
|
16
|
-
requirement: &
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
24
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
segments:
|
29
|
+
- 3
|
30
|
+
- 1
|
31
|
+
- 0
|
32
|
+
segments_generated: true
|
21
33
|
version: 3.1.0
|
22
34
|
type: :runtime
|
23
35
|
prerelease: false
|
24
|
-
version_requirements: *
|
25
|
-
description: MochaRails is a mountable Rails engine that serves a browser-based Mocha
|
26
|
-
|
27
|
-
email:
|
36
|
+
version_requirements: *id001
|
37
|
+
description: MochaRails is a mountable Rails engine that serves a browser-based Mocha test suite, along with your production JavaScript files, via the Asset Pipeline.
|
38
|
+
email:
|
28
39
|
- quartzmo@gmail.com
|
29
40
|
executables: []
|
41
|
+
|
30
42
|
extensions: []
|
43
|
+
|
31
44
|
extra_rdoc_files: []
|
32
|
-
|
45
|
+
|
46
|
+
files:
|
33
47
|
- app/assets/javascripts/mocha_rails/application.js
|
34
48
|
- app/assets/javascripts/mocha_rails/mocha-rails.js
|
35
49
|
- app/assets/stylesheets/mocha_rails/application.css
|
@@ -39,6 +53,8 @@ files:
|
|
39
53
|
- app/views/mocha_rails/tests/index.html.erb
|
40
54
|
- config/initializers/mocha_rails.rb
|
41
55
|
- config/routes.rb
|
56
|
+
- lib/generators/mocha_rails/install_generator.rb
|
57
|
+
- lib/generators/mocha_rails/templates/mocha-suite.js
|
42
58
|
- lib/mocha_rails/engine.rb
|
43
59
|
- lib/mocha_rails/version.rb
|
44
60
|
- lib/mocha_rails.rb
|
@@ -80,38 +96,43 @@ files:
|
|
80
96
|
- test/integration/navigation_test.rb
|
81
97
|
- test/mocha_rails_test.rb
|
82
98
|
- test/test_helper.rb
|
99
|
+
has_rdoc: true
|
83
100
|
homepage: https://github.com/quartzmo/mocha_rails
|
84
101
|
licenses: []
|
102
|
+
|
85
103
|
post_install_message:
|
86
104
|
rdoc_options: []
|
87
|
-
|
105
|
+
|
106
|
+
require_paths:
|
88
107
|
- lib
|
89
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
108
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
90
109
|
none: false
|
91
|
-
requirements:
|
92
|
-
- -
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
|
95
|
-
segments:
|
110
|
+
requirements:
|
111
|
+
- - ">="
|
112
|
+
- !ruby/object:Gem::Version
|
113
|
+
hash: 3955539576298480198
|
114
|
+
segments:
|
96
115
|
- 0
|
97
|
-
|
98
|
-
|
116
|
+
segments_generated: true
|
117
|
+
version: "0"
|
118
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
99
119
|
none: false
|
100
|
-
requirements:
|
101
|
-
- -
|
102
|
-
- !ruby/object:Gem::Version
|
103
|
-
|
104
|
-
segments:
|
120
|
+
requirements:
|
121
|
+
- - ">="
|
122
|
+
- !ruby/object:Gem::Version
|
123
|
+
hash: 3955539576298480198
|
124
|
+
segments:
|
105
125
|
- 0
|
106
|
-
|
126
|
+
segments_generated: true
|
127
|
+
version: "0"
|
107
128
|
requirements: []
|
129
|
+
|
108
130
|
rubyforge_project:
|
109
|
-
rubygems_version: 1.
|
131
|
+
rubygems_version: 1.3.7
|
110
132
|
signing_key:
|
111
133
|
specification_version: 3
|
112
|
-
summary: Integrates the Mocha JavaScript test framework with the Rails (>= 3.1) Asset
|
113
|
-
|
114
|
-
test_files:
|
134
|
+
summary: Integrates the Mocha JavaScript test framework with the Rails (>= 3.1) Asset Pipeline.
|
135
|
+
test_files:
|
115
136
|
- test/dummy/app/assets/javascripts/application.js
|
116
137
|
- test/dummy/app/assets/stylesheets/application.css
|
117
138
|
- test/dummy/app/controllers/application_controller.rb
|