zfben_hanoi 0.0.1 → 0.0.2
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/bin/{hanoi → zfben_hanoi} +1 -1
- data/lib/{hanoi → zfben_hanoi}/browser.rb +0 -0
- data/lib/{hanoi → zfben_hanoi}/browsers/firefox.rb +1 -1
- data/lib/{hanoi → zfben_hanoi}/javascript_test_task.rb +3 -15
- data/lib/{hanoi → zfben_hanoi}/test_case.rb +0 -0
- data/lib/zfben_hanoi/test_results.rb +18 -0
- data/lib/zfben_hanoi/test_suite_results.rb +29 -0
- data/lib/{hanoi → zfben_hanoi}/webrick.rb +0 -0
- data/lib/zfben_hanoi.rb +8 -16
- data/templates/assets/callback.js +3 -5
- data/templates/fresh_rakefile +2 -2
- data/zfben_hanoi.gemspec +1 -1
- metadata +10 -16
- data/lib/hanoi/browsers/chrome.rb +0 -35
- data/lib/hanoi/browsers/internet_explorer.rb +0 -26
- data/lib/hanoi/browsers/konqueror.rb +0 -29
- data/lib/hanoi/browsers/opera.rb +0 -17
- data/lib/hanoi/browsers/safari.rb +0 -5
- data/lib/hanoi/browsers/webkit.rb +0 -35
- data/lib/hanoi/test_results.rb +0 -25
- data/lib/hanoi/test_suite_results.rb +0 -40
data/bin/{hanoi → zfben_hanoi}
RENAMED
@@ -6,7 +6,7 @@ raise "Unknown path '#{path}'" unless File.directory?(path)
|
|
6
6
|
templates_path = File.expand_path(File.dirname(__FILE__) + "/../templates")
|
7
7
|
|
8
8
|
# Rakefile
|
9
|
-
File.open(File.join(path, "Rakefile"), "a") { |f| f.write(File.
|
9
|
+
File.open(File.join(path, "Rakefile"), "a") { |f| f.write(File.read(File.join(templates_path, "fresh_rakefile")))}
|
10
10
|
|
11
11
|
# JavaScript test directory
|
12
12
|
name = File.directory?(File.join(path, "spec")) ? "spec" : "test"
|
File without changes
|
@@ -1,5 +1,5 @@
|
|
1
1
|
class JavaScriptTestTask < ::Rake::TaskLib
|
2
|
-
BROWSERS = %w(
|
2
|
+
BROWSERS = %w( firefox ).freeze
|
3
3
|
attr_reader :sources_directory
|
4
4
|
|
5
5
|
def initialize(name = :test)
|
@@ -45,7 +45,7 @@ class JavaScriptTestTask < ::Rake::TaskLib
|
|
45
45
|
|
46
46
|
print "\nFinished in #{Time.now - t0} seconds."
|
47
47
|
print @test_suite_results
|
48
|
-
browser.teardown
|
48
|
+
browser.teardown unless @test_suite_results.failed?
|
49
49
|
else
|
50
50
|
puts "\nSkipping #{browser}, not supported on this OS or not installed."
|
51
51
|
end
|
@@ -55,7 +55,7 @@ class JavaScriptTestTask < ::Rake::TaskLib
|
|
55
55
|
@server.shutdown
|
56
56
|
t.join
|
57
57
|
|
58
|
-
exit 1 if @test_suite_results.
|
58
|
+
exit 1 if @test_suite_results.failed?
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
@@ -90,20 +90,8 @@ class JavaScriptTestTask < ::Rake::TaskLib
|
|
90
90
|
def browser(browser)
|
91
91
|
browser =
|
92
92
|
case(browser)
|
93
|
-
when :chrome
|
94
|
-
Chrome.new
|
95
93
|
when :firefox
|
96
94
|
Firefox.new
|
97
|
-
when :safari
|
98
|
-
Safari.new
|
99
|
-
when :ie
|
100
|
-
InternetExplorer.new
|
101
|
-
when :konqueror
|
102
|
-
Konqueror.new
|
103
|
-
when :opera
|
104
|
-
Opera.new
|
105
|
-
when :webkit
|
106
|
-
Webkit.new
|
107
95
|
else
|
108
96
|
browser
|
109
97
|
end
|
File without changes
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class TestResults
|
2
|
+
attr_reader :total, :passed, :failed, :filename
|
3
|
+
def initialize(query, filename)
|
4
|
+
@total = query['total'].to_i
|
5
|
+
@passed = query['passed'].to_i
|
6
|
+
@failed = query['failed'].to_i
|
7
|
+
@filename = filename
|
8
|
+
end
|
9
|
+
|
10
|
+
def failed?
|
11
|
+
@failed > 0
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
return "F" if failed?
|
16
|
+
"."
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
class TestSuiteResults
|
2
|
+
def initialize
|
3
|
+
@total = 0
|
4
|
+
@passed = 0
|
5
|
+
@failed = 0
|
6
|
+
@failed_files = []
|
7
|
+
end
|
8
|
+
|
9
|
+
def <<(result)
|
10
|
+
@total += result.total
|
11
|
+
@passed += result.passed
|
12
|
+
@failed += result.failed
|
13
|
+
@filed_files.push(result.filename) if result.failed?
|
14
|
+
end
|
15
|
+
|
16
|
+
def failed?
|
17
|
+
@failed > 0
|
18
|
+
end
|
19
|
+
|
20
|
+
def to_s
|
21
|
+
str = ""
|
22
|
+
str << "\n Filed: #{@failed_files.join(', ')}" if failed?
|
23
|
+
"#{str}\n#{summary}\n\n"
|
24
|
+
end
|
25
|
+
|
26
|
+
def summary
|
27
|
+
"#{@total} tests, #{@passed} passed, #{@failed} failed."
|
28
|
+
end
|
29
|
+
end
|
File without changes
|
data/lib/zfben_hanoi.rb
CHANGED
@@ -1,16 +1,8 @@
|
|
1
|
-
require
|
2
|
-
require
|
3
|
-
require
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
require
|
8
|
-
|
9
|
-
require "hanoi/browsers/konqueror"
|
10
|
-
require "hanoi/browsers/webkit"
|
11
|
-
require "hanoi/browsers/safari"
|
12
|
-
require "hanoi/browsers/opera"
|
13
|
-
require "hanoi/test_case"
|
14
|
-
require "hanoi/test_results"
|
15
|
-
require "hanoi/test_suite_results"
|
16
|
-
require "hanoi/javascript_test_task"
|
1
|
+
require 'erb'
|
2
|
+
require 'webrick'
|
3
|
+
require 'rake/tasklib'
|
4
|
+
|
5
|
+
path = File.realpath(File.join(File.dirname(__FILE__), 'zfben_hanoi'))
|
6
|
+
['webrick.rb', 'browser.rb', 'browsers/firefox.rb', 'test_case.rb', 'test_results.rb', 'test_suite_results.rb', 'javascript_test_task.rb'].each do |f|
|
7
|
+
require File.join(path, f)
|
8
|
+
end
|
@@ -2,11 +2,9 @@ _done = QUnit.done;
|
|
2
2
|
if(QUnit.urlParams.resultsURL){
|
3
3
|
QUnit.done = function(result){
|
4
4
|
$.get(QUnit.urlParams.resultsURL, {
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
failures: result.failed,
|
9
|
-
errors: result.failed
|
5
|
+
total: result.total,
|
6
|
+
passed: result.passed,
|
7
|
+
failed: result.failed
|
10
8
|
});
|
11
9
|
_done(arguments[0]);
|
12
10
|
}
|
data/templates/fresh_rakefile
CHANGED
data/zfben_hanoi.gemspec
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: zfben_hanoi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -15,7 +15,7 @@ description: ''
|
|
15
15
|
email:
|
16
16
|
- ben@zfben.com
|
17
17
|
executables:
|
18
|
-
-
|
18
|
+
- zfben_hanoi
|
19
19
|
extensions: []
|
20
20
|
extra_rdoc_files: []
|
21
21
|
files:
|
@@ -24,21 +24,15 @@ files:
|
|
24
24
|
- MIT-LICENSE
|
25
25
|
- README.md
|
26
26
|
- Rakefile
|
27
|
-
- bin/
|
28
|
-
- lib/hanoi/browser.rb
|
29
|
-
- lib/hanoi/browsers/chrome.rb
|
30
|
-
- lib/hanoi/browsers/firefox.rb
|
31
|
-
- lib/hanoi/browsers/internet_explorer.rb
|
32
|
-
- lib/hanoi/browsers/konqueror.rb
|
33
|
-
- lib/hanoi/browsers/opera.rb
|
34
|
-
- lib/hanoi/browsers/safari.rb
|
35
|
-
- lib/hanoi/browsers/webkit.rb
|
36
|
-
- lib/hanoi/javascript_test_task.rb
|
37
|
-
- lib/hanoi/test_case.rb
|
38
|
-
- lib/hanoi/test_results.rb
|
39
|
-
- lib/hanoi/test_suite_results.rb
|
40
|
-
- lib/hanoi/webrick.rb
|
27
|
+
- bin/zfben_hanoi
|
41
28
|
- lib/zfben_hanoi.rb
|
29
|
+
- lib/zfben_hanoi/browser.rb
|
30
|
+
- lib/zfben_hanoi/browsers/firefox.rb
|
31
|
+
- lib/zfben_hanoi/javascript_test_task.rb
|
32
|
+
- lib/zfben_hanoi/test_case.rb
|
33
|
+
- lib/zfben_hanoi/test_results.rb
|
34
|
+
- lib/zfben_hanoi/test_suite_results.rb
|
35
|
+
- lib/zfben_hanoi/webrick.rb
|
42
36
|
- spec/browser_spec.rb
|
43
37
|
- spec/browsers/chrome_spec.rb
|
44
38
|
- spec/browsers/firefox_spec.rb
|
@@ -1,35 +0,0 @@
|
|
1
|
-
class Chrome < Browser
|
2
|
-
def initialize(path = nil)
|
3
|
-
@path = path || File.join(
|
4
|
-
ENV['UserPath'] || ENV['UserProfile'] || "C:/Documents and Settings/Administrator",
|
5
|
-
"AppData",
|
6
|
-
"Local",
|
7
|
-
"Google",
|
8
|
-
"Chrome",
|
9
|
-
"Application",
|
10
|
-
"chrome.exe"
|
11
|
-
)
|
12
|
-
end
|
13
|
-
|
14
|
-
def supported?
|
15
|
-
windows? || macos?
|
16
|
-
end
|
17
|
-
|
18
|
-
def installed?
|
19
|
-
if macos?
|
20
|
-
File.exist?("/Applications/#{name}.app")
|
21
|
-
else
|
22
|
-
super
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
def name
|
27
|
-
"Google Chrome"
|
28
|
-
end
|
29
|
-
|
30
|
-
def teardown
|
31
|
-
if macos?
|
32
|
-
system("killall #{escaped_name}")
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
class InternetExplorer < Browser
|
2
|
-
def setup
|
3
|
-
require 'win32ole' if windows?
|
4
|
-
end
|
5
|
-
|
6
|
-
def supported?
|
7
|
-
windows?
|
8
|
-
end
|
9
|
-
|
10
|
-
def runnable?
|
11
|
-
supported?
|
12
|
-
end
|
13
|
-
|
14
|
-
def visit(url)
|
15
|
-
if windows?
|
16
|
-
ie = WIN32OLE.new('InternetExplorer.Application')
|
17
|
-
ie.visible = true
|
18
|
-
ie.Navigate(url)
|
19
|
-
sleep 0.01 while ie.Busy || ie.ReadyState != 4
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def name
|
24
|
-
"Internet Explorer"
|
25
|
-
end
|
26
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
class Konqueror < Browser
|
2
|
-
@@config_dir = File.join((ENV['HOME'] || ''), '.kde', 'share', 'config')
|
3
|
-
@@global_config = File.join(@@config_dir, 'kdeglobals')
|
4
|
-
@@konqueror_config = File.join(@@config_dir, 'konquerorrc')
|
5
|
-
|
6
|
-
def supported?
|
7
|
-
linux?
|
8
|
-
end
|
9
|
-
|
10
|
-
# Forces KDE's default browser to be Konqueror during the tests, and forces
|
11
|
-
# Konqueror to open external URL requests in new tabs instead of a new
|
12
|
-
# window.
|
13
|
-
def setup
|
14
|
-
cd @@config_dir, :verbose => false do
|
15
|
-
copy @@global_config, "#{@@global_config}.bak", :preserve => true, :verbose => false
|
16
|
-
copy @@konqueror_config, "#{@@konqueror_config}.bak", :preserve => true, :verbose => false
|
17
|
-
# Too lazy to write it in Ruby... Is sed dependency so bad?
|
18
|
-
system "sed -ri /^BrowserApplication=/d '#{@@global_config}'"
|
19
|
-
system "sed -ri /^KonquerorTabforExternalURL=/s:false:true: '#{@@konqueror_config}'"
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
def teardown
|
24
|
-
cd @@config_dir, :verbose => false do
|
25
|
-
copy "#{@@global_config}.bak", @@global_config, :preserve => true, :verbose => false
|
26
|
-
copy "#{@@konqueror_config}.bak", @@konqueror_config, :preserve => true, :verbose => false
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
data/lib/hanoi/browsers/opera.rb
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
class Opera < Browser
|
2
|
-
def initialize(path = 'c:\Program Files\Opera\Opera.exe')
|
3
|
-
@path = path
|
4
|
-
end
|
5
|
-
|
6
|
-
def setup
|
7
|
-
if windows?
|
8
|
-
puts %{
|
9
|
-
MAJOR ANNOYANCE on Windows.
|
10
|
-
You have to shut down Opera manually after each test
|
11
|
-
for the script to proceed.
|
12
|
-
Any suggestions on fixing this is GREATLY appreciated!
|
13
|
-
Thank you for your understanding.
|
14
|
-
}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
@@ -1,35 +0,0 @@
|
|
1
|
-
class Webkit < Browser
|
2
|
-
def initialize(path = File.join(ENV['WEBKIT_HOME'] || ENV['ProgramFiles'] || 'C:\Program Files', 'Webkit', 'webkit.exe'))
|
3
|
-
@path = path
|
4
|
-
end
|
5
|
-
|
6
|
-
def supported?
|
7
|
-
macos? || windows?
|
8
|
-
end
|
9
|
-
|
10
|
-
def setup
|
11
|
-
applescript(%(tell application "#{name}" to make new document)) if macos?
|
12
|
-
end
|
13
|
-
|
14
|
-
def visit(url)
|
15
|
-
if macos?
|
16
|
-
applescript(%(tell application "#{name}" to set URL of front document to "#{url}"))
|
17
|
-
elsif windows?
|
18
|
-
system("#{path} #{url}")
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
def teardown
|
23
|
-
#applescript('tell application "Safari" to close front document')
|
24
|
-
|
25
|
-
if macos?
|
26
|
-
system("killall #{escaped_name}")
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
private
|
31
|
-
def applescript(script)
|
32
|
-
raise "Can't run AppleScript on #{host}" unless macos?
|
33
|
-
system "osascript -e '#{script}' 2>&1 >/dev/null"
|
34
|
-
end
|
35
|
-
end
|
data/lib/hanoi/test_results.rb
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
class TestResults
|
2
|
-
attr_reader :modules, :tests, :assertions, :failures, :errors, :filename
|
3
|
-
def initialize(query, filename)
|
4
|
-
@modules = query['modules'].to_i
|
5
|
-
@tests = query['tests'].to_i
|
6
|
-
@assertions = query['assertions'].to_i
|
7
|
-
@failures = query['failures'].to_i
|
8
|
-
@errors = query['errors'].to_i
|
9
|
-
@filename = filename
|
10
|
-
end
|
11
|
-
|
12
|
-
def error?
|
13
|
-
@errors > 0
|
14
|
-
end
|
15
|
-
|
16
|
-
def failure?
|
17
|
-
@failures > 0
|
18
|
-
end
|
19
|
-
|
20
|
-
def to_s
|
21
|
-
return "E" if error?
|
22
|
-
return "F" if failure?
|
23
|
-
"."
|
24
|
-
end
|
25
|
-
end
|
@@ -1,40 +0,0 @@
|
|
1
|
-
class TestSuiteResults
|
2
|
-
def initialize
|
3
|
-
@modules = 0
|
4
|
-
@tests = 0
|
5
|
-
@assertions = 0
|
6
|
-
@failures = 0
|
7
|
-
@errors = 0
|
8
|
-
@error_files = []
|
9
|
-
@failure_files = []
|
10
|
-
end
|
11
|
-
|
12
|
-
def <<(result)
|
13
|
-
@modules += result.modules
|
14
|
-
@tests += result.tests
|
15
|
-
@assertions += result.assertions
|
16
|
-
@failures += result.failures
|
17
|
-
@errors += result.errors
|
18
|
-
@error_files.push(result.filename) if result.error?
|
19
|
-
@failure_files.push(result.filename) if result.failure?
|
20
|
-
end
|
21
|
-
|
22
|
-
def error?
|
23
|
-
@errors > 0
|
24
|
-
end
|
25
|
-
|
26
|
-
def failure?
|
27
|
-
@failures > 0
|
28
|
-
end
|
29
|
-
|
30
|
-
def to_s
|
31
|
-
str = ""
|
32
|
-
str << "\n Failures: #{@failure_files.join(', ')}" if failure?
|
33
|
-
str << "\n Errors: #{@error_files.join(', ')}" if error?
|
34
|
-
"#{str}\n#{summary}\n\n"
|
35
|
-
end
|
36
|
-
|
37
|
-
def summary
|
38
|
-
"#{@modules} modules, #{@tests} tests, #{@assertions} assertions, #{@failures} failures, #{@errors} errors."
|
39
|
-
end
|
40
|
-
end
|