watirgrid 0.0.8.pre → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
data/LICENSE CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2009 Tim Koopmans
1
+ Copyright (c) 2009-2011 Tim Koopmans
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.rdoc CHANGED
@@ -3,11 +3,7 @@
3
3
  WatirGrid allows for distributed testing across a grid network using Watir.
4
4
 
5
5
  == Getting Started
6
- This gem is hosted on Gemcutter. Gemcutter is the next generation of gem hosting for the Ruby community. To get started:
7
- gem install gemcutter
8
- gem tumble
9
-
10
- Then to install WatirGrid:
6
+ To install WatirGrid:
11
7
  gem install watirgrid
12
8
 
13
9
  === The Basics
data/Rakefile CHANGED
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'rake'
3
2
 
4
3
  begin
@@ -10,29 +9,27 @@ begin
10
9
  gem.email = "tim.koops@gmail.com"
11
10
  gem.homepage = "http://github.com/90kts/watirgrid"
12
11
  gem.authors = ["Tim Koopmans"]
13
- gem.add_development_dependency "rspec", ">= 1.2.9"
14
- gem.version = "0.0.8.pre"
15
- # gem is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
12
+ gem.version = "0.0.9"
16
13
  end
17
14
  rescue LoadError
18
15
  puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
19
16
  end
20
17
 
21
18
  require 'spec/rake/spectask'
22
- Spec::Rake::SpecTask.new(:spec) do |spec|
23
- spec.libs << 'lib' << 'spec'
24
- spec.spec_files = FileList['spec/**/*_spec.rb']
19
+ desc "Run unit tests"
20
+ Spec::Rake::SpecTask.new('unit_tests_watir') do |t|
21
+ t.spec_files = FileList['spec/**/grid_spec.rb']
22
+ t.spec_opts = ["--format", "nested", "-c"]
23
+ t.fail_on_error = false
25
24
  end
26
25
 
27
- Spec::Rake::SpecTask.new(:rcov) do |spec|
28
- spec.libs << 'lib' << 'spec'
29
- spec.pattern = 'spec/**/*_spec.rb'
30
- spec.rcov = true
26
+ desc "Run unit tests for WebDriver"
27
+ Spec::Rake::SpecTask.new('unit_tests_webdriver') do |t|
28
+ t.spec_files = FileList['spec/**/webdriver_spec.rb']
29
+ t.spec_opts = ["--format", "nested", "-c"]
30
+ t.fail_on_error = false
31
31
  end
32
32
 
33
- task :spec => :check_dependencies
34
-
35
- task :default => :spec
36
33
 
37
34
  require 'rake/rdoctask'
38
35
  Rake::RDocTask.new do |rdoc|
data/bin/controller CHANGED
@@ -10,8 +10,8 @@ OptionParser.new do |opts|
10
10
  opts.separator ""
11
11
  opts.separator "Specific options:"
12
12
  opts.on("-H HOST", "--drb-server-host", String,
13
- "Specify DRb Server interface to host on") do |H|
14
- options[:drb_server_host] = H || nil
13
+ "Specify DRb Server interface to host on") do |h|
14
+ options[:drb_server_host] = h || nil
15
15
  end
16
16
  opts.on("-d PORT", "--drb-server-port", Integer,
17
17
  "Specify DRb Server port to listen on") do |d|
@@ -57,4 +57,4 @@ controller = Controller.new(
57
57
  :loglevel => options[:loglevel]
58
58
  )
59
59
  controller.start
60
- DRb.thread.join
60
+ DRb.thread.join
data/bin/provider CHANGED
@@ -10,8 +10,8 @@ OptionParser.new do |opts|
10
10
  opts.separator ""
11
11
  opts.separator "Specific options:"
12
12
  opts.on("-H HOST", "--drb-server-host", String,
13
- "Specify DRb Server interface to host on") do |H|
14
- options[:drb_server_host] = H || nil
13
+ "Specify DRb Server interface to host on") do |h|
14
+ options[:drb_server_host] = h || nil
15
15
  end
16
16
  opts.on("-d PORT", "--drb-server-port", Integer,
17
17
  "Specify DRb Server port to listen on") do |d|
@@ -61,4 +61,4 @@ provider = Provider.new(
61
61
  :acls => options[:acls] || %w{ allow all },
62
62
  :loglevel => options[:loglevel])
63
63
  provider.start
64
- DRb.thread.join
64
+ DRb.thread.join
@@ -0,0 +1,31 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
2
+ require 'watirgrid'
3
+
4
+ # Here's some basic examples in plain Ruby with Watirgrid
5
+
6
+ # Start a Controller using defaults
7
+ controller = Controller.new
8
+ controller.start
9
+
10
+ # Start a Provider with SafariWatir
11
+ provider = Provider.new(:browser_type => 'safari')
12
+ provider.start
13
+
14
+ # Start a Grid
15
+ grid = Watir::Grid.new
16
+ grid.start(:take_all => true)
17
+
18
+ # Control the Providers via the Grid
19
+ # We only have one Provider on the Grid so no real need for threads
20
+ # however keeping the thread construct for example only
21
+ threads = []
22
+ grid.browsers.each_with_index do |browser, index|
23
+ threads << Thread.new do
24
+ b = browser[:object].new_browser
25
+ b.goto("http://www.google.com")
26
+ b.text_field(:name, 'q').set("watirgrid")
27
+ b.button(:name, "btnI").click
28
+ b.close
29
+ end
30
+ end
31
+ threads.each {|thread| thread.join}
@@ -0,0 +1,40 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
2
+ require 'watirgrid'
3
+
4
+ # Here's some basic examples in plain Ruby with Watirgrid and WebDriver
5
+
6
+ # Start a Controller using defaults
7
+ controller = Controller.new
8
+ controller.start
9
+
10
+ # Start 2 Providers with WebDriver
11
+ 1.upto(2) do
12
+ provider = Provider.new(:browser_type => 'webdriver')
13
+ provider.start
14
+ end
15
+
16
+ # Start another Grid
17
+ grid = Watir::Grid.new
18
+ grid.start(:take_all => true)
19
+
20
+ # Control the first Provider via the Grid using Firefox
21
+ # Note when we have a WebDriver object we also need to specify the target
22
+ # browser in new_browser method
23
+ thread = Thread.new do
24
+ b = grid.browsers[0][:object].new_browser(:firefox)
25
+ b.goto("http://google.com")
26
+ b.text_field(:name, 'q').set("watirgrid")
27
+ b.button(:name, "btnI").click
28
+ b.close
29
+ end
30
+ thread.join
31
+
32
+ # Control the second Provider via the Grid, this time using Chrome
33
+ thread = Thread.new do
34
+ b = grid.browsers[1][:object].new_browser(:chrome)
35
+ b.goto("http://google.com")
36
+ b.text_field(:name, 'q').set("watirgrid")
37
+ b.button(:name, "btnI").click
38
+ b.close
39
+ end
40
+ thread.join
@@ -0,0 +1,34 @@
1
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', 'lib'))
2
+ require 'watirgrid'
3
+ require 'extensions/remote'
4
+
5
+ # Here's some basic examples in plain Ruby with Watirgrid and WebDriver Remote / HtmlUnit
6
+
7
+ # Start a Controller using defaults
8
+ controller = Controller.new
9
+ controller.start
10
+
11
+ # Start 50 Providers with WebDriver Remote
12
+ 1.upto(50) do
13
+ provider = Provider.new(:browser_type => 'webdriver_remote')
14
+ provider.start
15
+ end
16
+
17
+ # Start another Grid
18
+ @grid = Watir::Grid.new
19
+ @grid.start(:take_all => true)
20
+ threads = []
21
+ @grid.browsers.each_with_index do |browser, index|
22
+ sleep 0.5 # let's sleep a little to give a more natural rampup
23
+ threads << Thread.new do
24
+ require 'selenium/server'
25
+ include Selenium
26
+
27
+ b = browser[:object].new_browser(:htmlunit)
28
+ t = Time.now
29
+ b.goto("http://90kts.local/")
30
+ puts "#{Thread.current.object_id} : #{b.title} : Elapsed #{Time.now - t}"
31
+ b.close
32
+ end
33
+ end
34
+ threads.each {|thread| thread.join}
@@ -0,0 +1,17 @@
1
+ @Example
2
+ Feature: Watirgrid using WebDriver
3
+ In order to use Watirgrid
4
+ Users must be able to create controllers, add providers and control a grid
5
+
6
+ Scenario: Create a Controller with Providers
7
+ Given I have created and started a Controller
8
+ Then I should be able to create and start 2 "WebDriver" Providers
9
+
10
+ # Note: WebDriver can only control one instance of any particular browser on a single host.
11
+ # With Watirgrid, you'd typically have multiple instances across multiple hosts (Providers)
12
+ # For the sake of a demo, we'll just control 2 difference instances on a single host.
13
+ Scenario: Create a Grid and control the Providers
14
+ Given I have created and started a Grid with 2 Providers
15
+ Then I should be able to control the following browsers in parallel:
16
+ | Chrome |
17
+ | Firefox |
@@ -0,0 +1,39 @@
1
+ $LOAD_PATH.unshift(File.dirname(__FILE__))
2
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', '..', '..', 'lib'))
3
+ require 'watirgrid'
4
+ require 'rspec/expectations';
5
+
6
+ Given /^I have created and started a Controller$/ do
7
+ controller = Controller.new(
8
+ :loglevel => Logger::ERROR)
9
+ controller.start
10
+ end
11
+
12
+ Then /^I should be able to create and start (\d+) "(.+?)" Providers$/ do |total, browser_type|
13
+ 1.upto(total.to_i) do
14
+ provider = Provider.new(
15
+ :loglevel => Logger::ERROR, :browser_type => browser_type)
16
+ provider.start
17
+ end
18
+ end
19
+
20
+ Given /^I have created and started a Grid with (\d+) Providers$/ do |total|
21
+ @grid = Watir::Grid.new
22
+ @grid.start(:take_all => true)
23
+ @grid.browsers.size.should == total.to_i
24
+ end
25
+
26
+ Then /^I should be able to control the following browsers in parallel:$/ do |table|
27
+ browsers = table.raw.collect {|e| e.to_s.downcase.to_sym}
28
+ threads = []
29
+ @grid.browsers.each_with_index do |browser, index|
30
+ threads << Thread.new do
31
+ b = browser[:object].new_browser(browsers[index])
32
+ b.goto("http://www.google.com")
33
+ b.text_field(:name, 'q').set("watirgrid")
34
+ b.button(:name, "btnI").click
35
+ b.close
36
+ end
37
+ end
38
+ threads.each {|thread| thread.join}
39
+ end
data/lib/controller.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  # controller.rb
3
3
  # Rinda Ring Server Controlller
