chinchilla 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in chinchilla.gemspec
4
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2012 tchak
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Chinchilla
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'chinchilla'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install chinchilla
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require "bundler/gem_tasks"
@@ -0,0 +1,21 @@
1
+ # -*- encoding: utf-8 -*-
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'chinchilla/version'
5
+
6
+ Gem::Specification.new do |gem|
7
+ gem.name = "chinchilla"
8
+ gem.version = Chinchilla::VERSION
9
+ gem.authors = ["tchak"]
10
+ gem.email = ["paul@chavard.net"]
11
+ gem.description = %q{QUnit test runner}
12
+ gem.summary = %q{Run QUnit test on Capybara}
13
+ gem.homepage = ""
14
+
15
+ gem.add_dependency 'capybara'
16
+
17
+ gem.files = `git ls-files`.split($\)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+ end
@@ -0,0 +1,40 @@
1
+ var Chinchilla = {
2
+ done: false,
3
+ dots: "",
4
+ results: []
5
+ };
6
+
7
+ Chinchilla.getResults = function() {
8
+ return JSON.stringify(Chinchilla.results);
9
+ };
10
+
11
+ var currentTest = {};
12
+ QUnit.testDone = function(results) {
13
+ Chinchilla.dots += (results.failed > 0 ? "F" : ".");
14
+ Chinchilla.results.push({
15
+ name: results.name,
16
+ passed: results.failed === 0,
17
+ message: currentTest.message
18
+ });
19
+
20
+ currentTest = {};
21
+ };
22
+
23
+ QUnit.log = function(results) {
24
+ if (!results.result) {
25
+ var message;
26
+ if (results.message) {
27
+ message = results.message;
28
+ } else {
29
+ message = "Expected '"+results.expected+"', got '"+results.actual+"'";
30
+ }
31
+ currentTest.message = message;
32
+ currentTest.trace = results.source;
33
+ }
34
+ };
35
+
36
+ QUnit.done = function(results) {
37
+ Chinchilla.done = true;
38
+ };
39
+
40
+ QUnit.config.autorun = false;
@@ -0,0 +1,23 @@
1
+ module Chinchilla
2
+ class Runner
3
+ class Example
4
+ def initialize(row)
5
+ @row = row
6
+ end
7
+
8
+ def passed?
9
+ @row['passed']
10
+ end
11
+
12
+ def failure_message
13
+ unless passed?
14
+ msg = []
15
+ msg << " Failed: #{@row['name']}"
16
+ msg << " #{@row['message']}"
17
+ msg << " in #{@row['trace']}" if @row['trace']
18
+ msg.join("\n")
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,68 @@
1
+ module Chinchilla
2
+ class Runner
3
+ class TestRunner
4
+ attr_reader :runner, :test
5
+
6
+ def initialize(runner, test)
7
+ @runner = runner
8
+ @test = test
9
+ end
10
+
11
+ def session
12
+ runner.session
13
+ end
14
+
15
+ def io
16
+ runner.io
17
+ end
18
+
19
+ def run
20
+ io.puts dots
21
+ io.puts failure_messages
22
+ io.puts "\n#{examples.size} assertions, #{failed_examples.size} failures"
23
+ passed?
24
+ end
25
+
26
+ def examples
27
+ @results ||= begin
28
+ session.visit(test.url)
29
+
30
+ previous_results = ""
31
+
32
+ session.wait_until(300) do
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
39
+
40
+ dots = session.evaluate_script('Chinchilla.dots')
41
+ io.print dots.sub(/^#{Regexp.escape(previous_results)}/, '')
42
+
43
+ JSON.parse(session.evaluate_script('Chinchilla.getResults()')).map do |row|
44
+ Example.new(row)
45
+ end
46
+ end
47
+ end
48
+
49
+ def failed_examples
50
+ examples.select { |example| not example.passed? }
51
+ end
52
+
53
+ def passed?
54
+ examples.all? { |example| example.passed? }
55
+ end
56
+
57
+ def dots
58
+ examples; ""
59
+ end
60
+
61
+ def failure_messages
62
+ unless passed?
63
+ examples.map { |example| example.failure_message }.compact.join("\n\n")
64
+ end
65
+ end
66
+ end
67
+ end
68
+ end
@@ -0,0 +1,69 @@
1
+ require 'chinchilla/runner/example'
2
+ require 'chinchilla/runner/test_runner'
3
+
4
+ module Chinchilla
5
+ class Runner
6
+ attr_reader :suite, :io
7
+
8
+ def initialize(io=STDOUT)
9
+ @io = io
10
+ end
11
+
12
+ def test_runner(test)
13
+ TestRunner.new(self, test)
14
+ end
15
+
16
+ def run
17
+ before = Time.now
18
+
19
+ io.puts ""
20
+ io.puts dots.to_s
21
+ io.puts ""
22
+ if failure_messages
23
+ io.puts failure_messages
24
+ io.puts ""
25
+ end
26
+
27
+ seconds = "%.2f" % (Time.now - before)
28
+ io.puts "Finished in #{seconds} seconds"
29
+ io.puts "#{examples.size} assertions, #{failed_examples.size} failures"
30
+ passed?
31
+ end
32
+
33
+ def examples
34
+ test_runners.map { |test_runner| test_runner.examples }.flatten
35
+ end
36
+
37
+ def failed_examples
38
+ examples.select { |example| not example.passed? }
39
+ end
40
+
41
+ def passed?
42
+ test_runners.all? { |test_runner| test_runner.passed? }
43
+ end
44
+
45
+ def dots
46
+ test_runners.map { |test_runner| test_runner.dots }.join
47
+ end
48
+
49
+ def failure_messages
50
+ unless passed?
51
+ test_runners.map { |test_runner| test_runner.failure_messages }.compact.join("\n\n")
52
+ end
53
+ end
54
+
55
+ def session
56
+ @session ||= Capybara::Session.new(Chinchilla.driver, Chinchilla.application)
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) }
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,13 @@
1
+ module Chinchilla
2
+ class Suite
3
+ attr_reader :mounted_at
4
+
5
+ def initialize(mounted_at)
6
+ @mounted_at = mounted_at
7
+ end
8
+
9
+ def tests
10
+ [Test.new(mounted_at)]
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,9 @@
1
+ module Chinchilla
2
+ class Test
3
+ attr_reader :url
4
+
5
+ def initialize(url)
6
+ @url = url
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,3 @@
1
+ module Chinchilla
2
+ VERSION = "0.0.1"
3
+ end
data/lib/chinchilla.rb ADDED
@@ -0,0 +1,17 @@
1
+ require "chinchilla/version"
2
+ require "chinchilla/test"
3
+ require "chinchilla/suite"
4
+ require "chinchilla/runner"
5
+
6
+ module Chinchilla
7
+ class Engine < ::Rails::Engine
8
+ end
9
+
10
+ class << self
11
+ attr_accessor :application, :driver, :mounted_at
12
+
13
+ def configure
14
+ yield self
15
+ end
16
+ end
17
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: chinchilla
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - tchak
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-07-02 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: capybara
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: QUnit test runner
31
+ email:
32
+ - paul@chavard.net
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - .gitignore
38
+ - Gemfile
39
+ - LICENSE
40
+ - README.md
41
+ - Rakefile
42
+ - chinchilla.gemspec
43
+ - lib/assets/javascripts/chinchilla.js
44
+ - lib/chinchilla.rb
45
+ - lib/chinchilla/runner.rb
46
+ - lib/chinchilla/runner/example.rb
47
+ - lib/chinchilla/runner/test_runner.rb
48
+ - lib/chinchilla/suite.rb
49
+ - lib/chinchilla/test.rb
50
+ - lib/chinchilla/version.rb
51
+ homepage: ''
52
+ licenses: []
53
+ post_install_message:
54
+ rdoc_options: []
55
+ require_paths:
56
+ - lib
57
+ required_ruby_version: !ruby/object:Gem::Requirement
58
+ none: false
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ segments:
64
+ - 0
65
+ hash: -1080271884884927784
66
+ required_rubygems_version: !ruby/object:Gem::Requirement
67
+ none: false
68
+ requirements:
69
+ - - ! '>='
70
+ - !ruby/object:Gem::Version
71
+ version: '0'
72
+ segments:
73
+ - 0
74
+ hash: -1080271884884927784
75
+ requirements: []
76
+ rubyforge_project:
77
+ rubygems_version: 1.8.23
78
+ signing_key:
79
+ specification_version: 3
80
+ summary: Run QUnit test on Capybara
81
+ test_files: []