konacha 2.3.0 → 2.4.0

Sign up to get free protection for your applications and to get access to all the features.
data/History.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # master
2
2
 
3
+ # 2.4.0
4
+
5
+ * Support requesting files with periods in the name
6
+ * Allow customisation of the spec filename via `spec_matcher` config option
7
+ * Disable mocha's leak detection by default (#80)
8
+
3
9
  # 2.3.0
4
10
 
5
11
  * Improved support for guard-konacha
data/README.md CHANGED
@@ -182,20 +182,25 @@ Konacha can be configured in an initializer, e.g. `config/initializers/konacha.r
182
182
 
183
183
  ```ruby
184
184
  Konacha.configure do |config|
185
- config.spec_dir = "spec/javascripts"
186
- config.driver = :selenium
187
- config.stylesheets = %w(application)
185
+ config.spec_dir = "spec/javascripts"
186
+ config.spec_matcher = /_spec\.|_test\./
187
+ config.driver = :selenium
188
+ config.stylesheets = %w(application)
188
189
  end if defined?(Konacha)
189
190
  ```
190
191
 
191
192
  The `defined?` check is necessary to avoid a dependency on Konacha in the production
192
193
  environment.
193
194
 
194
- The `spec_dir` option tells Konacha where to find JavaScript specs. `driver`
195
- names a Capybara driver used for the `run` task (try `:poltergeist`, after
196
- installing [PhantomJS](https://github.com/jonleighton/poltergeist#installing-phantomjs)).
195
+ The `spec_dir` option tells Konacha where to find JavaScript specs. `spec_matcher`
196
+ is an object responding to `===` (most likely a `Regexp`); it receives a filename
197
+ and should return true if the file is a spec. `driver` names a Capybara driver used
198
+ for the `run` task (try `:poltergeist`, after installing
199
+ [PhantomJS](https://github.com/jonleighton/poltergeist#installing-phantomjs)).
197
200
  The `stylesheets` option sets the stylesheets to be linked from the `<head>`
198
- of the test runner iframe. The values above are the defaults.
201
+ of the test runner iframe.
202
+
203
+ The values above are the defaults.
199
204
 
200
205
  ## Test Interface and Assertions
201
206
 
@@ -25,6 +25,10 @@ mocha.ui = function (name) {
25
25
 
26
26
  mocha.ui('bdd');
27
27
 
28
+ // Disable leak detection by default. It doesn't seem to be reliable
29
+ // with Konacha's iframe setup.
30
+ mocha.ignoreLeaks();
31
+
28
32
  mocha.suite.beforeAll(function () {
29
33
  var contexts = parent.document.getElementsByClassName("test-context");
30
34
  for (var i = 0; i < contexts.length; ++i) {
@@ -1,6 +1,6 @@
1
1
  Konacha = {
2
2
  getEvents: function() {
3
- return JSON.stringify(Konacha.events);
3
+ return JSON.stringify(Konacha.events || []);
4
4
  }
5
5
  };
6
6
 
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  Konacha::Engine.routes.draw do
2
- get '/iframe/*name' => 'specs#iframe', :as => :iframe
2
+ get '/iframe/*name' => 'specs#iframe', :format => false, :as => :iframe
3
3
  get '/' => 'specs#parent'
4
4
  get '*path' => 'specs#parent'
5
5
  end
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 = "2.3.0"
20
+ gem.version = "2.4.0"
21
21
  gem.license = "MIT"
22
22
 
23
23
  gem.add_dependency "railties", ">= 3.1", "< 5"
data/lib/konacha.rb CHANGED
@@ -29,7 +29,7 @@ module Konacha
29
29
  yield config
30
30
  end
31
31
 
32
- delegate :port, :spec_dir, :application, :driver, :to => :config
32
+ delegate :port, :spec_dir, :spec_matcher, :application, :driver, :to => :config
33
33
 
34
34
  def spec_root
35
35
  File.join(Rails.root, config.spec_dir)
@@ -37,7 +37,7 @@ module Konacha
37
37
 
38
38
  def spec_paths
39
39
  Rails.application.assets.each_entry(spec_root).find_all { |pathname|
40
- pathname.basename.to_s =~ /_spec\.|_test\./ &&
40
+ config.spec_matcher === pathname.basename.to_s &&
41
41
  (pathname.extname == '.js' || Tilt[pathname]) &&
42
42
  Rails.application.assets.content_type_of(pathname) == 'application/javascript'
43
43
  }.map { |pathname|
@@ -27,12 +27,13 @@ module Konacha
27
27
 
28
28
  options = app.config.konacha
29
29
 
30
- options.spec_dir ||= "spec/javascripts"
31
- options.port ||= 3500
32
- options.application ||= self.class.application(app)
33
- options.driver ||= :selenium
34
- options.stylesheets ||= %w(application)
35
- options.verbose ||= false
30
+ options.spec_dir ||= "spec/javascripts"
31
+ options.spec_matcher ||= /_spec\.|_test\./
32
+ options.port ||= 3500
33
+ options.application ||= self.class.application(app)
34
+ options.driver ||= :selenium
35
+ options.stylesheets ||= %w(application)
36
+ options.verbose ||= false
36
37
 
37
38
  app.config.assets.paths << app.root.join(options.spec_dir).to_s
38
39
  end
@@ -21,7 +21,7 @@ module Konacha
21
21
  begin
22
22
  sleep 0.1
23
23
  events = JSON.parse(session.evaluate_script('window.top.Konacha.getEvents()'))
24
- if events
24
+ if events.present?
25
25
  events[events_consumed..-1].each do |event|
26
26
  done = true if event['event'] == 'end'
27
27
  reporter.process_mocha_event(event)
@@ -0,0 +1,4 @@
1
+ describe('jQuery.fn.plugin()', function () {
2
+ it('is a fake test to assert that the suite has loaded into the iframe', function () {
3
+ });
4
+ });
data/spec/konacha_spec.rb CHANGED
@@ -9,6 +9,12 @@ describe Konacha do
9
9
  subject.spec_dir.should == "spec/javascripts"
10
10
  end
11
11
  end
12
+
13
+ describe ".spec_matcher" do
14
+ it "defaults to /_spec\.|_test\./" do
15
+ subject.spec_matcher.should == /_spec\.|_test\./
16
+ end
17
+ end
12
18
  end
13
19
 
14
20
  describe ".spec_paths" do
@@ -62,6 +68,30 @@ describe Konacha do
62
68
  it "does not include non-asset files" do
63
69
  subject.should_not include("do_not_include_spec.js.bak")
64
70
  end
71
+
72
+ describe 'with a custom matcher' do
73
+ after { Konacha.config.spec_matcher = /_spec\.|_test\./ }
74
+
75
+ it "includes *-spec.* files" do
76
+ Konacha.config.spec_matcher = /-spec\./
77
+ subject.should include("file-with-hyphens-spec.js")
78
+ end
79
+
80
+ it "includes *.spec.* files" do
81
+ Konacha.config.spec_matcher = /\.spec\./
82
+ subject.should include("file.with.periods.spec.js")
83
+ end
84
+
85
+ it "works with any object responding to ===" do
86
+ Konacha.config.spec_matcher = Module.new do
87
+ def self.===(path)
88
+ path == "array_sum_js_spec.js"
89
+ end
90
+ end
91
+ subject.should include("array_sum_js_spec.js")
92
+ subject.size.should == 1
93
+ end
94
+ end
65
95
  end
66
96
 
67
97
  it "can be configured in an initializer" do
data/spec/server_spec.rb CHANGED
@@ -35,6 +35,12 @@ describe Konacha::Server, :type => :feature do
35
35
  page.should have_css(".test.pass")
36
36
  end
37
37
 
38
+ it "serves a file with a period in the name" do
39
+ visit "/jquery.plugin_spec"
40
+ page.should have_content("jQuery.fn.plugin()")
41
+ page.should have_css(".test.pass", :count => 1)
42
+ end
43
+
38
44
  it "supports spec helpers" do
39
45
  visit "/spec_helper_spec"
40
46
  page.should have_content("two_plus_two")
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: 2.3.0
4
+ version: 2.4.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-20 00:00:00.000000000 Z
12
+ date: 2013-01-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: railties
@@ -283,9 +283,12 @@ files:
283
283
  - spec/dummy/spec/javascripts/do_not_include_spec.js.bak
284
284
  - spec/dummy/spec/javascripts/do_not_include_spec.png
285
285
  - spec/dummy/spec/javascripts/failing_spec.js
286
+ - spec/dummy/spec/javascripts/file-with-hyphens-spec.js
287
+ - spec/dummy/spec/javascripts/file.with.periods.spec.js
286
288
  - spec/dummy/spec/javascripts/file_ending_in_test.js
287
289
  - spec/dummy/spec/javascripts/isolation/a_spec.js
288
290
  - spec/dummy/spec/javascripts/isolation/b_spec.js
291
+ - spec/dummy/spec/javascripts/jquery.plugin_spec.js
289
292
  - spec/dummy/spec/javascripts/pending_spec.js
290
293
  - spec/dummy/spec/javascripts/spec_helper.js
291
294
  - spec/dummy/spec/javascripts/spec_helper_spec.js
@@ -325,7 +328,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
325
328
  version: '0'
326
329
  segments:
327
330
  - 0
328
- hash: 3599375489174334072
331
+ hash: -2894895241222942879
329
332
  required_rubygems_version: !ruby/object:Gem::Requirement
330
333
  none: false
331
334
  requirements:
@@ -334,7 +337,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
334
337
  version: '0'
335
338
  segments:
336
339
  - 0
337
- hash: 3599375489174334072
340
+ hash: -2894895241222942879
338
341
  requirements: []
339
342
  rubyforge_project:
340
343
  rubygems_version: 1.8.24
@@ -361,9 +364,12 @@ test_files:
361
364
  - spec/dummy/spec/javascripts/do_not_include_spec.js.bak
362
365
  - spec/dummy/spec/javascripts/do_not_include_spec.png
363
366
  - spec/dummy/spec/javascripts/failing_spec.js
367
+ - spec/dummy/spec/javascripts/file-with-hyphens-spec.js
368
+ - spec/dummy/spec/javascripts/file.with.periods.spec.js
364
369
  - spec/dummy/spec/javascripts/file_ending_in_test.js
365
370
  - spec/dummy/spec/javascripts/isolation/a_spec.js
366
371
  - spec/dummy/spec/javascripts/isolation/b_spec.js
372
+ - spec/dummy/spec/javascripts/jquery.plugin_spec.js
367
373
  - spec/dummy/spec/javascripts/pending_spec.js
368
374
  - spec/dummy/spec/javascripts/spec_helper.js
369
375
  - spec/dummy/spec/javascripts/spec_helper_spec.js