qunit-rails 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/Gemfile +2 -0
- data/Gemfile.lock +61 -0
- data/MIT-LICENSE +20 -0
- data/README.md +107 -0
- data/Rakefile +2 -0
- data/app/controllers/qunit/rails/application_controller.rb +6 -0
- data/app/controllers/qunit/rails/test_controller.rb +10 -0
- data/app/views/qunit/rails/test/index.html.erb +13 -0
- data/config/initializers/qunitizer.rb +1 -0
- data/config/routes.rb +7 -0
- data/lib/assets/javascripts/qunit.js +1669 -0
- data/lib/assets/stylesheets/qunit.css +235 -0
- data/lib/generators/qunit/install_generator.rb +16 -0
- data/lib/generators/templates/test_helper.css +4 -0
- data/lib/generators/templates/test_helper.js +2 -0
- data/lib/qunit/rails/engine.rb +7 -0
- data/lib/qunit/rails/version.rb +5 -0
- data/lib/qunit-rails.rb +6 -0
- data/qunit-rails.gemspec +17 -0
- metadata +81 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
qunit-rails (0.0.1)
|
5
|
+
railties (~> 3.2.3)
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
actionpack (3.2.3)
|
11
|
+
activemodel (= 3.2.3)
|
12
|
+
activesupport (= 3.2.3)
|
13
|
+
builder (~> 3.0.0)
|
14
|
+
erubis (~> 2.7.0)
|
15
|
+
journey (~> 1.0.1)
|
16
|
+
rack (~> 1.4.0)
|
17
|
+
rack-cache (~> 1.2)
|
18
|
+
rack-test (~> 0.6.1)
|
19
|
+
sprockets (~> 2.1.2)
|
20
|
+
activemodel (3.2.3)
|
21
|
+
activesupport (= 3.2.3)
|
22
|
+
builder (~> 3.0.0)
|
23
|
+
activesupport (3.2.3)
|
24
|
+
i18n (~> 0.6)
|
25
|
+
multi_json (~> 1.0)
|
26
|
+
builder (3.0.0)
|
27
|
+
erubis (2.7.0)
|
28
|
+
hike (1.2.1)
|
29
|
+
i18n (0.6.0)
|
30
|
+
journey (1.0.3)
|
31
|
+
json (1.7.3)
|
32
|
+
multi_json (1.3.5)
|
33
|
+
rack (1.4.1)
|
34
|
+
rack-cache (1.2)
|
35
|
+
rack (>= 0.4)
|
36
|
+
rack-ssl (1.3.2)
|
37
|
+
rack
|
38
|
+
rack-test (0.6.1)
|
39
|
+
rack (>= 1.0)
|
40
|
+
railties (3.2.3)
|
41
|
+
actionpack (= 3.2.3)
|
42
|
+
activesupport (= 3.2.3)
|
43
|
+
rack-ssl (~> 1.3.2)
|
44
|
+
rake (>= 0.8.7)
|
45
|
+
rdoc (~> 3.4)
|
46
|
+
thor (~> 0.14.6)
|
47
|
+
rake (0.9.2.2)
|
48
|
+
rdoc (3.12)
|
49
|
+
json (~> 1.4)
|
50
|
+
sprockets (2.1.3)
|
51
|
+
hike (~> 1.2)
|
52
|
+
rack (~> 1.0)
|
53
|
+
tilt (~> 1.1, != 1.3.0)
|
54
|
+
thor (0.14.6)
|
55
|
+
tilt (1.3.3)
|
56
|
+
|
57
|
+
PLATFORMS
|
58
|
+
ruby
|
59
|
+
|
60
|
+
DEPENDENCIES
|
61
|
+
qunit-rails!
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2012 Francesco Rodriguez
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
# QUnit on Rails
|
2
|
+
|
3
|
+
QUnit JavaScript Unit Testing framework for Rails.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
* Ruby 1.9.x
|
8
|
+
* Rails 3.2+
|
9
|
+
|
10
|
+
## Getting Started
|
11
|
+
|
12
|
+
QUnit on Rails works with Rails 3.2. You can add it to your Gemfile with:
|
13
|
+
|
14
|
+
group :development, :test do
|
15
|
+
gem 'qunit-rails'
|
16
|
+
end
|
17
|
+
|
18
|
+
Run the bundle command to install it.
|
19
|
+
|
20
|
+
**The engine is automatically mounted into your application in the development
|
21
|
+
and test environments.**
|
22
|
+
|
23
|
+
After you install it and add it to your Gemfile, you need to run the install
|
24
|
+
generator:
|
25
|
+
|
26
|
+
rails g qunit:install
|
27
|
+
|
28
|
+
The generator will create two directories with two files inside your `test` folder:
|
29
|
+
|
30
|
+
test/javascripts/test_helper.js
|
31
|
+
test/stylesheets/test_helper.css
|
32
|
+
|
33
|
+
## Usage
|
34
|
+
|
35
|
+
### JavaScripts
|
36
|
+
|
37
|
+
The file `test/javascripts/test_helper.js` has the following content:
|
38
|
+
|
39
|
+
//= require application
|
40
|
+
//= require_tree .
|
41
|
+
|
42
|
+
This loads all the javascripts defined in `app/assets/javascripts/application.js`.
|
43
|
+
Also, this pulls in all your test files from the `javascripts` folder into
|
44
|
+
*QUnit-Rails*:
|
45
|
+
|
46
|
+
test/javascripts/*_test.js
|
47
|
+
test/javascripts/*_test.js.coffee
|
48
|
+
test/javascripts/*_test.js.erb
|
49
|
+
|
50
|
+
Here's an example `test/javascripts/foo_test.js`:
|
51
|
+
|
52
|
+
test('Foo always says the truth', function() {
|
53
|
+
foo = new Foo();
|
54
|
+
|
55
|
+
equal(foo.truth, true, 'foo.truth is not true');
|
56
|
+
});
|
57
|
+
|
58
|
+
If you're not comfortable with loading all the javascript defined in the
|
59
|
+
`application.js` manifest file, you can delete `//= require application`
|
60
|
+
from the `test_helper.js` file and use the `require` dependency mechanism
|
61
|
+
in your tests to pull the dependencies. Here's an example
|
62
|
+
`test/javascripts/foo_test.js`:
|
63
|
+
|
64
|
+
//= require foo
|
65
|
+
|
66
|
+
test('Foo always says the truth', function() {
|
67
|
+
foo = new Foo();
|
68
|
+
|
69
|
+
equal(foo.truth, true, 'foo.truth is not true');
|
70
|
+
});
|
71
|
+
|
72
|
+
### Stylesheets
|
73
|
+
|
74
|
+
For including stylesheets in your tests, *QUnit-Rails* uses
|
75
|
+
`test/javascripts/test_helper.css`. Use [Sprockets](https://github.com/sstephenson/sprockets)
|
76
|
+
directives to include the right css files:
|
77
|
+
|
78
|
+
/*
|
79
|
+
*= require application
|
80
|
+
*= require_tree .
|
81
|
+
*/
|
82
|
+
|
83
|
+
## Run Tests
|
84
|
+
|
85
|
+
### Start server
|
86
|
+
|
87
|
+
Start the server to run the tests:
|
88
|
+
|
89
|
+
rails s
|
90
|
+
|
91
|
+
Go to `http://localhost:3000/qunit` to see the QUnit Test Runner.
|
92
|
+
|
93
|
+
### From the CLI
|
94
|
+
|
95
|
+
[COMING SOON](/)
|
96
|
+
|
97
|
+
### Autotest
|
98
|
+
|
99
|
+
[COMING SOON](/)
|
100
|
+
|
101
|
+
## What's next?
|
102
|
+
|
103
|
+
Profit.
|
104
|
+
|
105
|
+
## License
|
106
|
+
|
107
|
+
MIT License. Copyright 2012 Francesco Rodriguez. <http://www.frodsan.com>
|
data/Rakefile
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
<html>
|
2
|
+
<head>
|
3
|
+
<title>QUnit Test Runner</title>
|
4
|
+
<%= stylesheet_link_tag "qunit" %>
|
5
|
+
<%= stylesheet_link_tag "test_helper" %>
|
6
|
+
<%= javascript_include_tag "qunit" %>
|
7
|
+
<%= javascript_include_tag "test_helper" %>
|
8
|
+
<%= csrf_meta_tags %>
|
9
|
+
</head>
|
10
|
+
<body>
|
11
|
+
<div id="qunit"></div></div>
|
12
|
+
</body>
|
13
|
+
</html>
|
@@ -0,0 +1 @@
|
|
1
|
+
Rails.application.config.assets.paths << Rails.root.join("test", "javascripts") << Rails.root.join("test", "stylesheets")
|