konacha 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/History.md +4 -0
- data/README.md +25 -8
- data/app/views/konacha/specs/specs.html.erb +2 -1
- data/konacha.gemspec +1 -1
- data/lib/assets/javascripts/konacha/runner.js +26 -22
- data/lib/assets/javascripts/konacha/server.js +4 -1
- data/spec/dummy/spec/javascripts/konacha_config.js +2 -0
- data/spec/dummy/spec/javascripts/konacha_config_spec.js +9 -0
- metadata +22 -18
data/History.md
CHANGED
data/README.md
CHANGED
@@ -108,6 +108,23 @@ Capybara driver used for the `run` task (try `:webkit`, after installing
|
|
108
108
|
|
109
109
|
The values above are the defaults.
|
110
110
|
|
111
|
+
### Mocha Configuration
|
112
|
+
|
113
|
+
You can customize the Mocha options passed into `mocha.setup(..)` by creating a file
|
114
|
+
named `konacha_config.js` or `konacha_config.js.coffee` in `spec/javascripts` and
|
115
|
+
setting properties of `Konacha.mochaOptions`:
|
116
|
+
|
117
|
+
// ignore the following globals during leak detection
|
118
|
+
Konacha.mochaOptions.globals = ['YUI'];
|
119
|
+
|
120
|
+
// or, ignore all leaks
|
121
|
+
Konacha.mochaOptions.ignoreLeaks = true;
|
122
|
+
|
123
|
+
// set slow test timeout in ms
|
124
|
+
Konacha.mochaOptions.timeout = 5;
|
125
|
+
|
126
|
+
The `ui` and `reporter` Mocha options are set by Konacha and must not be modified.
|
127
|
+
|
111
128
|
## Test Interface and Assertions
|
112
129
|
|
113
130
|
Konacha includes a vendored copy of mocha.js and the [chai](http://chaijs.com/)
|
@@ -124,24 +141,24 @@ for some jQuery-specific assertions.
|
|
124
141
|
|
125
142
|
One problem often faced when writing unit tests for client side code is that changes
|
126
143
|
to the page are not reverted for the next example, so that successive examples become
|
127
|
-
dependent on each other. Konacha adds a special div to your page with an id of `
|
144
|
+
dependent on each other. Konacha adds a special div to your page with an id of `konacha`.
|
128
145
|
This div is automatically emptied before each example. You should avoid appending markup
|
129
|
-
to the page body and instead append it to
|
146
|
+
to the page body and instead append it to the `#konacha` div:
|
130
147
|
|
131
148
|
describe "transactions", ->
|
132
149
|
it "should add stuff in one test...", ->
|
133
|
-
$('#
|
134
|
-
$('#
|
150
|
+
$('#konacha').append('<h1 id="added">New Stuff</h1>')
|
151
|
+
$('#konacha h1#added').length.should.equal(1)
|
135
152
|
|
136
153
|
it "... should have been removed before the next starts", ->
|
137
|
-
$('#
|
154
|
+
$('#konacha h1#added').length.should.equal(0)
|
138
155
|
|
139
156
|
## Templates / Fixtures
|
140
157
|
|
141
158
|
Konacha has no template (a.k.a. HTML fixture) support of its own. Instead, we suggest you use
|
142
159
|
Sprocket's built in support for JavaScript template (`.jst`) files. Add a `spec/javascripts/templates`
|
143
160
|
directory, place template files there (using any JS template language supported by Sprockets),
|
144
|
-
require them in your spec or spec_helper, and render them into the `#
|
161
|
+
require them in your spec or spec_helper, and render them into the `#konacha` div.
|
145
162
|
|
146
163
|
For example, in `spec/javascripts/templates/hello.jst.ejs`:
|
147
164
|
|
@@ -157,8 +174,8 @@ And your spec:
|
|
157
174
|
|
158
175
|
describe("templating", function(){
|
159
176
|
it("is built in to Sprockets", function(){
|
160
|
-
$('#
|
161
|
-
$('#
|
177
|
+
$('#konacha').html(JST['templates/hello']());
|
178
|
+
$('#konacha h1').text().should.equal('Hello Konacha!');
|
162
179
|
});
|
163
180
|
});
|
164
181
|
|
@@ -6,8 +6,9 @@
|
|
6
6
|
<%= stylesheet_link_tag "mocha", :debug => false %>
|
7
7
|
<%= stylesheet_link_tag "konacha", :debug => false %>
|
8
8
|
<%= javascript_include_tag "mocha", "chai", "konacha/#{Konacha.mode}", :debug => false %>
|
9
|
+
<%= javascript_include_tag("konacha_config", :debug => false) if Rails.application.assets.find_asset('konacha_config') %>
|
9
10
|
<script>
|
10
|
-
mocha.setup(
|
11
|
+
mocha.setup(Konacha.mochaOptions);
|
11
12
|
|
12
13
|
beforeEach(function () {
|
13
14
|
var e = document.getElementById('konacha'),
|
data/konacha.gemspec
CHANGED
@@ -17,7 +17,7 @@ the asset pipeline and engines.}
|
|
17
17
|
gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
18
18
|
gem.name = "konacha"
|
19
19
|
gem.require_paths = ["lib"]
|
20
|
-
gem.version = "1.
|
20
|
+
gem.version = "1.1.0"
|
21
21
|
|
22
22
|
gem.add_dependency "rails", "~> 3.1"
|
23
23
|
gem.add_dependency "capybara"
|
@@ -1,34 +1,38 @@
|
|
1
1
|
window.Konacha = {
|
2
2
|
dots:"",
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
mochaOptions: {
|
5
|
+
ui: 'bdd',
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
});
|
7
|
+
reporter: function (runner) {
|
8
|
+
window.mocha.reporters.Base.call(this, runner);
|
10
9
|
|
11
|
-
|
12
|
-
|
13
|
-
Konacha.results.push({
|
14
|
-
name:test.title,
|
15
|
-
passed:true
|
10
|
+
runner.on('start', function () {
|
11
|
+
Konacha.results = [];
|
16
12
|
});
|
17
|
-
});
|
18
13
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
trace:test.err.stack
|
14
|
+
runner.on('pass', function (test) {
|
15
|
+
Konacha.dots += ".";
|
16
|
+
Konacha.results.push({
|
17
|
+
name:test.title,
|
18
|
+
passed:true
|
19
|
+
});
|
26
20
|
});
|
27
|
-
});
|
28
21
|
|
29
|
-
|
30
|
-
|
31
|
-
|
22
|
+
runner.on('fail', function (test) {
|
23
|
+
Konacha.dots += "F";
|
24
|
+
Konacha.results.push({
|
25
|
+
name:test.title,
|
26
|
+
passed:false,
|
27
|
+
message:test.err.message,
|
28
|
+
trace:test.err.stack
|
29
|
+
});
|
30
|
+
});
|
31
|
+
|
32
|
+
runner.on('end', function () {
|
33
|
+
Konacha.done = true;
|
34
|
+
});
|
35
|
+
}
|
32
36
|
},
|
33
37
|
|
34
38
|
getResults:function () {
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: konacha
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-04-
|
12
|
+
date: 2012-04-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement: &
|
16
|
+
requirement: &70238910364860 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '3.1'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70238910364860
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: capybara
|
27
|
-
requirement: &
|
27
|
+
requirement: &70238910364460 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70238910364460
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: jquery-rails
|
38
|
-
requirement: &
|
38
|
+
requirement: &70238910364000 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ! '>='
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '0'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70238910364000
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: rspec-rails
|
49
|
-
requirement: &
|
49
|
+
requirement: &70238910363580 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ! '>='
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: '0'
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70238910363580
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: capybara-firebug
|
60
|
-
requirement: &
|
60
|
+
requirement: &70238910363080 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,10 +65,10 @@ dependencies:
|
|
65
65
|
version: '1.1'
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *70238910363080
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: coffee-script
|
71
|
-
requirement: &
|
71
|
+
requirement: &70238910362660 !ruby/object:Gem::Requirement
|
72
72
|
none: false
|
73
73
|
requirements:
|
74
74
|
- - ! '>='
|
@@ -76,10 +76,10 @@ dependencies:
|
|
76
76
|
version: '0'
|
77
77
|
type: :development
|
78
78
|
prerelease: false
|
79
|
-
version_requirements: *
|
79
|
+
version_requirements: *70238910362660
|
80
80
|
- !ruby/object:Gem::Dependency
|
81
81
|
name: ejs
|
82
|
-
requirement: &
|
82
|
+
requirement: &70238910362200 !ruby/object:Gem::Requirement
|
83
83
|
none: false
|
84
84
|
requirements:
|
85
85
|
- - ! '>='
|
@@ -87,10 +87,10 @@ dependencies:
|
|
87
87
|
version: '0'
|
88
88
|
type: :development
|
89
89
|
prerelease: false
|
90
|
-
version_requirements: *
|
90
|
+
version_requirements: *70238910362200
|
91
91
|
- !ruby/object:Gem::Dependency
|
92
92
|
name: vendorer
|
93
|
-
requirement: &
|
93
|
+
requirement: &70238910361780 !ruby/object:Gem::Requirement
|
94
94
|
none: false
|
95
95
|
requirements:
|
96
96
|
- - ! '>='
|
@@ -98,7 +98,7 @@ dependencies:
|
|
98
98
|
version: '0'
|
99
99
|
type: :development
|
100
100
|
prerelease: false
|
101
|
-
version_requirements: *
|
101
|
+
version_requirements: *70238910361780
|
102
102
|
description: ! 'Konacha is a Rails engine that allows you to test your JavaScript
|
103
103
|
with the
|
104
104
|
|
@@ -151,6 +151,8 @@ files:
|
|
151
151
|
- spec/dummy/spec/javascripts/array_sum_js_spec.js
|
152
152
|
- spec/dummy/spec/javascripts/assert_spec.js.coffee
|
153
153
|
- spec/dummy/spec/javascripts/failing_spec.js
|
154
|
+
- spec/dummy/spec/javascripts/konacha_config.js
|
155
|
+
- spec/dummy/spec/javascripts/konacha_config_spec.js
|
154
156
|
- spec/dummy/spec/javascripts/spec_helper.js
|
155
157
|
- spec/dummy/spec/javascripts/spec_helper_spec.js
|
156
158
|
- spec/dummy/spec/javascripts/subdirectory/subdirectory_spec.js
|
@@ -206,6 +208,8 @@ test_files:
|
|
206
208
|
- spec/dummy/spec/javascripts/array_sum_js_spec.js
|
207
209
|
- spec/dummy/spec/javascripts/assert_spec.js.coffee
|
208
210
|
- spec/dummy/spec/javascripts/failing_spec.js
|
211
|
+
- spec/dummy/spec/javascripts/konacha_config.js
|
212
|
+
- spec/dummy/spec/javascripts/konacha_config_spec.js
|
209
213
|
- spec/dummy/spec/javascripts/spec_helper.js
|
210
214
|
- spec/dummy/spec/javascripts/spec_helper_spec.js
|
211
215
|
- spec/dummy/spec/javascripts/subdirectory/subdirectory_spec.js
|