hanoi 0.0.2 → 0.0.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Luca Guidi
1
+ Copyright (c) 2009 - 2010 Luca Guidi
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
data/README.md CHANGED
@@ -105,6 +105,10 @@ You have probably noticed that `file_2_fixtures.html` is missing, this because *
105
105
 
106
106
  To solve the annoying start page issue run: `defaults write org.webkit.nightly.WebKit StartPageDisabled -bool YES`
107
107
 
108
+ #### Webkit on Windows
109
+
110
+ Webkit hasn't a default path on Windows, please put under `C:\Program Files`, or specify the `WEBKIT_HOME` env var.
111
+
108
112
  ## Acknowledgements
109
113
 
110
114
  The Ruby libraries of Hanoi are a customization of the `jsblib.rb`, courtesy of the [Prototype](http://prototypejs.org) team.
@@ -117,4 +121,4 @@ Hanoi runs a customized version of `QUnit`, courtesy of the [jQuery](http://jque
117
121
 
118
122
  ## Copyright
119
123
 
120
- (c) 2009 Luca Guidi - [http://lucaguidi.com](http://lucaguidi.com), released under the MIT license
124
+ (c) 2009 - 2010 Luca Guidi - [http://lucaguidi.com](http://lucaguidi.com), released under the MIT license
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rake/testtask'
5
5
  require 'rake/rdoctask'
6
6
  require 'spec/rake/spectask'
7
7
 
8
- HANOI_VERSION = "0.0.2"
8
+ HANOI_VERSION = "0.0.3"
9
9
 
10
10
  task :default => :spec
11
11
 
@@ -1,7 +1,7 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = "hanoi"
3
- s.version = "0.0.2"
4
- s.date = "2009-12-26"
3
+ s.version = "0.0.3"
4
+ s.date = "2010-01-03"
5
5
  s.summary = "Automated jQuery tests with QUnit"
6
6
  s.author = "Luca Guidi"
7
7
  s.email = "guidi.luca@gmail.com"
@@ -1,8 +1,7 @@
1
1
  class Browser
2
2
  def supported?; true; end
3
- def setup ; end
4
- def open(url) ; end
5
- def teardown ; end
3
+ def setup; end
4
+ def teardown; end
6
5
 
7
6
  def host
8
7
  require 'rbconfig'
@@ -14,13 +13,25 @@ class Browser
14
13
  end
15
14
 
16
15
  def windows?
17
- host.include?('mswin')
16
+ /mswin|mingw/.match host
18
17
  end
19
18
 
20
19
  def linux?
21
20
  host.include?('linux')
22
21
  end
23
22
 
23
+ def installed?
24
+ if linux?
25
+ Kernel.system "which #{name}"
26
+ else
27
+ File.exist? path
28
+ end
29
+ end
30
+
31
+ def runnable?
32
+ supported? && installed?
33
+ end
34
+
24
35
  def visit(url)
25
36
  if macos?
26
37
  system("open -g -a #{path} '#{url}'")
@@ -2,8 +2,8 @@ class Chrome < Browser
2
2
  def initialize(path = nil)
3
3
  @path = path || File.join(
4
4
  ENV['UserPath'] || ENV['UserProfile'] || "C:/Documents and Settings/Administrator",
5
- "Local Settings",
6
- "Application Data",
5
+ "AppData",
6
+ "Local",
7
7
  "Google",
8
8
  "Chrome",
9
9
  "Application",
@@ -15,6 +15,14 @@ class Chrome < Browser
15
15
  windows? || macos?
16
16
  end
17
17
 
18
+ def installed?
19
+ if macos?
20
+ File.exist?("/Applications/#{name}.app")
21
+ else
22
+ super
23
+ end
24
+ end
25
+
18
26
  def name
19
27
  "Google Chrome"
20
28
  end
@@ -6,7 +6,11 @@ class InternetExplorer < Browser
6
6
  def supported?
7
7
  windows?
8
8
  end
9
-
9
+
10
+ def runnable?
11
+ supported?
12
+ end
13
+
10
14
  def visit(url)
11
15
  if windows?
12
16
  ie = WIN32OLE.new('InternetExplorer.Application')
@@ -26,12 +26,4 @@ class Konqueror < Browser
26
26
  copy "#{@@konqueror_config}.bak", @@konqueror_config, :preserve => true, :verbose => false
27
27
  end
28
28
  end
29
-
30
- def visit(url)
31
- system("kfmclient openURL #{url}")
32
- end
33
-
34
- def to_s
35
- "Konqueror"
36
- end
37
29
  end
@@ -1,4 +1,8 @@
1
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
+
2
6
  def supported?
3
7
  macos? || windows?
4
8
  end
@@ -29,7 +29,7 @@ class JavaScriptTestTask < ::Rake::TaskLib
29
29
 
30
30
  # run all combinations of browsers and tests
31
31
  @browsers.each do |browser|
32
- if browser.supported?
32
+ if browser.runnable?
33
33
  t0 = Time.now
34
34
  test_suite_results = TestSuiteResults.new
35
35
 
@@ -47,7 +47,7 @@ class JavaScriptTestTask < ::Rake::TaskLib
47
47
  print test_suite_results
48
48
  browser.teardown
49
49
  else
50
- puts "\nSkipping #{browser}, not supported on this OS."
50
+ puts "\nSkipping #{browser}, not supported on this OS or not installed."
51
51
  end
52
52
  end
53
53
 
@@ -13,7 +13,7 @@ describe "Browser" do
13
13
  method = case @browser.host
14
14
  when /darwin/
15
15
  :macos?
16
- when /mswin/
16
+ when /mswin/, /mingw/
17
17
  :windows?
18
18
  when /linux/
19
19
  :linux?
@@ -21,4 +21,48 @@ describe "Browser" do
21
21
 
22
22
  @browser.send(method).should be_true
23
23
  end
24
- end
24
+
25
+ describe "Cross OS Browser", :shared => true do
26
+ it "should check if installed" do
27
+ File.should_receive(:exist?).and_return true
28
+ @browser.should be_installed
29
+
30
+ File.should_receive(:exist?).and_return false
31
+ @browser.should_not be_installed
32
+ end
33
+
34
+ it "should check if runnable" do
35
+ File.should_receive(:exist?).and_return true
36
+ @browser.should be_runnable
37
+
38
+ File.should_receive(:exist?).and_return false
39
+ @browser.should_not be_runnable
40
+ end
41
+ end
42
+
43
+ describe "Mac Os X" do
44
+ it_should_behave_like "Cross OS Browser"
45
+ end if macos?
46
+
47
+ describe "Windows" do
48
+ it_should_behave_like "Cross OS Browser"
49
+ end if windows?
50
+
51
+ describe "Linux" do
52
+ it "should check if installed" do
53
+ Kernel.should_receive(:system).with("which browser").and_return true
54
+ @browser.should be_installed
55
+
56
+ Kernel.should_receive(:system).with("which browser").and_return false
57
+ @browser.should_not be_installed
58
+ end
59
+
60
+ it "should check if runnable" do
61
+ Kernel.should_receive(:system).with("which browser").and_return true
62
+ @browser.should be_runnable
63
+
64
+ Kernel.should_receive(:system).with("which browser").and_return false
65
+ @browser.should_not be_runnable
66
+ end
67
+ end if linux?
68
+ end
@@ -34,7 +34,17 @@ describe "Chrome" do
34
34
  it_should_behave_like "Cross OS Chrome"
35
35
 
36
36
  it "should have a path" do
37
- @browser.path.should == File.join(ENV['ProgramFiles'] || 'c:\Program Files', '\Mozilla Chrome\firefox.exe')
37
+ expected = File.join(
38
+ ENV['UserPath'] || ENV['UserProfile'] || "C:/Documents and Settings/Administrator",
39
+ "AppData",
40
+ "Local",
41
+ "Google",
42
+ "Chrome",
43
+ "Application",
44
+ "chrome.exe"
45
+ )
46
+
47
+ @browser.path.should == expected
38
48
  end
39
49
 
40
50
  it "should visit a given url" do
@@ -3,6 +3,7 @@ require File.join(File.dirname(__FILE__), "/../spec_helper")
3
3
  describe "InternetExplorer" do
4
4
  before :each do
5
5
  @browser = InternetExplorer.new
6
+ @url = "http://localhost"
6
7
  end
7
8
 
8
9
  describe "Cross OS Internet Explorer", :shared => true do
@@ -28,13 +29,19 @@ describe "InternetExplorer" do
28
29
  @browser.should be_supported
29
30
  end
30
31
 
32
+ it "should be runnable" do
33
+ @browser.should be_runnable
34
+ end
35
+
31
36
  it "should setup" do
32
- # TODO test on windows
33
- # Kernel.expects(:require).with('win32ole')
37
+ Kernel.expects(:require).with('win32ole')
34
38
  lambda { @browser.setup }.should_not raise_error
35
39
  end
36
40
 
37
- it "should visit a given url"
41
+ it "should visit a given url" do
42
+ Kernel.expects(:system).with("#{@browser.path} #{@url}")
43
+ @browser.visit(@url)
44
+ end
38
45
  end if windows?
39
46
 
40
47
  describe "Linux" do
@@ -23,6 +23,10 @@ describe "Webkit" do
23
23
  @browser.setup
24
24
  end
25
25
 
26
+ it "should have a path" do
27
+ @browser.path.should == "/Applications/Webkit.app"
28
+ end
29
+
26
30
  it "should visit a given url" do
27
31
  url = "http://localhost"
28
32
  @browser.expects(:applescript).with(%(tell application "#{@browser.name}" to set URL of front document to "#{url}"))
@@ -42,6 +46,11 @@ describe "Webkit" do
42
46
  @browser.setup
43
47
  end
44
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
+
45
54
  it "should visit a given url" do
46
55
  Kernel.expects(:system).with("#{@browser.path} #{@url}")
47
56
  @browser.visit(@url)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hanoi
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Luca Guidi
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-12-26 00:00:00 +01:00
12
+ date: 2010-01-03 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies: []
15
15