qunit-rails 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gems +1 -0
- data/CHANGELOG.md +8 -0
- data/README.md +69 -60
- data/UNLICENSE +24 -0
- data/app/controllers/qunit/rails/test_controller.rb +1 -4
- data/config/initializers/qunit-rails.rb +5 -1
- data/config/routes.rb +6 -3
- data/{vendor → lib}/assets/javascripts/qunit.js +1274 -1276
- data/{vendor → lib}/assets/stylesheets/qunit.css +7 -6
- data/lib/generators/qunit/install_generator.rb +32 -14
- data/lib/qunit/rails/engine.rb +7 -2
- data/lib/qunit-rails.rb +1 -6
- data/qunit-rails.gemspec +13 -18
- metadata +21 -27
- data/.gitignore +0 -7
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -61
- data/LICENSE.md +0 -22
- data/Rakefile +0 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d36a6e67173926358fa5107d450736b5ed487815
|
4
|
+
data.tar.gz: 87d91289641cae10ae0fe5a7bc4d008fd73eaa7a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b477bdc7f8552f9d2b2921af4d92ae02c4b408deb489a3ec1c9136bd7298894ba13e14b0b683feb81b0d214521fa5dc706b709c48fdc0cfbc11ce6226fc6e973
|
7
|
+
data.tar.gz: ad353fc122858d4d3fc6ebb45515ae251d482cf5d773473d50a9f4afa63f07f2f43fd19f57ef880ce23a47c09df42885afd3b1364975c3e33aa7a250c23b2741
|
data/.gems
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
railties -v 3.2.16
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,8 @@
|
|
1
|
+
0.0.5
|
2
|
+
-----
|
3
|
+
|
4
|
+
* Add custom name support for test folders.
|
5
|
+
|
6
|
+
* Use `get` instead of `match` in the routes. PR [#17](https://github.com/frodsan/qunit-rails/pull/17).
|
7
|
+
|
8
|
+
* Update routes to not remount if previously mounted. PR [#16](https://github.com/frodsan/qunit-rails/pull/16).
|
data/README.md
CHANGED
@@ -3,25 +3,19 @@ QUnit on Rails
|
|
3
3
|
|
4
4
|
QUnit JavaScript Unit Testing framework for Rails.
|
5
5
|
|
6
|
-
Requirements
|
7
|
-
------------
|
8
|
-
|
9
|
-
* Ruby 1.9.x
|
10
|
-
* Rails 3.2+
|
11
|
-
|
12
6
|
Getting Started
|
13
7
|
---------------
|
14
8
|
|
15
9
|
QUnit on Rails works with Rails 3.2. You can add it to your Gemfile with:
|
16
10
|
|
17
|
-
|
18
|
-
|
19
|
-
|
11
|
+
```ruby
|
12
|
+
group :development, :test do
|
13
|
+
gem "qunit-rails"
|
14
|
+
end
|
15
|
+
```
|
20
16
|
|
21
|
-
Run the bundle command to install it.
|
22
|
-
|
23
|
-
**The engine is automatically mounted into your application in the development
|
24
|
-
and test environments.**
|
17
|
+
Run the bundle command to install it. The engine is automatically mounted
|
18
|
+
into your application in the development and test environments.
|
25
19
|
|
26
20
|
After you install it and add it to your Gemfile, you need to run the install
|
27
21
|
generator:
|
@@ -34,21 +28,41 @@ your `test` folder:
|
|
34
28
|
test/javascripts/test_helper.js
|
35
29
|
test/stylesheets/test_helper.css
|
36
30
|
|
37
|
-
If you
|
31
|
+
If you want to specify a custom folder name for the tests and the test helpers,
|
32
|
+
you'll need to change the `qunit.tests_path` option in `config/environments/development.rb`
|
33
|
+
file:
|
34
|
+
|
35
|
+
```ruby
|
36
|
+
App::Application.configure do
|
37
|
+
...
|
38
|
+
|
39
|
+
config.qunit.tests_path = "spec"
|
40
|
+
end
|
41
|
+
```
|
42
|
+
|
43
|
+
Then, this is the result if you run `rails g qunit:install`:
|
44
|
+
|
45
|
+
spec/javascripts/test_helper.js
|
46
|
+
spec/stylesheets/test_helper.js
|
47
|
+
|
48
|
+
If you prefer CoffeeScript, you can run:
|
38
49
|
|
39
|
-
rails g qunit:install -
|
50
|
+
rails g qunit:install -j coffee
|
40
51
|
|
41
52
|
This will generate a `test_helper.coffee` file instead of `test_helper.js`.
|
42
53
|
|
43
|
-
|
54
|
+
Usage
|
55
|
+
-----
|
44
56
|
|
45
57
|
### JavaScript/CoffeeScript Tests
|
46
58
|
|
47
59
|
The `test/javascripts/test_helper.js` file has the following content:
|
48
60
|
|
49
|
-
|
50
|
-
|
51
|
-
|
61
|
+
```javascript
|
62
|
+
//= require application
|
63
|
+
//= require_tree .
|
64
|
+
//= require_self
|
65
|
+
```
|
52
66
|
|
53
67
|
This loads all the javascripts defined in `app/assets/javascripts/application.js`.
|
54
68
|
Also, this pulls in all your test files from the `javascripts` folder into
|
@@ -61,11 +75,13 @@ Also, this pulls in all your test files from the `javascripts` folder into
|
|
61
75
|
|
62
76
|
Here's an example `test/javascripts/foo_test.js`:
|
63
77
|
|
64
|
-
|
65
|
-
|
78
|
+
```javascript
|
79
|
+
test("Foo always says the truth", function() {
|
80
|
+
foo = new Foo();
|
66
81
|
|
67
|
-
|
68
|
-
|
82
|
+
equal(foo.truth, true, "foo.truth is not true");
|
83
|
+
});
|
84
|
+
```
|
69
85
|
|
70
86
|
If you're not comfortable with loading all the javascript defined in the
|
71
87
|
`application.js` manifest file, you can delete `//= require application`
|
@@ -74,42 +90,49 @@ and use the `require` dependency mechanism in your tests to pull the dependencie
|
|
74
90
|
|
75
91
|
Here's an example `test/javascripts/foo_test.js`:
|
76
92
|
|
77
|
-
|
93
|
+
```javascript
|
94
|
+
//= require foo
|
78
95
|
|
79
|
-
|
80
|
-
|
96
|
+
test("Foo always says the truth", function() {
|
97
|
+
foo = new Foo();
|
81
98
|
|
82
|
-
|
83
|
-
|
99
|
+
equal(foo.truth, true, "foo.truth is not true");
|
100
|
+
});
|
101
|
+
```
|
84
102
|
|
85
103
|
### Stylesheets
|
86
104
|
|
87
|
-
For including stylesheets in your tests,
|
88
|
-
`test/javascripts/test_helper.css`. Use [Sprockets]
|
105
|
+
For including stylesheets in your tests, It uses
|
106
|
+
`test/javascripts/test_helper.css`. Use [Sprockets][sprockets]
|
89
107
|
directives to include the right css files:
|
90
108
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
109
|
+
```css
|
110
|
+
/*
|
111
|
+
*= require application
|
112
|
+
*= require_tree .
|
113
|
+
*/
|
114
|
+
```
|
95
115
|
|
96
|
-
###
|
116
|
+
### Overriding `index.html`
|
97
117
|
|
98
118
|
You can set your own custom Test Runner, by overriding
|
99
119
|
the default `index.html.erb`. Create a new file in
|
100
120
|
`app/views/qunit/rails/test/index.html.erb` and edit it
|
101
121
|
whichever you prefer:
|
102
122
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
123
|
+
```html
|
124
|
+
<html>
|
125
|
+
<head>
|
126
|
+
<title>My Custom Test Runner</title>
|
127
|
+
</head>
|
128
|
+
<body>
|
129
|
+
<h1>My Custom Test Runner</h1>
|
130
|
+
</body>
|
131
|
+
</html>
|
132
|
+
```
|
111
133
|
|
112
|
-
|
134
|
+
Run Tests
|
135
|
+
---------
|
113
136
|
|
114
137
|
### Start server
|
115
138
|
|
@@ -117,20 +140,6 @@ Start the server to run the tests:
|
|
117
140
|
|
118
141
|
rails s
|
119
142
|
|
120
|
-
Go to
|
121
|
-
|
122
|
-
### From the CLI
|
123
|
-
|
124
|
-
[Eventually](/)
|
125
|
-
|
126
|
-
### Autotest
|
127
|
-
|
128
|
-
[Eventually](/)
|
129
|
-
|
130
|
-
## What's next?
|
131
|
-
|
132
|
-
Profit.
|
133
|
-
|
134
|
-
## License
|
143
|
+
Go to <http://localhost:3000/qunit> to see the QUnit Test Runner.
|
135
144
|
|
136
|
-
|
145
|
+
[sprockets]: https://github.com/sstephenson/sprockets)
|
data/UNLICENSE
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
This is free and unencumbered software released into the public domain.
|
2
|
+
|
3
|
+
Anyone is free to copy, modify, publish, use, compile, sell, or
|
4
|
+
distribute this software, either in source code form or as a compiled
|
5
|
+
binary, for any purpose, commercial or non-commercial, and by any
|
6
|
+
means.
|
7
|
+
|
8
|
+
In jurisdictions that recognize copyright laws, the author or authors
|
9
|
+
of this software dedicate any and all copyright interest in the
|
10
|
+
software to the public domain. We make this dedication for the benefit
|
11
|
+
of the public at large and to the detriment of our heirs and
|
12
|
+
successors. We intend this dedication to be an overt act of
|
13
|
+
relinquishment in perpetuity of all present and future rights to this
|
14
|
+
software under copyright law.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
20
|
+
OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
21
|
+
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
22
|
+
OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
For more information, please refer to <http://unlicense.org/>
|
@@ -1 +1,5 @@
|
|
1
|
-
Rails.application.config.
|
1
|
+
qunit = Rails.application.config.qunit
|
2
|
+
javascripts_path = Rails.root.join(qunit.tests_path, qunit.javascripts_path)
|
3
|
+
stylesheets_path = Rails.root.join(qunit.tests_path, qunit.stylesheets_path)
|
4
|
+
|
5
|
+
Rails.application.config.assets.paths << javascripts_path << stylesheets_path
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
|
-
|
2
|
-
root to:
|
1
|
+
QUnit::Rails::Engine.routes.draw do
|
2
|
+
root to: "test#index"
|
3
|
+
get ":action", controller: "test"
|
3
4
|
end
|
4
5
|
|
5
6
|
Rails.application.routes.draw do
|
6
|
-
|
7
|
+
unless Rails.application.routes.named_routes.routes[:qunit_rails]
|
8
|
+
mount QUnit::Rails::Engine => "/qunit"
|
9
|
+
end
|
7
10
|
end
|