chinchilla 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/chinchilla.gemspec +2 -0
- data/lib/assets/javascripts/{chinchilla.js → qunit-runner.js} +10 -6
- data/lib/chinchilla/runner/{test_runner.rb → test.rb} +28 -17
- data/lib/chinchilla/runner.rb +34 -21
- data/lib/chinchilla/version.rb +1 -1
- data/lib/chinchilla.rb +7 -10
- metadata +38 -8
- data/lib/chinchilla/suite.rb +0 -13
- data/lib/chinchilla/test.rb +0 -9
data/chinchilla.gemspec
CHANGED
@@ -13,6 +13,8 @@ Gem::Specification.new do |gem|
|
|
13
13
|
gem.homepage = ""
|
14
14
|
|
15
15
|
gem.add_dependency 'capybara'
|
16
|
+
gem.add_dependency 'poltergeist'
|
17
|
+
gem.add_dependency 'colorize'
|
16
18
|
|
17
19
|
gem.files = `git ls-files`.split($\)
|
18
20
|
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
@@ -1,17 +1,19 @@
|
|
1
|
-
|
1
|
+
(function() {
|
2
|
+
|
3
|
+
QUnit.Runner = {
|
2
4
|
done: false,
|
3
5
|
dots: "",
|
4
6
|
results: []
|
5
7
|
};
|
6
8
|
|
7
|
-
|
8
|
-
return JSON.stringify(
|
9
|
+
QUnit.Runner.getResults = function() {
|
10
|
+
return JSON.stringify(QUnit.Runner.results);
|
9
11
|
};
|
10
12
|
|
11
13
|
var currentTest = {};
|
12
14
|
QUnit.testDone = function(results) {
|
13
|
-
|
14
|
-
|
15
|
+
QUnit.Runner.dots += (results.failed > 0 ? "F" : ".");
|
16
|
+
QUnit.Runner.results.push({
|
15
17
|
name: results.name,
|
16
18
|
passed: results.failed === 0,
|
17
19
|
message: currentTest.message
|
@@ -34,7 +36,9 @@ QUnit.log = function(results) {
|
|
34
36
|
};
|
35
37
|
|
36
38
|
QUnit.done = function(results) {
|
37
|
-
|
39
|
+
QUnit.Runner.done = true;
|
38
40
|
};
|
39
41
|
|
40
42
|
QUnit.config.autorun = false;
|
43
|
+
|
44
|
+
})();
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Chinchilla
|
2
2
|
class Runner
|
3
|
-
class
|
4
|
-
attr_reader :runner, :
|
3
|
+
class Test
|
4
|
+
attr_reader :runner, :url
|
5
5
|
|
6
|
-
def initialize(runner,
|
6
|
+
def initialize(runner, url)
|
7
7
|
@runner = runner
|
8
|
-
@
|
8
|
+
@url = url
|
9
9
|
end
|
10
10
|
|
11
11
|
def session
|
@@ -23,24 +23,35 @@ module Chinchilla
|
|
23
23
|
passed?
|
24
24
|
end
|
25
25
|
|
26
|
+
def colorize_dots(dots)
|
27
|
+
dots = dots.chars.map do |d|
|
28
|
+
case d
|
29
|
+
when 'E', 'F'; d.red
|
30
|
+
when 'P'; d.yellow
|
31
|
+
when '.'; d.green
|
32
|
+
else; d
|
33
|
+
end
|
34
|
+
end
|
35
|
+
dots.join ''
|
36
|
+
end
|
37
|
+
|
26
38
|
def examples
|
27
39
|
@results ||= begin
|
28
|
-
session.visit(
|
29
|
-
|
30
|
-
previous_results = ""
|
40
|
+
session.visit(url)
|
31
41
|
|
32
|
-
|
33
|
-
dots = session.evaluate_script('Chinchilla.dots')
|
34
|
-
io.print dots.sub(/^#{Regexp.escape(previous_results)}/, '')
|
35
|
-
io.flush
|
36
|
-
previous_results = dots
|
37
|
-
session.evaluate_script('Chinchilla.done')
|
38
|
-
end
|
42
|
+
dots_printed = 0
|
39
43
|
|
40
|
-
|
41
|
-
|
44
|
+
begin
|
45
|
+
sleep 0.1
|
46
|
+
done, dots = session.evaluate_script('[QUnit.Runner.done, QUnit.Runner.dots]')
|
47
|
+
if dots
|
48
|
+
io.write colorize_dots(dots[dots_printed..-1])
|
49
|
+
io.flush
|
50
|
+
dots_printed = dots.length
|
51
|
+
end
|
52
|
+
end until done
|
42
53
|
|
43
|
-
JSON.parse(session.evaluate_script('
|
54
|
+
JSON.parse(session.evaluate_script('QUnit.Runner.getResults()')).map do |row|
|
44
55
|
Example.new(row)
|
45
56
|
end
|
46
57
|
end
|
data/lib/chinchilla/runner.rb
CHANGED
@@ -1,16 +1,39 @@
|
|
1
1
|
require 'chinchilla/runner/example'
|
2
|
-
require 'chinchilla/runner/
|
2
|
+
require 'chinchilla/runner/test'
|
3
3
|
|
4
4
|
module Chinchilla
|
5
5
|
class Runner
|
6
|
-
|
6
|
+
def self.run(options={})
|
7
|
+
self.new(options).run
|
8
|
+
end
|
9
|
+
|
10
|
+
def initialize(options)
|
11
|
+
options[:urls] = [options.delete(:url)] if options.has_key?(:url)
|
12
|
+
@options = options
|
13
|
+
end
|
14
|
+
|
15
|
+
def io
|
16
|
+
@io ||= @options[:io] || STDOUT
|
17
|
+
end
|
18
|
+
|
19
|
+
def urls
|
20
|
+
@urls ||= @options[:urls] || ['/']
|
21
|
+
end
|
22
|
+
|
23
|
+
def driver
|
24
|
+
@driver ||= @options[:driver] || :poltergeist
|
25
|
+
end
|
26
|
+
|
27
|
+
def application
|
28
|
+
@application ||= @options[:application] || default_application
|
29
|
+
end
|
7
30
|
|
8
|
-
def
|
9
|
-
|
31
|
+
def default_application
|
32
|
+
defined?(Rails) ? Rails.application : nil
|
10
33
|
end
|
11
34
|
|
12
|
-
def
|
13
|
-
|
35
|
+
def tests
|
36
|
+
@tests ||= urls.map {|url| Test.new(self, url) }
|
14
37
|
end
|
15
38
|
|
16
39
|
def run
|
@@ -31,7 +54,7 @@ module Chinchilla
|
|
31
54
|
end
|
32
55
|
|
33
56
|
def examples
|
34
|
-
|
57
|
+
tests.map { |test| test.examples }.flatten
|
35
58
|
end
|
36
59
|
|
37
60
|
def failed_examples
|
@@ -39,31 +62,21 @@ module Chinchilla
|
|
39
62
|
end
|
40
63
|
|
41
64
|
def passed?
|
42
|
-
|
65
|
+
tests.all? { |test| test.passed? }
|
43
66
|
end
|
44
67
|
|
45
68
|
def dots
|
46
|
-
|
69
|
+
tests.map { |test| test.dots }.join
|
47
70
|
end
|
48
71
|
|
49
72
|
def failure_messages
|
50
73
|
unless passed?
|
51
|
-
|
74
|
+
tests.map { |test| test.failure_messages }.compact.join("\n\n")
|
52
75
|
end
|
53
76
|
end
|
54
77
|
|
55
78
|
def session
|
56
|
-
@session ||= Capybara::Session.new(
|
57
|
-
end
|
58
|
-
|
59
|
-
def suite
|
60
|
-
@suite ||= Chinchilla::Suite.new(Chinchilla.mounted_at)
|
61
|
-
end
|
62
|
-
|
63
|
-
protected
|
64
|
-
|
65
|
-
def test_runners
|
66
|
-
@test_runners ||= suite.tests.map { |test| TestRunner.new(self, test) }
|
79
|
+
@session ||= Capybara::Session.new(driver, application)
|
67
80
|
end
|
68
81
|
end
|
69
82
|
end
|
data/lib/chinchilla/version.rb
CHANGED
data/lib/chinchilla.rb
CHANGED
@@ -1,17 +1,14 @@
|
|
1
1
|
require "chinchilla/version"
|
2
|
-
require "chinchilla/test"
|
3
|
-
require "chinchilla/suite"
|
4
|
-
require "chinchilla/runner"
|
5
2
|
|
6
|
-
|
7
|
-
|
8
|
-
|
3
|
+
require "capybara"
|
4
|
+
require "capybara/poltergeist"
|
5
|
+
require "colorize"
|
9
6
|
|
10
|
-
|
11
|
-
attr_accessor :application, :driver, :mounted_at
|
7
|
+
require "chinchilla/runner"
|
12
8
|
|
13
|
-
|
14
|
-
|
9
|
+
if defined?(::Rails)
|
10
|
+
module Chinchilla
|
11
|
+
class Engine < ::Rails::Engine
|
15
12
|
end
|
16
13
|
end
|
17
14
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chinchilla
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.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: 2012-
|
12
|
+
date: 2012-09-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: capybara
|
@@ -27,6 +27,38 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: poltergeist
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
- !ruby/object:Gem::Dependency
|
47
|
+
name: colorize
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
49
|
+
none: false
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
type: :runtime
|
55
|
+
prerelease: false
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
30
62
|
description: QUnit test runner
|
31
63
|
email:
|
32
64
|
- paul@chavard.net
|
@@ -40,13 +72,11 @@ files:
|
|
40
72
|
- README.md
|
41
73
|
- Rakefile
|
42
74
|
- chinchilla.gemspec
|
43
|
-
- lib/assets/javascripts/
|
75
|
+
- lib/assets/javascripts/qunit-runner.js
|
44
76
|
- lib/chinchilla.rb
|
45
77
|
- lib/chinchilla/runner.rb
|
46
78
|
- lib/chinchilla/runner/example.rb
|
47
|
-
- lib/chinchilla/runner/
|
48
|
-
- lib/chinchilla/suite.rb
|
49
|
-
- lib/chinchilla/test.rb
|
79
|
+
- lib/chinchilla/runner/test.rb
|
50
80
|
- lib/chinchilla/version.rb
|
51
81
|
homepage: ''
|
52
82
|
licenses: []
|
@@ -62,7 +92,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
62
92
|
version: '0'
|
63
93
|
segments:
|
64
94
|
- 0
|
65
|
-
hash: -
|
95
|
+
hash: -3891497850019772180
|
66
96
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
67
97
|
none: false
|
68
98
|
requirements:
|
@@ -71,7 +101,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
71
101
|
version: '0'
|
72
102
|
segments:
|
73
103
|
- 0
|
74
|
-
hash: -
|
104
|
+
hash: -3891497850019772180
|
75
105
|
requirements: []
|
76
106
|
rubyforge_project:
|
77
107
|
rubygems_version: 1.8.23
|
data/lib/chinchilla/suite.rb
DELETED