zfben_hanoi 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +4 -0
- data/Gemfile +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +105 -0
- data/Rakefile +8 -0
- data/bin/hanoi +26 -0
- data/lib/hanoi/browser.rb +65 -0
- data/lib/hanoi/browsers/chrome.rb +35 -0
- data/lib/hanoi/browsers/firefox.rb +11 -0
- data/lib/hanoi/browsers/internet_explorer.rb +26 -0
- data/lib/hanoi/browsers/konqueror.rb +29 -0
- data/lib/hanoi/browsers/opera.rb +17 -0
- data/lib/hanoi/browsers/safari.rb +5 -0
- data/lib/hanoi/browsers/webkit.rb +35 -0
- data/lib/hanoi/javascript_test_task.rb +202 -0
- data/lib/hanoi/test_case.rb +45 -0
- data/lib/hanoi/test_results.rb +25 -0
- data/lib/hanoi/test_suite_results.rb +40 -0
- data/lib/hanoi/webrick.rb +103 -0
- data/lib/zfben_hanoi.rb +16 -0
- data/spec/browser_spec.rb +68 -0
- data/spec/browsers/chrome_spec.rb +65 -0
- data/spec/browsers/firefox_spec.rb +67 -0
- data/spec/browsers/internet_explorer_spec.rb +50 -0
- data/spec/browsers/konqueror_spec.rb +41 -0
- data/spec/browsers/opera_spec.rb +67 -0
- data/spec/browsers/safari_spec.rb +39 -0
- data/spec/browsers/webkit_spec.rb +69 -0
- data/spec/spec_helper.rb +23 -0
- data/templates/assets/callback.js +13 -0
- data/templates/example_fixtures.html +3 -0
- data/templates/example_test.js +4 -0
- data/templates/fresh_rakefile +15 -0
- data/templates/test_case.erb +29 -0
- data/zfben_hanoi.gemspec +19 -0
- metadata +81 -0
@@ -0,0 +1,41 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
2
|
+
|
3
|
+
describe "Konqueror" do
|
4
|
+
before :each do
|
5
|
+
@browser = Konqueror.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "Cross OS Konqueror", :shared => true do
|
9
|
+
it "return name" do
|
10
|
+
@browser.name.should == "Konqueror"
|
11
|
+
end
|
12
|
+
|
13
|
+
it "should not be supported" do
|
14
|
+
@browser.should_not be_supported
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "Mac OS X" do
|
19
|
+
it_should_behave_like "Cross OS Konqueror"
|
20
|
+
end if macos?
|
21
|
+
|
22
|
+
describe "Windows" do
|
23
|
+
it_should_behave_like "Cross OS Konqueror"
|
24
|
+
end if windows?
|
25
|
+
|
26
|
+
describe "Linux" do
|
27
|
+
it "return name" do
|
28
|
+
@browser.name.should == "konqueror"
|
29
|
+
end
|
30
|
+
|
31
|
+
it "should be supported" do
|
32
|
+
@browser.should be_supported
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should visit a given url" do
|
36
|
+
url = "http://localhost"
|
37
|
+
Kernel.expects(:system).with("kfmclient openURL #{url}")
|
38
|
+
@browser.visit(url)
|
39
|
+
end
|
40
|
+
end if linux?
|
41
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
2
|
+
|
3
|
+
describe "Opera" do
|
4
|
+
before :each do
|
5
|
+
@browser = Opera.new
|
6
|
+
@url = "http://localhost"
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "Cross OS Opera", :shared => true do
|
10
|
+
it "should be supported" do
|
11
|
+
@browser.should be_supported
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe "Mac OS X" do
|
16
|
+
it_should_behave_like "Cross OS Opera"
|
17
|
+
|
18
|
+
it "return name" do
|
19
|
+
@browser.name.should == "Opera"
|
20
|
+
end
|
21
|
+
|
22
|
+
it "should have a path" do
|
23
|
+
expected = File.expand_path("/Applications/#{@browser.escaped_name}.app")
|
24
|
+
@browser.path.should == expected
|
25
|
+
end
|
26
|
+
|
27
|
+
it "should visit a given url" do
|
28
|
+
@browser.expects(:applescript).with(%(tell application "#{@browser.name}" to GetURL "#{@url}"))
|
29
|
+
@browser.visit(@url)
|
30
|
+
end
|
31
|
+
end if macos?
|
32
|
+
|
33
|
+
describe "Windows" do
|
34
|
+
it_should_behave_like "Cross OS Opera"
|
35
|
+
|
36
|
+
it "return name" do
|
37
|
+
@browser.name.should == "Opera"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should have a path" do
|
41
|
+
@browser.path.should == 'c:\Program Files\Opera\Opera.exe'
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should visit a given url" do
|
45
|
+
Kernel.expects(:system).with("#{@browser.path} #{@url}")
|
46
|
+
@browser.visit(@url)
|
47
|
+
end
|
48
|
+
end if windows?
|
49
|
+
|
50
|
+
describe "Linux" do
|
51
|
+
it_should_behave_like "Cross OS Opera"
|
52
|
+
|
53
|
+
it "return name" do
|
54
|
+
@browser.name.should == "opera"
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should have a path" do
|
58
|
+
path = "/usr/bin/#{@browser.name}"
|
59
|
+
Opera.new(path).path.should == path
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should visit a given url" do
|
63
|
+
Kernel.expects(:system).with("#{@browser.name} #{@url}")
|
64
|
+
@browser.visit(@url)
|
65
|
+
end
|
66
|
+
end if linux?
|
67
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
2
|
+
|
3
|
+
describe "Safari" do
|
4
|
+
before :each do
|
5
|
+
@browser = Safari.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "Cross OS Safari", :shared => true do
|
9
|
+
it "should be supported" do
|
10
|
+
@browser.should be_supported
|
11
|
+
end
|
12
|
+
|
13
|
+
it "return name" do
|
14
|
+
@browser.name.should == "Safari"
|
15
|
+
end
|
16
|
+
|
17
|
+
it "should be kind of Webkit" do
|
18
|
+
@browser.should be_kind_of(Webkit)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe "Mac OS X" do
|
23
|
+
it_should_behave_like "Cross OS Safari"
|
24
|
+
end if macos?
|
25
|
+
|
26
|
+
describe "Windows" do
|
27
|
+
it_should_behave_like "Cross OS Safari"
|
28
|
+
end if windows?
|
29
|
+
|
30
|
+
describe "Linux" do
|
31
|
+
it "return name" do
|
32
|
+
@browser.name.should == "safari"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "should not be supported" do
|
36
|
+
@browser.should_not be_supported
|
37
|
+
end
|
38
|
+
end if linux?
|
39
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), "/../spec_helper")
|
2
|
+
|
3
|
+
describe "Webkit" do
|
4
|
+
before :each do
|
5
|
+
@browser = Webkit.new
|
6
|
+
end
|
7
|
+
|
8
|
+
describe "Cross OS Webkit", :shared => true do
|
9
|
+
it "should be supported" do
|
10
|
+
@browser.should be_supported
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
describe "Mac OS X" do
|
15
|
+
it_should_behave_like "Cross OS Webkit"
|
16
|
+
|
17
|
+
it "return name" do
|
18
|
+
@browser.name.should == "Webkit"
|
19
|
+
end
|
20
|
+
|
21
|
+
it "should setup" do
|
22
|
+
@browser.expects(:applescript).with(%(tell application "#{@browser.name}" to make new document))
|
23
|
+
@browser.setup
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should have a path" do
|
27
|
+
@browser.path.should == "/Applications/Webkit.app"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should visit a given url" do
|
31
|
+
url = "http://localhost"
|
32
|
+
@browser.expects(:applescript).with(%(tell application "#{@browser.name}" to set URL of front document to "#{url}"))
|
33
|
+
@browser.visit(url)
|
34
|
+
end
|
35
|
+
end if macos?
|
36
|
+
|
37
|
+
describe "Windows" do
|
38
|
+
it_should_behave_like "Cross OS Webkit"
|
39
|
+
|
40
|
+
it "return name" do
|
41
|
+
@browser.name.should == "Webkit"
|
42
|
+
end
|
43
|
+
|
44
|
+
it "should setup" do
|
45
|
+
@browser.should_not_receive(:applescript)
|
46
|
+
@browser.setup
|
47
|
+
end
|
48
|
+
|
49
|
+
it "should have a path" do
|
50
|
+
expected = File.join(ENV['WEBKIT_HOME'] || ENV['ProgramFiles'] || 'C:\Program Files', 'Webkit', 'webkit.exe')
|
51
|
+
@browser.path.should == expected
|
52
|
+
end
|
53
|
+
|
54
|
+
it "should visit a given url" do
|
55
|
+
Kernel.expects(:system).with("#{@browser.path} #{@url}")
|
56
|
+
@browser.visit(@url)
|
57
|
+
end
|
58
|
+
end if windows?
|
59
|
+
|
60
|
+
describe "Linux" do
|
61
|
+
it "return name" do
|
62
|
+
@browser.name.should == "webkit"
|
63
|
+
end
|
64
|
+
|
65
|
+
it "should not be supported" do
|
66
|
+
@browser.should_not be_supported
|
67
|
+
end
|
68
|
+
end if linux?
|
69
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
$: << File.join(File.dirname(__FILE__), "/../lib")
|
2
|
+
require "rubygems"
|
3
|
+
require "mocha"
|
4
|
+
require "zfben_hanoi"
|
5
|
+
|
6
|
+
module Kernel
|
7
|
+
alias_method :old_system, :system
|
8
|
+
def system(*args)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
# TODO delegation
|
13
|
+
def macos?
|
14
|
+
Browser.new.macos?
|
15
|
+
end
|
16
|
+
|
17
|
+
def windows?
|
18
|
+
Browser.new.windows?
|
19
|
+
end
|
20
|
+
|
21
|
+
def linux?
|
22
|
+
Browser.new.linux?
|
23
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
_done = QUnit.done;
|
2
|
+
if(QUnit.urlParams.resultsURL){
|
3
|
+
QUnit.done = function(result){
|
4
|
+
$.get(QUnit.urlParams.resultsURL, {
|
5
|
+
modules: result.total,
|
6
|
+
tests: result.total,
|
7
|
+
assertions: result.total,
|
8
|
+
failures: result.failed,
|
9
|
+
errors: result.failed
|
10
|
+
});
|
11
|
+
_done(arguments[0]);
|
12
|
+
}
|
13
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require "rubygems"
|
2
|
+
require "hanoi"
|
3
|
+
|
4
|
+
namespace :test do
|
5
|
+
desc "Runs all the JavaScript tests and collects the results"
|
6
|
+
JavaScriptTestTask.new(:js) do |t|
|
7
|
+
test_cases = ENV['TESTS'] && ENV['TESTS'].split(',')
|
8
|
+
browsers = ENV['BROWSERS'] && ENV['BROWSERS'].split(',')
|
9
|
+
# change this path according to your configuration,
|
10
|
+
# it should indicate the root directory of your JavaScript files
|
11
|
+
sources_directory = File.expand_path(File.dirname(__FILE__) + "/src")
|
12
|
+
|
13
|
+
t.setup(sources_directory, test_cases, browsers)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta http-equiv="Content-type" content="text/html; charset=utf-8">
|
5
|
+
<title><%= @test_case.name %></title>
|
6
|
+
|
7
|
+
<script src="http://code.jquery.com/jquery.min.js"></script>
|
8
|
+
<script src="http://code.jquery.com/qunit/qunit-git.js"></script>
|
9
|
+
<script src="/callback.js"></script>
|
10
|
+
<link rel="stylesheet" href="http://code.jquery.com/qunit/qunit-git.css" type="text/css" media="screen" />
|
11
|
+
|
12
|
+
<script src="<%= @test_case.target %>" type="text/javascript" charset="utf-8"></script>
|
13
|
+
|
14
|
+
<script>
|
15
|
+
$(document).ready(function(){
|
16
|
+
<%= @test_case.content %>
|
17
|
+
});
|
18
|
+
</script>
|
19
|
+
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<h1 id="qunit-header"><%= @test_case.name.upcase %></h1>
|
23
|
+
<h2 id="qunit-banner"></h2>
|
24
|
+
<div id="qunit-testrunner-toolbar"></div>
|
25
|
+
<h2 id="qunit-userAgent"></h2>
|
26
|
+
<ol id="qunit-tests"></ol>
|
27
|
+
<div id="qunit-fixture"><%= @test_case.html_fixtures %></div>
|
28
|
+
</body>
|
29
|
+
</html>
|
data/zfben_hanoi.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "zfben_hanoi"
|
6
|
+
s.version = '0.0.1'
|
7
|
+
s.authors = ["Ben"]
|
8
|
+
s.email = ["ben@zfben.com"]
|
9
|
+
s.homepage = "https://github.com/benz303/zfben_hanoi"
|
10
|
+
s.summary = %q{}
|
11
|
+
s.description = %q{}
|
12
|
+
|
13
|
+
s.rubyforge_project = "zfben_hanoi"
|
14
|
+
|
15
|
+
s.files = `git ls-files`.split("\n")
|
16
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
|
+
s.require_paths = ["lib"]
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,81 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: zfben_hanoi
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Ben
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-13 00:00:00.000000000Z
|
13
|
+
dependencies: []
|
14
|
+
description: ''
|
15
|
+
email:
|
16
|
+
- ben@zfben.com
|
17
|
+
executables:
|
18
|
+
- hanoi
|
19
|
+
extensions: []
|
20
|
+
extra_rdoc_files: []
|
21
|
+
files:
|
22
|
+
- .gitignore
|
23
|
+
- Gemfile
|
24
|
+
- MIT-LICENSE
|
25
|
+
- README.md
|
26
|
+
- Rakefile
|
27
|
+
- bin/hanoi
|
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
|
41
|
+
- lib/zfben_hanoi.rb
|
42
|
+
- spec/browser_spec.rb
|
43
|
+
- spec/browsers/chrome_spec.rb
|
44
|
+
- spec/browsers/firefox_spec.rb
|
45
|
+
- spec/browsers/internet_explorer_spec.rb
|
46
|
+
- spec/browsers/konqueror_spec.rb
|
47
|
+
- spec/browsers/opera_spec.rb
|
48
|
+
- spec/browsers/safari_spec.rb
|
49
|
+
- spec/browsers/webkit_spec.rb
|
50
|
+
- spec/spec_helper.rb
|
51
|
+
- templates/assets/callback.js
|
52
|
+
- templates/example_fixtures.html
|
53
|
+
- templates/example_test.js
|
54
|
+
- templates/fresh_rakefile
|
55
|
+
- templates/test_case.erb
|
56
|
+
- zfben_hanoi.gemspec
|
57
|
+
homepage: https://github.com/benz303/zfben_hanoi
|
58
|
+
licenses: []
|
59
|
+
post_install_message:
|
60
|
+
rdoc_options: []
|
61
|
+
require_paths:
|
62
|
+
- lib
|
63
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
71
|
+
requirements:
|
72
|
+
- - ! '>='
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '0'
|
75
|
+
requirements: []
|
76
|
+
rubyforge_project: zfben_hanoi
|
77
|
+
rubygems_version: 1.8.6
|
78
|
+
signing_key:
|
79
|
+
specification_version: 3
|
80
|
+
summary: ''
|
81
|
+
test_files: []
|