4
4
 
5
- require 'rubygems'
6
5
  require 'rinda/tuplespace'
7
6
  require 'rinda/ring'
8
7
  require 'logger'
@@ -101,4 +100,3 @@ class Controller
101
100
  end
102
101
 
103
102
  end
104
-
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env ruby
2
+ # remote.rb
3
+ # Rinda Ring Provider
4
+
5
+ require 'rinda/ring'
6
+ require 'rinda/tuplespace'
7
+ require 'logger'
8
+ require 'drb/acl'
9
+ require 'uuid'
10
+ require 'selenium/server'
11
+ include Selenium
12
+ @server = Selenium::Server.new(File.expand_path(File.dirname(__FILE__)) + '/selenium-server-standalone-2.0b1.jar', :background => true)
13
+ @server.start
14
+
15
+ module Watir
16
+ class Provider
17
+
18
+ include DRbUndumped # all objects will be proxied, not copied
19
+
20
+ attr_reader :browser
21
+
22
+ def initialize(browser = nil)
23
+ browser = (browser || 'tmp').downcase.to_sym
24
+ case browser
25
+ when :webdriver_remote
26
+ require 'watir-webdriver'
27
+ @browser = Watir::Browser
28
+ end
29
+ end
30
+
31
+ def new_browser(webdriver_browser_type = nil)
32
+ if webdriver_browser_type == :htmlunit
33
+ capabilities = WebDriver::Remote::Capabilities.htmlunit(:javascript_enabled => true)
34
+ @browser.new(:remote, :url => "http://127.0.0.1:4444/wd/hub", :desired_capabilities => capabilities)
35
+ end
36
+ end
37
+
38
+ end
39
+ end
data/lib/provider.rb CHANGED
@@ -2,7 +2,6 @@
2
2
  # provider.rb
