konacha 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -18,3 +18,6 @@ test/version_tmp
18
18
  tmp
19
19
  node_modules
20
20
  spec/dummy/log
21
+ vendor/assets/javascripts/mocha.js
22
+ vendor/assets/stylesheets/mocha.css
23
+ vendor/assets/javascripts/chai.js
@@ -0,0 +1,6 @@
1
+ [submodule "chai"]
2
+ path = chai
3
+ url = git://github.com/logicalparadox/chai.git
4
+ [submodule "mocha"]
5
+ path = mocha
6
+ url = git://github.com/visionmedia/mocha.git
data/History.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # master
2
2
 
3
+ # 1.1.1
4
+
5
+ * 1.8.7 compatibility
6
+
3
7
  # 1.1.0
4
8
 
5
9
  * Provided the ability to set mocha options via JS
data/README.md CHANGED
@@ -20,9 +20,11 @@ Photo credit: [FCartegnie](http://commons.wikimedia.org/wiki/File:Konacha.jpg),
20
20
 
21
21
  Add konacha to the `:test` and `:development` groups in the Gemfile and `bundle install`:
22
22
 
23
- group :test, :development do
24
- gem "konacha"
25
- end
23
+ ```ruby
24
+ group :test, :development do
25
+ gem "konacha"
26
+ end
27
+ ```
26
28
 
27
29
  ## Usage
28
30
 
@@ -35,28 +37,32 @@ For example, suppose you wanted to test your cool JavaScript `Array#sum` method,
35
37
  you placed in `app/assets/javascripts/array_sum.js`. Write the specs in JavaScript in
36
38
  the file `spec/javascripts/array_sum_spec.js`:
37
39
 
38
- //= require array_sum
40
+ ```javascript
41
+ //= require array_sum
39
42
 
40
- describe("Array#sum", function(){
41
- it("returns 0 when the Array is empty", function(){
42
- [].sum().should.equal(0);
43
- });
43
+ describe("Array#sum", function() {
44
+ it("returns 0 when the Array is empty", function() {
45
+ [].sum().should.equal(0);
46
+ });
44
47
 
45
- it("returns the sum of numeric elements", function(){
46
- [1,2,3].sum().should.equal(6);
47
- });
48
- });
48
+ it("returns the sum of numeric elements", function() {
49
+ [1,2,3].sum().should.equal(6);
50
+ });
51
+ });
52
+ ```
49
53
 
50
54
  Or, if you prefer CoffeeScript, in `spec/javascripts/array_sum_spec.js.coffee`:
51
55
 
52
- #= require array_sum
56
+ ```coffeescript
57
+ #= require array_sum
53
58
 
54
- describe "Array#sum", ->
55
- it "returns 0 when the Array is empty", ->
56
- [].sum().should.equal(0)
59
+ describe "Array#sum", ->
60
+ it "returns 0 when the Array is empty", ->
61
+ [].sum().should.equal(0)
57
62
 
58
- it "returns the sum of numeric elements", ->
59
- [1,2,3].sum().should.equal(6)
63
+ it "returns the sum of numeric elements", ->
64
+ [1,2,3].sum().should.equal(6)
65
+ ```
60
66
 
61
67
  The `konacha:serve` rake task starts a server for your tests. You can go to the root
62
68
  page to run all specs (e.g. `http://localhost:3500/`), a sub page to run an individual
@@ -71,12 +77,14 @@ Since Konacha integrates with the asset pipeline, using setup helpers in your sp
71
77
  easy. Just create a `spec_helper.js` or `spec_helper.js.coffee` file in `specs/javascripts`
72
78
  and require it in your tests:
73
79
 
74
- //= require spec_helper
75
- //= require array_sum
80
+ ```javascript
81
+ //= require spec_helper
82
+ //= require array_sum
76
83
 
77
- describe("Array#sum", function(){
78
- ...
79
- });
84
+ describe("Array#sum", function() {
85
+ ...
86
+ });
87
+ ```
80
88
 
81
89
  ## Directives and Asset Bundling
82
90
 
@@ -94,10 +102,12 @@ search through a many thousand line application.js bundle to debug a spec failur
94
102
 
95
103
  Konacha can be configured in an initializer, e.g. `config/initializers/konacha.rb`:
96
104
 
97
- Konacha.configure do |config|
98
- config.spec_dir = "spec/javascripts"
99
- config.driver = :selenium
100
- end if defined?(Konacha)
105
+ ```ruby
106
+ Konacha.configure do |config|
107
+ config.spec_dir = "spec/javascripts"
108
+ config.driver = :selenium
109
+ end if defined?(Konacha)
110
+ ```
101
111
 
102
112
  The `defined?` check is necessary to avoid a dependency on Konacha in the production
103
113
  environment.
@@ -114,14 +124,16 @@ You can customize the Mocha options passed into `mocha.setup(..)` by creating a
114
124
  named `konacha_config.js` or `konacha_config.js.coffee` in `spec/javascripts` and
115
125
  setting properties of `Konacha.mochaOptions`:
116
126
 
117
- // ignore the following globals during leak detection
118
- Konacha.mochaOptions.globals = ['YUI'];
127
+ ```javascript
128
+ // ignore the following globals during leak detection
129
+ Konacha.mochaOptions.globals = ['YUI'];
119
130
 
120
- // or, ignore all leaks
121
- Konacha.mochaOptions.ignoreLeaks = true;
131
+ // or, ignore all leaks
132
+ Konacha.mochaOptions.ignoreLeaks = true;
122
133
 
123
- // set slow test timeout in ms
124
- Konacha.mochaOptions.timeout = 5;
134
+ // set slow test timeout in ms
135
+ Konacha.mochaOptions.timeout = 5;
136
+ ```
125
137
 
126
138
  The `ui` and `reporter` Mocha options are set by Konacha and must not be modified.
127
139
 
@@ -145,13 +157,15 @@ dependent on each other. Konacha adds a special div to your page with an id of `
145
157
  This div is automatically emptied before each example. You should avoid appending markup
146
158
  to the page body and instead append it to the `#konacha` div:
147
159
 
148
- describe "transactions", ->
149
- it "should add stuff in one test...", ->
150
- $('#konacha').append('<h1 id="added">New Stuff</h1>')
151
- $('#konacha h1#added').length.should.equal(1)
160
+ ```coffeescript
161
+ describe "transactions", ->
162
+ it "should add stuff in one test...", ->
163
+ $('#konacha').append('<h1 id="added">New Stuff</h1>')
164
+ $('#konacha h1#added').length.should.equal(1)
152
165
 
153
- it "... should have been removed before the next starts", ->
154
- $('#konacha h1#added').length.should.equal(0)
166
+ it "... should have been removed before the next starts", ->
167
+ $('#konacha h1#added').length.should.equal(0)
168
+ ```
155
169
 
156
170
  ## Templates / Fixtures
157
171
 
@@ -162,22 +176,56 @@ require them in your spec or spec_helper, and render them into the `#konacha` di
162
176
 
163
177
  For example, in `spec/javascripts/templates/hello.jst.ejs`:
164
178
 
165
- <h1>Hello Konacha!</h1>
179
+ ```html
180
+ <h1>Hello Konacha!</h1>
181
+ ```
166
182
 
167
183
  In `spec_helper.js`:
168
184
 
169
- //= require_tree ./templates
185
+ ```javascript
186
+ //= require_tree ./templates
187
+ ```
170
188
 
171
189
  And your spec:
172
190
 
173
- //= require spec_helper
191
+ ```javascript
192
+ //= require spec_helper
174
193
 
175
- describe("templating", function(){
176
- it("is built in to Sprockets", function(){
177
- $('#konacha').html(JST['templates/hello']());
178
- $('#konacha h1').text().should.equal('Hello Konacha!');
179
- });
180
- });
194
+ describe("templating", function() {
195
+ it("is built in to Sprockets", function() {
196
+ $('#konacha').html(JST['templates/hello']());
197
+ $('#konacha h1').text().should.equal('Hello Konacha!');
198
+ });
199
+ });
200
+ ```
201
+
202
+ ## Contributing
203
+
204
+ ```bash
205
+ git clone git://github.com/jfirebaugh/konacha.git
206
+ ```
207
+
208
+ Run `bundle exec rake` to run the test suite.
209
+
210
+ ### Contributing to Mocha and Chai
211
+
212
+ The Konacha repository includes the
213
+ [Mocha](https://github.com/visionmedia/mocha) and
214
+ [Chai](https://github.com/logicalparadox/chai) repositories as submodules, so
215
+ you can hack on them directly:
216
+
217
+ ```bash
218
+ cd mocha # or: cd chai
219
+ git checkout master
220
+ ... hack-hack-hack ...
221
+ bundle exec rake assets # make and cp assets based on your changes
222
+ ```
223
+
224
+ Assuming your app's Gemfile points at your Konacha checkout (`gem 'konacha',
225
+ :path => '~/path/to/konacha'`), your changes to Mocha and Chai are live in
226
+ localhost:3500 when you refresh your browser.
227
+
228
+ You can send pull requests to Mocha and Chai straight out of your submodules.
181
229
 
182
230
  ## License
183
231
 
data/Rakefile CHANGED
@@ -3,6 +3,18 @@
3
3
  require "bundler/gem_tasks"
4
4
  require "rspec/core/rake_task"
5
5
 
6
- RSpec::Core::RakeTask.new :spec
6
+ RSpec::Core::RakeTask.new :spec => :assets
7
+
8
+ desc 'Build and copy Mocha and Chai assets from submodules into vendor/assets'
9
+ task :assets do
10
+ sh 'git submodule update --init'
11
+ sh 'cd mocha && make -s'
12
+ sh 'cd chai && make -s'
13
+ mkdir_p 'vendor/assets/javascripts'
14
+ mkdir_p 'vendor/assets/stylesheets'
15
+ cp 'mocha/mocha.js', 'vendor/assets/javascripts/'
16
+ cp 'mocha/mocha.css', 'vendor/assets/stylesheets/'
17
+ cp 'chai/chai.js', 'vendor/assets/javascripts/'
18
+ end
7
19
 
8
20
  task :default => :spec
@@ -5,7 +5,7 @@ module Konacha
5
5
  asset_paths.asset_for(spec.asset_name, "js").to_a
6
6
  end.flatten.uniq.map(&:logical_path)
7
7
 
8
- javascript_include_tag *assets, :body => true, :debug => false
8
+ javascript_include_tag *(assets << {:body => true, :debug => false})
9
9
  end
10
10
  end
11
11
  end
@@ -13,11 +13,14 @@ the asset pipeline and engines.}
13
13
  gem.homepage = "http://github.com/jfirebaugh/konacha"
14
14
 
15
15
  gem.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
16
- gem.files = `git ls-files`.split("\n")
16
+ gem.files = `git ls-files`.split("\n") + \
17
+ ['vendor/assets/javascripts/mocha.js',
18
+ 'vendor/assets/stylesheets/mocha.css',
19
+ 'vendor/assets/javascripts/chai.js']
17
20
  gem.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
21
  gem.name = "konacha"
19
22
  gem.require_paths = ["lib"]
20
- gem.version = "1.1.0"
23
+ gem.version = "1.1.1"
21
24
 
22
25
  gem.add_dependency "rails", "~> 3.1"
23
26
  gem.add_dependency "capybara"
@@ -2,8 +2,11 @@ require 'spec_helper'
2
2
 
3
3
  describe "konacha/specs/specs" do
4
4
  it "includes konacha JS for given mode" do
5
+ assign(:specs, [])
5
6
  Konacha.should_receive(:mode).any_number_of_times { :runner }
7
+
6
8
  render
9
+
7
10
  rendered.should have_css("script[src='/assets/konacha/runner.js']")
8
11
  end
9
12
 
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.1.0
4
+ version: 1.1.1
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 00:00:00.000000000 Z
12
+ date: 2012-04-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70238910364860 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,15 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70238910364860
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '3.1'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: capybara
27
- requirement: &70238910364460 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
35
  - - ! '>='
@@ -32,10 +37,15 @@ dependencies:
32
37
  version: '0'
33
38
  type: :runtime
34
39
  prerelease: false
35
- version_requirements: *70238910364460
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: jquery-rails
38
- requirement: &70238910364000 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ! '>='
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: '0'
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70238910364000
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: rspec-rails
49
- requirement: &70238910363580 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70238910363580
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: capybara-firebug
60
- requirement: &70238910363080 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '1.1'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70238910363080
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '1.1'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: coffee-script
71
- requirement: &70238910362660 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,10 +101,15 @@ dependencies:
76
101
  version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *70238910362660
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  - !ruby/object:Gem::Dependency
81
111
  name: ejs
82
- requirement: &70238910362200 !ruby/object:Gem::Requirement
112
+ requirement: !ruby/object:Gem::Requirement
83
113
  none: false
84
114
  requirements:
85
115
  - - ! '>='
@@ -87,10 +117,15 @@ dependencies:
87
117
  version: '0'
88
118
  type: :development
89
119
  prerelease: false
90
- version_requirements: *70238910362200
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
91
126
  - !ruby/object:Gem::Dependency
92
127
  name: vendorer
93
- requirement: &70238910361780 !ruby/object:Gem::Requirement
128
+ requirement: !ruby/object:Gem::Requirement
94
129
  none: false
95
130
  requirements:
96
131
  - - ! '>='
@@ -98,7 +133,12 @@ dependencies:
98
133
  version: '0'
99
134
  type: :development
100
135
  prerelease: false
101
- version_requirements: *70238910361780
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
102
142
  description: ! 'Konacha is a Rails engine that allows you to test your JavaScript
103
143
  with the
104
144
 
@@ -118,6 +158,7 @@ extensions: []
118
158
  extra_rdoc_files: []
119
159
  files:
120
160
  - .gitignore
161
+ - .gitmodules
121
162
  - Gemfile
122
163
  - History.md
123
164
  - LICENSE
@@ -165,10 +206,10 @@ files:
165
206
  - spec/server_spec.rb
166
207
  - spec/spec_helper.rb
167
208
  - spec/views/specs/specs.html.erb_spec.rb
168
- - vendor/assets/javascripts/chai.js
209
+ - vendor/images/konacha.jpg
169
210
  - vendor/assets/javascripts/mocha.js
170
211
  - vendor/assets/stylesheets/mocha.css
171
- - vendor/images/konacha.jpg
212
+ - vendor/assets/javascripts/chai.js
172
213
  homepage: http://github.com/jfirebaugh/konacha
173
214
  licenses: []
174
215
  post_install_message:
@@ -189,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
189
230
  version: '0'
190
231
  requirements: []
191
232
  rubyforge_project:
192
- rubygems_version: 1.8.17
233
+ rubygems_version: 1.8.23
193
234
  signing_key:
194
235
  specification_version: 3
195
236
  summary: Unit-test your Rails JavaScript with the mocha test framework and chai assertion
@@ -222,4 +263,3 @@ test_files:
222
263
  - spec/server_spec.rb
223
264
  - spec/spec_helper.rb
224
265
  - spec/views/specs/specs.html.erb_spec.rb
225
- has_rdoc: