tuev 0.4.2 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tuev (0.4.2)
4
+ tuev (0.5.0)
5
5
  selenium-client
6
6
 
7
7
  GEM
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.4.2
1
+ 0.5.0
data/bin/tuev CHANGED
@@ -28,9 +28,9 @@ opts = OptionParser.new do |opts|
28
28
  "set selenium host's port (default: #{options[:port]})") do |port|
29
29
  options[:port] = port || options[:port]
30
30
  end
31
-
31
+
32
32
  # List of arguments.
33
- opts.on("-b", "--browsers=x,y,z", Array,
33
+ opts.on("-b", "--browsers=x,y,z", Array,
34
34
  "browsers where to run this file in (default #{options[:browsers].join(",")})") do |browsers|
35
35
  options[:browsers] = browsers || options[:browsers]
36
36
  end
@@ -56,7 +56,7 @@ opts = OptionParser.new do |opts|
56
56
  end
57
57
 
58
58
  begin
59
- opts.parse!(ARGV)
59
+ opts.parse!(ARGV)
60
60
  rescue => e
61
61
  if e.is_a?(OptionParser::MissingArgument) && e.args[0] == "-h"
62
62
  print opts
@@ -76,8 +76,7 @@ end
76
76
 
77
77
  errors = 0
78
78
  qunit_files.each do |file|
79
- path = File.expand_path(file)
80
- errors += QunitRunner.new(path, options).run
79
+ errors += QunitRunner.new(file, options).run
81
80
  end
82
81
 
83
82
  exit(errors)
@@ -108,6 +108,7 @@ class Tuev
108
108
  if files.empty?
109
109
  raise "could not find file matching '#{pattern}'"
110
110
  end
111
+
111
112
  files
112
113
  end
113
114
 
@@ -120,7 +121,7 @@ class Tuev
120
121
  end
121
122
 
122
123
 
123
- file_list.map{|x| file_url(x)}
124
+ file_list.map{|x| file_url(x)}.uniq
124
125
  end
125
126
 
126
127
  def file_url(*relativ_path_parts)
@@ -2,9 +2,33 @@ require "selenium/client"
2
2
  class QunitRunner
3
3
  def initialize(path, selenium_conf)
4
4
  @test_file = path
5
+
6
+ if local_file? && !(@test_file =~ /file:\/\//)
7
+ @test_file = "file://#{File.expand_path(@test_file)}"
8
+ end
9
+
5
10
  @selenium_conf = selenium_conf
6
11
  end
7
12
 
13
+ def local_file?
14
+ # it's a local file if it has not any protocoll or the file:// protcoll
15
+ !(@test_file =~ /:\/\//) || !!(@test_file =~ /file:\/\//)
16
+ end
17
+
18
+ def split_url
19
+ @test_file.match(/(?<host>.*:\/\/[^\/]+)(?<path>.*)$/)
20
+ end
21
+
22
+ # host & path as is needed below ...
23
+ def host
24
+ local_file? ? "file://" : split_url["host"]
25
+ end
26
+
27
+ def path
28
+ local_file? ? @test_file : split_url["path"]
29
+ end
30
+
31
+
8
32
  def run_in_browser(browser_string)
9
33
  begin
10
34
  Net::HTTP.new(@selenium_conf[:host], @selenium_conf[:port]).get2("/")
@@ -22,7 +46,7 @@ class QunitRunner
22
46
  :host => @selenium_conf[:host],
23
47
  :port => @selenium_conf[:port],
24
48
  :browser => browser_string,
25
- :url => "file://",
49
+ :url => host,
26
50
  :timeout_in_second => 60
27
51
  )
28
52
 
@@ -38,7 +62,7 @@ class QunitRunner
38
62
 
39
63
  @selenium_conf[:browsers].each do |browser_id|
40
64
  run_in_browser(browser_id) do |browser|
41
- browser.open "file://#{@test_file}"
65
+ browser.open path
42
66
  browser.wait_for_page_to_load "60000"
43
67
  puts "\ntesting on #{browser_id}: #{@test_file}\n\n"
44
68
  60.times{ break if (browser.is_element_present("id=qunit-testresult") rescue false); sleep 1 }
@@ -0,0 +1,40 @@
1
+ require 'spec_helper'
2
+
3
+ describe "QunitRunner" do
4
+ it "should detect correctly whether we have a local file or not" do
5
+ QunitRunner.new("http://example.com", "").local_file?.should == false
6
+ QunitRunner.new("https://example.com", "").local_file?.should == false
7
+ QunitRunner.new("/tmp/foo", "").local_file?.should == true
8
+ QunitRunner.new("file:///tmp/foo", "").local_file?.should == true
9
+ QunitRunner.new("../foo", "").local_file?.should == true
10
+ end
11
+
12
+ it "should detect the base host correctly" do
13
+ QunitRunner.new("http://example.com", "").host.should == "http://example.com"
14
+ QunitRunner.new("http://example.com/", "").host.should == "http://example.com"
15
+ QunitRunner.new("http://example.com/lirumlarum", "").host.should == "http://example.com"
16
+
17
+ QunitRunner.new("https://example.com", "").host.should == "https://example.com"
18
+ QunitRunner.new("https://example.com/", "").host.should == "https://example.com"
19
+ QunitRunner.new("https://example.com/lirumlarum", "").host.should == "https://example.com"
20
+
21
+ QunitRunner.new("/tmp/foo", "").host.should == "file://"
22
+ QunitRunner.new("file:///tmp/foo", "").host.should == "file://"
23
+ QunitRunner.new("../foo", "").host.should == "file://"
24
+ end
25
+
26
+ it "should detect the base path correctly" do
27
+ QunitRunner.new("http://example.com", "").path.should == ""
28
+ QunitRunner.new("http://example.com/", "").path.should == "/"
29
+ QunitRunner.new("http://example.com/lirumlarum", "").path.should == "/lirumlarum"
30
+
31
+ QunitRunner.new("https://example.com", "").path.should == ""
32
+ QunitRunner.new("https://example.com/", "").path.should == "/"
33
+ QunitRunner.new("https://example.com/lirumlarum", "").path.should == "/lirumlarum"
34
+
35
+ QunitRunner.new("/tmp/foo", "").path.should == "file:///tmp/foo"
36
+ QunitRunner.new("file:///tmp/foo", "").path.should == "file:///tmp/foo"
37
+ QunitRunner.new("../foo", "").path.should == "file://#{File.expand_path("../foo")}"
38
+ end
39
+
40
+ end
@@ -1,7 +1,4 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe "Tuev" do
4
- it "fails" do
5
- Tuev.new.should != nil
6
- end
7
4
  end
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{tuev}
8
- s.version = "0.4.2"
8
+ s.version = "0.5.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["kesselborn"]
12
- s.date = %q{2011-05-04}
12
+ s.date = %q{2011-10-27}
13
13
  s.default_executable = %q{tuev}
14
14
  s.description = %q{...}
15
15
  s.email = %q{daniel@soundcloud.com}
@@ -43,6 +43,7 @@ Gem::Specification.new do |s|
43
43
  "lib/tuev/tuev_runner.rb",
44
44
  "spec/fixtures/fake_root/config/tuev.yml",
45
45
  "spec/fixtures/file_layout1.txt",
46
+ "spec/qunit_runner_spec.rb",
46
47
  "spec/spec_helper.rb",
47
48
  "spec/tuev_spec.rb",
48
49
  "tuev.gemspec",
@@ -54,6 +55,7 @@ Gem::Specification.new do |s|
54
55
  s.rubygems_version = %q{1.6.2}
55
56
  s.summary = %q{run qunit & selenium tests with rake}
56
57
  s.test_files = [
58
+ "spec/qunit_runner_spec.rb",
57
59
  "spec/spec_helper.rb",
58
60
  "spec/tuev_spec.rb"
59
61
  ]
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: tuev
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.4.2
5
+ version: 0.5.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - kesselborn
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-05-04 00:00:00 +02:00
13
+ date: 2011-10-27 00:00:00 +02:00
14
14
  default_executable: tuev
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
@@ -135,6 +135,7 @@ files:
135
135
  - lib/tuev/tuev_runner.rb
136
136
  - spec/fixtures/fake_root/config/tuev.yml
137
137
  - spec/fixtures/file_layout1.txt
138
+ - spec/qunit_runner_spec.rb
138
139
  - spec/spec_helper.rb
139
140
  - spec/tuev_spec.rb
140
141
  - tuev.gemspec
@@ -153,7 +154,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
153
154
  requirements:
154
155
  - - ">="
155
156
  - !ruby/object:Gem::Version
156
- hash: -2086859141094756435
157
+ hash: -3230019329448292206
157
158
  segments:
158
159
  - 0
159
160
  version: "0"
@@ -171,5 +172,6 @@ signing_key:
171
172
  specification_version: 3
172
173
  summary: run qunit & selenium tests with rake
173
174
  test_files:
175
+ - spec/qunit_runner_spec.rb
174
176
  - spec/spec_helper.rb
175
177
  - spec/tuev_spec.rb