3
3
  # Rinda Ring Provider
4
4
 
5
- require 'rubygems'
6
5
  require 'rinda/ring'
7
6
  require 'rinda/tuplespace'
8
7
  require 'logger'
@@ -22,33 +21,29 @@ module Watir
22
21
  attr_reader :browser
23
22
 
24
23
  def initialize(browser = nil)
25
- browser = (browser || 'tmp').downcase.to_sym
24
+ browser = (browser || 'tmp').downcase.to_sym
26
25
  case browser
27
- when :safari
26
+ when :safari, :safariwatir
28
27
  require 'safariwatir'
29
28
  @browser = Watir::Safari
30
- when :firefox
29
+ when :firefox, :firewatir
31
30
  require 'firewatir'
32
31
  @browser = FireWatir::Firefox
33
- when :ie
32
+ when :ie, :watir
34
33
  require 'watir'
35
34
  @browser = Watir::IE
36
35
  when :webdriver
37
36
  require 'watir-webdriver'
38
37
  @browser = Watir::Browser
39
- else
40
- @browser = find_supported_browser
41
38
  end
42
39
  end
43
40
 
44
- #~ def find_supported_browser
45
- #~ if Watir::IE then return Watir::IE end
46
- #~ if FireWatir::Firefox then return FireWatir::Firefox end
47
- #~ if Watir::Safari then return Watir::Safari end
48
- #~ end
49
-
50
41
  def new_browser(webdriver_browser_type = nil)
51
- @browser.new(webdriver_browser_type)
42
+ if webdriver_browser_type
43
+ @browser.new(webdriver_browser_type)
44
+ else
45
+ @browser.new
46
+ end
52
47
  end
53
48
 
54
49
  ##
