watir-proxy 0.0.1

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.
@@ -0,0 +1,4 @@
1
+ === 0.0.1 2010-09-23
2
+
3
+ * 1 major enhancement:
4
+ * Initial release
@@ -0,0 +1,16 @@
1
+ History.txt
2
+ Manifest.txt
3
+ PostInstall.txt
4
+ README.rdoc
5
+ Rakefile
6
+ bin/watir-proxy-start-server
7
+ lib/watir-proxy-start-server/cli.rb
8
+ lib/watir-proxy.rb
9
+ script/console
10
+ script/destroy
11
+ script/generate
12
+ spec/spec.opts
13
+ spec/spec_helper.rb
14
+ spec/watir-proxy-start-server_cli_spec.rb
15
+ spec/watir-proxy_spec.rb
16
+ tasks/rspec.rake
@@ -0,0 +1,3 @@
1
+
2
+ For more information on watir-proxy, see https://rubygems.org/gems/watir-proxy
3
+
@@ -0,0 +1,58 @@
1
+ = watir-proxy
2
+
3
+ * http://github.com/usualoma/watir-proxy
4
+
5
+ == DESCRIPTION:
6
+
7
+ A DRB server program and client libraries for Watir.
8
+
9
+ == FEATURES/PROBLEMS:
10
+
11
+ * Reuse a created browser.
12
+ * Execute Watir from other machine.
13
+
14
+ == SYNOPSIS:
15
+
16
+ $ watir-proxy-start-server
17
+
18
+ $ cat > watir-proxy-test.rb <<__RUBY__
19
+ require 'rubygems'
20
+ require 'watir-proxy'
21
+
22
+ browser = WatirProxy::Server.browser(:type => :firefox)
23
+ browser.goto 'http://localhost/'
24
+ __RUBY__
25
+
26
+ $ ruby < watir-proxy-test.rb # A new browser will be created.
27
+ $ ruby < watir-proxy-test.rb # A browser made above will be reused.
28
+
29
+ == REQUIREMENTS:
30
+
31
+ * watir-webdriver
32
+
33
+ == INSTALL:
34
+
35
+ * sudo gem install watir-proxy
36
+
37
+ == LICENSE:
38
+
39
+ Copyright (c) 2010 Taku AMANO
40
+
41
+ Permission is hereby granted, free of charge, to any person obtaining
42
+ a copy of this software and associated documentation files (the
43
+ 'Software'), to deal in the Software without restriction, including
44
+ without limitation the rights to use, copy, modify, merge, publish,
45
+ distribute, sublicense, and/or sell copies of the Software, and to
46
+ permit persons to whom the Software is furnished to do so, subject to
47
+ the following conditions:
48
+
49
+ The above copyright notice and this permission notice shall be
50
+ included in all copies or substantial portions of the Software.
51
+
52
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
53
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
54
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
55
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
56
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
57
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
58
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,27 @@
1
+ require 'rubygems'
2
+ gem 'hoe', '>= 2.1.0'
3
+ require 'hoe'
4
+ require 'fileutils'
5
+ require './lib/watir-proxy'
6
+
7
+ Hoe.plugin :newgem
8
+ # Hoe.plugin :website
9
+ # Hoe.plugin :cucumberfeatures
10
+
11
+ # Generate all the Rake tasks
12
+ # Run 'rake -T' to see list of generated tasks (from gem root directory)
13
+ $hoe = Hoe.spec 'watir-proxy' do
14
+ self.developer 'Taku AMANO', 'taku@toi-planning.net'
15
+ self.post_install_message = 'PostInstall.txt'
16
+ # self.rubyforge_name = self.name
17
+ self.extra_deps = [
18
+ ['watir-webdriver', '>= 0'],
19
+ ]
20
+ end
21
+
22
+ require 'newgem/tasks'
23
+ Dir['tasks/**/*.rake'].each { |t| load t }
24
+
25
+ # TODO - want other tests/tasks run by default? Add them to the list
26
+ # remove_task :default
27
+ # task :default => [:spec, :features]
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # Created by Taku AMANO on 2010-9-23.
4
+ # Copyright (c) 2010. All rights reserved.
5
+
6
+ require 'rubygems'
7
+ require File.expand_path(File.dirname(__FILE__) + "/../lib/watir-proxy")
8
+ require "watir-proxy-start-server/cli"
9
+
10
+ WatirProxyStartServer::CLI.execute(STDOUT, ARGV)
@@ -0,0 +1,36 @@
1
+ require 'optparse'
2
+
3
+ module WatirProxyStartServer
4
+ class CLI
5
+ def self.execute(stdout, arguments=[], &block)
6
+
7
+ options = { }
8
+ mandatory_options = %w( )
9
+
10
+ parser = OptionParser.new do |opts|
11
+ opts.banner = <<-BANNER.gsub(/^ /,'')
12
+ Usage: #{File.basename($0)} [options]
13
+
14
+ Options are:
15
+ BANNER
16
+ opts.separator ""
17
+ opts.on("-d", "--drb-uri URI", String,
18
+ "URI passed to DRb.start_service",
19
+ "Default: " + WatirProxy::Server.default_drb_uri
20
+ ) { |arg| options[:drb_uri] = arg }
21
+ opts.on("-h", "--help",
22
+ "Show this help message.") { stdout.puts opts; exit }
23
+ opts.parse!(arguments)
24
+
25
+ if mandatory_options && mandatory_options.find { |option| options[option.to_sym].nil? }
26
+ stdout.puts opts; exit
27
+ end
28
+ end
29
+
30
+ WatirProxy::Server.start_service(options) do
31
+ block.call stdout if block
32
+ end
33
+ WatirProxy::Server.thread.join if WatirProxy::Server.thread
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,88 @@
1
+ $:.unshift(File.dirname(__FILE__)) unless
2
+ $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'watir-webdriver'
5
+ require 'drb/drb'
6
+
7
+ module WatirProxy
8
+ VERSION = '0.0.1'
9
+
10
+ class Browser
11
+ def initialize(opts = {})
12
+ @drb = opts[:drb]
13
+ @browser = opts[:browser]
14
+ @options = opts[:options]
15
+ end
16
+
17
+ def method_missing(name, *args)
18
+ if @browser
19
+ @browser.send name, *args
20
+ else
21
+ @drb.browser_call @options, name, *args
22
+ end
23
+ end
24
+ end
25
+
26
+ class Server
27
+ attr_accessor :stream, :current_browser
28
+
29
+ @@default_browser = :firefox
30
+ @@default_drb_uri = 'druby://localhost:12444'
31
+
32
+ def self.browser(opts = {}, &block)
33
+ drb, browser = nil, nil
34
+ begin
35
+ drb = DRbObject.new_with_uri(self.drb_uri(opts))
36
+ rescue DRb::DRbConnError => e
37
+ browser = self.new(StringIO.new).browser(opts)
38
+ end
39
+
40
+ Browser.new({
41
+ :drb => drb,
42
+ :browser => browser,
43
+ :options => opts,
44
+ })
45
+ end
46
+
47
+ def self.default_drb_uri
48
+ @@default_drb_uri
49
+ end
50
+
51
+ def self.drb_uri(opts = {})
52
+ opts[:drb_uri] || ENV['WATIR_PROXY_DRB_URI'] || self.default_drb_uri
53
+ end
54
+
55
+ def self.start_service(opts = {}, &block)
56
+ DRb.start_service(self.drb_uri(opts), self.new)
57
+ yield if block
58
+ end
59
+
60
+ def self.stop_service(&block)
61
+ DRb.stop_service
62
+ end
63
+
64
+ def self.thread
65
+ DRb.thread
66
+ end
67
+
68
+ def initialize(stream = $stdout)
69
+ @stream = stream
70
+ @current_browser = @@default_browser
71
+ @browsers = {}
72
+ end
73
+
74
+ def browser_call(opts, name, *args)
75
+ self.browser(opts).send name, *args
76
+ end
77
+
78
+ def browser(opts = {})
79
+ @current_browser = opts[:type] || @current_browser
80
+ @browsers[@current_browser] ||= new_browser(@current_browser)
81
+ end
82
+
83
+ def new_browser(type)
84
+ Watir::Browser.new(type)
85
+ end
86
+
87
+ end
88
+ end
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env ruby
2
+ # File: script/console
3
+ irb = RUBY_PLATFORM =~ /(:?mswin|mingw)/ ? 'irb.bat' : 'irb'
4
+
5
+ libs = " -r irb/completion"
6
+ # Perhaps use a console_lib to store any extra methods I may want available in the cosole
7
+ # libs << " -r #{File.dirname(__FILE__) + '/../lib/console_lib/console_logger.rb'}"
8
+ libs << " -r #{File.dirname(__FILE__) + '/../lib/watir-proxy.rb'}"
9
+ puts "Loading watir-proxy gem"
10
+ exec "#{irb} #{libs} --simple-prompt"
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/destroy'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Destroy.new.run(ARGV)
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+ APP_ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..'))
3
+
4
+ begin
5
+ require 'rubigen'
6
+ rescue LoadError
7
+ require 'rubygems'
8
+ require 'rubigen'
9
+ end
10
+ require 'rubigen/scripts/generate'
11
+
12
+ ARGV.shift if ['--help', '-h'].include?(ARGV[0])
13
+ RubiGen::Base.use_component_sources! [:rubygems, :newgem, :newgem_theme, :test_unit]
14
+ RubiGen::Scripts::Generate.new.run(ARGV)
@@ -0,0 +1 @@
1
+ --colour
@@ -0,0 +1,12 @@
1
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
2
+
3
+ begin
4
+ require 'spec'
5
+ rescue LoadError
6
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
7
+ gem 'rspec'
8
+ require 'spec'
9
+ end
10
+
11
+ $:.unshift(File.dirname(__FILE__) + '/../lib')
12
+ require 'watir-proxy'
@@ -0,0 +1,18 @@
1
+ require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
2
+ require 'watir-proxy-start-server/cli'
3
+
4
+ describe WatirProxyStartServer::CLI, "execute" do
5
+ before(:each) do
6
+ @stdout_io = StringIO.new
7
+ WatirProxyStartServer::CLI.execute(@stdout_io, []) do |stdout|
8
+ stdout.puts 'successfully executed'
9
+ WatirProxy::Server.stop_service
10
+ end
11
+ @stdout_io.rewind
12
+ @stdout = @stdout_io.read
13
+ end
14
+
15
+ it "should print default output" do
16
+ @stdout.should match "successfully executed\n"
17
+ end
18
+ end
@@ -0,0 +1,79 @@
1
+ require File.dirname(__FILE__) + '/spec_helper.rb'
2
+
3
+ require 'webrick'
4
+
5
+ describe WatirProxy do
6
+
7
+ before :all do
8
+ @access_log = StringIO.new
9
+ @server_thread = Thread.new do
10
+ @server = WEBrick::HTTPServer.new({
11
+ :BindAddress => '127.0.0.1',
12
+ :Logger => WEBrick::Log.new(@access_log),
13
+ :AccessLog => [[@access_log, WEBrick::AccessLog::COMBINED_LOG_FORMAT]],
14
+ :Port => 11111,
15
+ })
16
+ @server.mount_proc '/' do |req, res|
17
+ res.body = <<-HTML
18
+ <html>
19
+ <head>
20
+ </head>
21
+ <body>
22
+ content
23
+ </body>
24
+ </html>
25
+ HTML
26
+ end
27
+ @server.start
28
+ end
29
+ end
30
+
31
+ after :all do
32
+ @server.shutdown
33
+ @server_thread.exit
34
+ @server_thread.join
35
+ end
36
+
37
+ before :each do
38
+ WatirProxy::Server.start_service
39
+ end
40
+
41
+ after :each do
42
+ begin
43
+ @browser.close
44
+ rescue LoadError, NameError, ArgumentError => e
45
+ #
46
+ end
47
+ WatirProxy::Server.stop_service
48
+ end
49
+
50
+ browsers = [:firefox, :chrome, :ie]
51
+ #browsers << :opera
52
+ #browsers << :safari
53
+
54
+ browsers.each do |type|
55
+ describe type do
56
+ it "create" do
57
+ begin
58
+ @browser = WatirProxy::Server.browser(:type => type)
59
+ rescue LoadError, NameError, ArgumentError => e
60
+ #
61
+ else
62
+ @browser.should be_instance_of WatirProxy::Browser
63
+ end
64
+ end
65
+
66
+ it "goto" do
67
+ begin
68
+ @browser = WatirProxy::Server.browser(:type => type)
69
+ @browser.goto 'http://localhost:11111'
70
+ rescue LoadError, NameError, ArgumentError => e
71
+ #
72
+ else
73
+ @browser.html.should match /content/
74
+ end
75
+ end
76
+ end
77
+ end
78
+
79
+ end
@@ -0,0 +1,21 @@
1
+ begin
2
+ require 'spec'
3
+ rescue LoadError
4
+ require 'rubygems' unless ENV['NO_RUBYGEMS']
5
+ require 'spec'
6
+ end
7
+ begin
8
+ require 'spec/rake/spectask'
9
+ rescue LoadError
10
+ puts <<-EOS
11
+ To use rspec for testing you must install rspec gem:
12
+ gem install rspec
13
+ EOS
14
+ exit(0)
15
+ end
16
+
17
+ desc "Run the specs under spec/models"
18
+ Spec::Rake::SpecTask.new do |t|
19
+ t.spec_opts = ['--options', "spec/spec.opts"]
20
+ t.spec_files = FileList['spec/**/*_spec.rb']
21
+ end
metadata ADDED
@@ -0,0 +1,131 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: watir-proxy
3
+ version: !ruby/object:Gem::Version
4
+ hash: 29
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 1
10
+ version: 0.0.1
11
+ platform: ruby
12
+ authors:
13
+ - Taku AMANO
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-09-28 00:00:00 +09:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: watir-webdriver
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
33
+ type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: rubyforge
37
+ prerelease: false
38
+ requirement: &id002 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 7
44
+ segments:
45
+ - 2
46
+ - 0
47
+ - 4
48
+ version: 2.0.4
49
+ type: :development
50
+ version_requirements: *id002
51
+ - !ruby/object:Gem::Dependency
52
+ name: hoe
53
+ prerelease: false
54
+ requirement: &id003 !ruby/object:Gem::Requirement
55
+ none: false
56
+ requirements:
57
+ - - ">="
58
+ - !ruby/object:Gem::Version
59
+ hash: 21
60
+ segments:
61
+ - 2
62
+ - 6
63
+ - 1
64
+ version: 2.6.1
65
+ type: :development
66
+ version_requirements: *id003
67
+ description: A DRB server program and client libraries for Watir.
68
+ email:
69
+ - taku@toi-planning.net
70
+ executables:
71
+ - watir-proxy-start-server
72
+ extensions: []
73
+
74
+ extra_rdoc_files:
75
+ - History.txt
76
+ - Manifest.txt
77
+ - PostInstall.txt
78
+ files:
79
+ - History.txt
80
+ - Manifest.txt
81
+ - PostInstall.txt
82
+ - README.rdoc
83
+ - Rakefile
84
+ - bin/watir-proxy-start-server
85
+ - lib/watir-proxy-start-server/cli.rb
86
+ - lib/watir-proxy.rb
87
+ - script/console
88
+ - script/destroy
89
+ - script/generate
90
+ - spec/spec.opts
91
+ - spec/spec_helper.rb
92
+ - spec/watir-proxy-start-server_cli_spec.rb
93
+ - spec/watir-proxy_spec.rb
94
+ - tasks/rspec.rake
95
+ has_rdoc: true
96
+ homepage: http://github.com/usualoma/watir-proxy
97
+ licenses: []
98
+
99
+ post_install_message: PostInstall.txt
100
+ rdoc_options:
101
+ - --main
102
+ - README.rdoc
103
+ require_paths:
104
+ - lib
105
+ required_ruby_version: !ruby/object:Gem::Requirement
106
+ none: false
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ hash: 3
111
+ segments:
112
+ - 0
113
+ version: "0"
114
+ required_rubygems_version: !ruby/object:Gem::Requirement
115
+ none: false
116
+ requirements:
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ hash: 3
120
+ segments:
121
+ - 0
122
+ version: "0"
123
+ requirements: []
124
+
125
+ rubyforge_project: watir-proxy
126
+ rubygems_version: 1.3.7
127
+ signing_key:
128
+ specification_version: 3
129
+ summary: A DRB server program and client libraries for Watir.
130
+ test_files: []
131
+