@@ -83,7 +78,7 @@ module Watir
83
78
  browsers.each { |browser| %x[killall -r #{browser}] }
84
79
  when /darwin/
85
80
  browsers = ['firefox-bin', 'Chrome', 'Safari']
86
- browsers.each { |browser| %x[killall -m #{browser}] }
81
+ browsers.each { |browser| %x[pkill -9 #{browser}] }
87
82
  end
88
83
  end
89
84
 
@@ -223,6 +218,4 @@ class Provider
223
218
  '127.0.0.1'
224
219
  end
225
220
  end
226
-
227
221
  end
228
-
data/lib/watirgrid.rb CHANGED
@@ -1,4 +1,3 @@
1
- require 'rubygems'
2
1
  require 'controller'
3
2
  require 'provider'
4
3
 
@@ -164,4 +163,3 @@ module Watir
164
163
  end
165
164
 
166
165
  end
167
-
data/logo.png ADDED
Binary file
data/spec/grid_spec.rb CHANGED
@@ -1,125 +1,183 @@
1
1
  require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
2
 
3
- describe 'WatirGrid' do
4
- before(:all) do
3
+ describe 'Starting and Stopping Controllers on the Grid' do
4
+ it 'should start a DRb and Ring Server when specifying NO interface or port' do
5
+ controller = Controller.new(:loglevel => Logger::ERROR)
6
+ controller.start
7
+ controller.drb_server_uri.should =~ /druby/
8
+ controller.stop
9
+ end
10
+
11
+ it 'should start a DRb and Ring Server on a specified interface' do
12
+ controller = Controller.new(
13
+ :drb_server_host => '127.0.0.1',
14
+ :ring_server_host => '127.0.0.1',
15
+ :loglevel => Logger::ERROR)
16
+ controller.start
17
+ controller.drb_server_uri.should =~ /druby/
18
+ controller.stop
19
+ end
20
+
21
+ it 'should start a DRb and Ring Server on specified ports' do
5
22
  controller = Controller.new(
6
- :ring_server_port => 12351,
23
+ :drb_server_port => 11235,
24
+ :ring_server_port => 12358,
7
25
  :loglevel => Logger::ERROR)
8
26
  controller.start
27
+ controller.drb_server_uri.should =~ /druby/
28
+ controller.stop
29
+ end
30
+ end
31
+
32
+ describe 'Starting and Stopping Providers on the Grid' do
33
+ before(:all) do
34
+ @controller = Controller.new(
35
+ :drb_server_host => '127.0.0.1',
36
+ :ring_server_host => '127.0.0.1',
37
+ :ring_server_port => 12350,
38
+ :loglevel => Logger::ERROR)
39
+ @controller.start
40
+ end
41
+
42
+ it 'should register a new provider on a specified port' do
43
+ provider = Provider.new(
44
+ :drb_server_host => '127.0.0.1',
45
+ :ring_server_host => '127.0.0.1',
46
+ :ring_server_port => 12350,
47
+ :loglevel => Logger::ERROR)
48
+ provider.start
49
+ end
50
+
51
+ after(:all) do
52
+ @controller.stop
53
+ end
54
+ end
55
+
56
+ describe 'Using the Grid' do
57
+ before(:all) do
58
+ @controller = Controller.new(
59
+ :ring_server_port => 12357,
60
+ :loglevel => Logger::ERROR)
61
+ @controller.start
9
62
  1.upto(5) do
10
63
  provider = Provider.new(
11
- :ring_server_port => 12351,
64
+ :ring_server_port => 12357,
12
65
  :loglevel => Logger::ERROR, :browser_type => 'safari')
13
66
  provider.start
14
67
  end
15
68
  end
16
69
 
17
- it 'should return how many grid are available in the tuplespace' do
18
- grid = Watir::Grid.new(:ring_server_port => 12351,
19
- :ring_server_host => '127.0.0.1')
70
+ after(:all) do
71
+ @controller.stop
72
+ end
73
+
74
+ it 'should return how many providers are available on the grid' do
75
+ grid = Watir::Grid.new(:ring_server_port => 12357)
20
76
  grid.start(:read_all => true)
21
77
  grid.size.should == 5
22
78
  end
23
79
 
24
- it 'should read any 2 grid in the tuplespace' do
25
- grid = Watir::Grid.new(:ring_server_port => 12351,
26
- :ring_server_host => '127.0.0.1')
80
+ it 'should read any 2 providers on the grid' do
81
+ grid = Watir::Grid.new(:ring_server_port => 12357)
27
82
  grid.start(:quantity => 2, :read_all => true)
28
83
  grid.size.should == 2
29
84
  end
30
85
 
31
- it 'should take any 1 browser in the tuplespace' do
32
- grid = Watir::Grid.new(:ring_server_port => 12351,
33
- :ring_server_host => '127.0.0.1')
86
+ it 'should take any 1 provider on the grid' do
87
+ grid = Watir::Grid.new(:ring_server_port => 12357)
34
88
  grid.start(:quantity => 1, :take_all => true)
35
89
  grid.size.should == 1
36
90
  end
37
91
 
38
- it 'should take all grid remaining in tuplespace' do
39
- grid = Watir::Grid.new(:ring_server_port => 12351,
40
- :ring_server_host => '127.0.0.1')
92
+ it 'should take all providers remaining on the grid' do
93
+ grid = Watir::Grid.new(:ring_server_port => 12357)
41
94
  grid.start(:take_all => true)
42
95
  grid.size.should == 4
43
96
  end
44
97
 
45
- it 'should find no more grid in the tuplespace' do
46
- grid = Watir::Grid.new(:ring_server_port => 12351,
47
- :ring_server_host => '127.0.0.1')
98
+ it 'should find no more providers on the grid' do
99
+ grid = Watir::Grid.new(:ring_server_port => 12357)
48
100
  grid.start(:read_all => true)
49
101
  grid.size.should == 0
50
102
  end
51
103
 
52
- it 'should register 4 new grid in the tuplespace' do
104
+ it 'should register 4 new providers on the grid' do
53
105
  1.upto(4) do
54
- provider = Provider.new(:ring_server_port => 12351,
106
+ provider = Provider.new(:ring_server_port => 12357,
55
107
  :loglevel => Logger::ERROR, :browser_type => 'safari')
56
108
  provider.start
57
109
  end
58
110
  end
59
111
 
60
- it 'should take any 1 browser based on browser type' do
61
- grid = Watir::Grid.new(:ring_server_port => 12351,
62
- :ring_server_host => '127.0.0.1')
112
+ it 'should take any 1 provider based on :browser_type from the grid' do
113
+ grid = Watir::Grid.new(:ring_server_port => 12357)
63
114
  grid.start(:quantity => 1,
64
115
  :take_all => true, :browser_type => 'safari')
65
116
  grid.size.should == 1
66
117
  end
67
118
 
68
- it 'should fail to find any grid based on a specific browser type' do
69
- grid = Watir::Grid.new(:ring_server_port => 12351,
70
- :ring_server_host => '127.0.0.1')
119
+ it 'should fail to find any providers on the grid based on a specific :browser_type' do
120
+ grid = Watir::Grid.new(:ring_server_port => 12357)
71
121
  grid.start(:quantity => 1,
72
122
  :take_all => true, :browser_type => 'firefox')
73
123
  grid.size.should == 0
74
124
  end
75
125
 
76
- it 'should fail to find any grid based on a unknown browser type' do
77
- grid = Watir::Grid.new(:ring_server_port => 12351,
78
- :ring_server_host => '127.0.0.1')
126
+ it 'should fail to find any providers on the grid based on an unknown :browser_type' do
127
+ grid = Watir::Grid.new(:ring_server_port => 12357)
79
128
  grid.start(:quantity => 1,
80
129
  :take_all => true, :browser_type => 'penguin')
81
130
  grid.size.should == 0
82
131
  end
83
132
 
84
- it 'should take any 1 browser based on specific architecture type' do
85
- grid = Watir::Grid.new(:ring_server_port => 12351,
86
- :ring_server_host => '127.0.0.1')
133
+ it 'should take any 1 provider on the grid based on specific :architecture' do
134
+ grid = Watir::Grid.new(:ring_server_port => 12357)
87
135
  grid.start(:quantity => 1,
88
136
  :take_all => true, :architecture => Config::CONFIG['arch'])
89
137
  grid.size.should == 1
90
138
  end
91
139
 
92
- it 'should fail to find any grid based on unknown architecture type' do
93
- grid = Watir::Grid.new(:ring_server_port => 12351,
94
- :ring_server_host => '127.0.0.1')
140
+ it 'should fail to find any providers on the grid based on an unknown :architecture' do
141
+ grid = Watir::Grid.new(:ring_server_port => 12357)
95
142
  grid.start(:quantity => 1,
96
- :take_all => true, :architecture => 'geos-1992')
143
+ :take_all => true, :architecture => 'geos-2000')
97
144
  grid.size.should == 0
98
145
  end
99
146
 
100
- it 'should take any 1 browser based on specific hostname' do
147
+ it 'should take any 1 provider on the grid based on specific :hostnames' do
101
148
  hostname = `hostname`.strip
102
- grid = Watir::Grid.new(:ring_server_port => 12351,
103
- :ring_server_host => '127.0.0.1')
149
+ grid = Watir::Grid.new(:ring_server_port => 12357)
104
150
  grid.start(:quantity => 1,
105
151
  :take_all => true,
106
- :hostnames => { hostname => "127.0.0.1"}
152
+ :hostnames => { hostname => '127.0.0.1'}
107
153
  )
108
154
  grid.size.should == 1
109
155
  end
110
156
 
111
- it 'should fail to find any grid based on unknown hostname' do
112
- grid = Watir::Grid.new(:ring_server_port => 12351,
113
- :ring_server_host => '127.0.0.1')
157
+ it 'should fail to find any providers on the grid based on unknown :hostnames' do
158
+ grid = Watir::Grid.new(:ring_server_port => 12357)
114
159
  grid.start(:quantity => 1,
115
160
  :take_all => true, :hostnames => {
116
161
  "tokyo" => "127.0.0.1"})
117
162
  grid.size.should == 0
118
163
  end
164
+
165
+ it 'should get the UUID of the last provider on the grid' do
166
+ grid = Watir::Grid.new(:ring_server_port => 12357)
167
+ grid.start(:read_all => true)
168
+ grid.browsers.each do |browser|
169
+ @uuid = browser[:uuid]
170
+ end
171
+ end
172
+
173
+ it 'should be able to find a provider by its UUID on the grid' do
174
+ grid = Watir::Grid.new(:ring_server_port => 12357)
175
+ grid.start(:read_all => true, :uuid => @uuid)
176
+ grid.size.should == 1
177
+ end
119
178
 
120
- it 'should take the last browser and execute some watir commands' do
121
- grid = Watir::Grid.new(:ring_server_port => 12351,
122
- :ring_server_host => '127.0.0.1')
179
+ it 'should take the last provider on the grid and execute some Watir code in Safari' do
180
+ grid = Watir::Grid.new(:ring_server_port => 12357)
123
181
  grid.start(:quantity => 1, :take_all => true)
124
182
  threads = []
125
183
  grid.browsers.each do |browser|
@@ -130,19 +188,17 @@ describe 'WatirGrid' do
130
188
  b = browser[:object].new_browser
131
189
  b.goto("http://www.google.com")
132
190
  b.text_field(:name, 'q').set("watirgrid")
133
- b.button(:name, "btnI").click
191
+ #b.button(:name, "btnI").click
192
+ b.close
134
193
  end
135
194
  end
136
195
  threads.each {|thread| thread.join}
137
196
  grid.size.should == 1
138
197
  end
139
198
 
140
- it 'should find no more tuples in the tuplespace' do
141
- grid = Watir::Grid.new(:ring_server_port => 12351,
142
- :ring_server_host => '127.0.0.1')
199
+ it 'should find no more providers on the grid' do
200
+ grid = Watir::Grid.new(:ring_server_port => 12357)
143
201
  grid.start(:read_all => true)
144
202
  grid.size.should == 0
145
- end
146
-
203
+ end
147
204
  end
148
-
data/spec/spec_helper.rb CHANGED
@@ -1,9 +1,3 @@
1
1
  $LOAD_PATH.unshift(File.dirname(__FILE__))
2
2
  $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
3
3
  require 'watirgrid'
4
- require 'spec'
5
- require 'spec/autorun'
6
-
7
- Spec::Runner.configure do |config|
8
-
9
- end