RDee 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,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1f108a3c7c47f5ce2e00c26b947671fa2bd992ed
4
+ data.tar.gz: 782ca4414611441da4ce915b868a31ebde8c49ea
5
+ SHA512:
6
+ metadata.gz: 587e4e884907beff175008cbf8a68ab56488c8d9e094f91b230ba9ae92ce78311834fb53dcf3603bd5b6ba913ec295595698f41379a2f59e289101edbed61ac4
7
+ data.tar.gz: 8a290e05a8d5c27341513f249ab704fc115b1f0f1065ffd0a9be9dc97d55452efe2e6908d96fd87d427c9344c0a7d8e1b0c4196d0d2aea68bf464bf6a538a9e1
@@ -0,0 +1,22 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
4
+ - 2.1.2
5
+ -jruby-19mode
@@ -0,0 +1,2 @@
1
+ === Release 0.1
2
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ardi.gemspec
4
+
5
+ gem 'fuubar'
6
+ gem 'fuubar-cucumber'
7
+ gem 'rb-fsevent', :require => false if RUBY_PLATFORM =~ /darwin/i
8
+ gem 'growl'
9
+ gem 'guard-rspec'
10
+ gem 'guard-cucumber'
11
+
12
+ gemspec
@@ -0,0 +1,17 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+
5
+ guard :rspec, all_on_start: true, all_after_pass: true, cmd: 'rspec --color --format documentation' do
6
+ watch(%r{^spec/.+_spec\.rb$})
7
+ watch(%r{^lib/(.+)\.rb$}) { "spec" }
8
+ watch('spec/spec_helper.rb') { "spec" }
9
+ end
10
+
11
+ guard 'cucumber', notification: true, all_after_pass: false, cli: '--profile focus' do
12
+ watch(%r{^features/.+\.feature$})
13
+ watch(%r{^features/support/.+$}) { "features" }
14
+ watch(%r{^features/step_definitions/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'features' }
15
+ watch(%r{^lib/.+\.rb$}) { "features" }
16
+ watch(%r{^cucumber.yml$}) { "features" }
17
+ end
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 Jeffrey S. Morgan
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,29 @@
1
+ # RD
2
+
3
+ TODO: Write a gem description
4
+
5
+ ## Installation
6
+
7
+ Add this line to your application's Gemfile:
8
+
9
+ gem 'rd'
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install rd
18
+
19
+ ## Usage
20
+
21
+ TODO: Write usage instructions here
22
+
23
+ ## Contributing
24
+
25
+ 1. Fork it ( https://github.com/[my-github-username]/rd/fork )
26
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
27
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
28
+ 4. Push to the branch (`git push origin my-new-feature`)
29
+ 5. Create a new Pull Request
@@ -0,0 +1,15 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+ require 'cucumber/rake/task'
4
+
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ Cucumber::Rake::Task.new(:features) do |t|
8
+ t.profile = 'default'
9
+ end
10
+
11
+ desc 'Run all specs and cukes'
12
+ task :test => ['spec', 'features']
13
+
14
+ task :default => :test
15
+
@@ -0,0 +1,3 @@
1
+ default: --no-source --color --format pretty
2
+ focus: --no-source --color --format pretty --tags @focus
3
+
@@ -0,0 +1,35 @@
1
+ Feature: RDee should work well with browsers when target is set via environment variable
2
+
3
+ Since I only have a Mac I will test Firefox, Chrome, and Safari
4
+
5
+ Scenario: Creating a Firefox browser with a variable using Selenium
6
+ When I establish a Firefox browser with a variable using Selenium
7
+ Then I should be able to perform a google search for cheezyworld
8
+ And I should be able to close the connection
9
+
10
+ Scenario: Creating a Firefox browser with a variable using Watir
11
+ When I establish a Firefox browser with a variable using Watir
12
+ Then I should be able to perform a google search for cheezyworld
13
+ And I should be able to close the connection
14
+
15
+ Scenario: Creating a Chrome browser with a variable using Selenium
16
+ When I establish a Chrome browser with a variable using Selenium
17
+ Then I should be able to perform a google search for cheezyworld
18
+ And I should be able to close the connection
19
+
20
+ Scenario: Creating a Chrome browser with a variable using Watir
21
+ When I establish a Chrome browser with a variable using Watir
22
+ Then I should be able to perform a google search for cheezyworld
23
+ And I should be able to close the connection
24
+
25
+ Scenario: Creating a Safari browser with a variable using Selenium
26
+ When I establish a Safari browser with a variable using Selenium
27
+ Then I should be able to perform a google search for cheezyworld
28
+ And I should be able to close the connection
29
+
30
+ Scenario: Creating a Safari browser with a variable using Watir
31
+ When I establish a Safari browser with a variable using Watir
32
+ Then I should be able to perform a google search for cheezyworld
33
+ And I should be able to close the connection
34
+
35
+
@@ -0,0 +1,35 @@
1
+ Feature: RDee should work well with browsers on your local machine
2
+
3
+ Since I only have a Mac I will test Firefox, Chrome, and Safari
4
+
5
+ Scenario: Creating a Firefox browser on the local machine using Selenium
6
+ When I establish a Firefox browser on the local machine using Selenium
7
+ Then I should be able to perform a google search for cheezyworld
8
+ And I should be able to close the connection
9
+
10
+ Scenario: Creating a Firefox browser on the local machine using Watir
11
+ When I establish a Firefox browser on the local machine using Watir
12
+ Then I should be able to perform a google search for cheezyworld
13
+ And I should be able to close the connection
14
+
15
+ Scenario: Creating a Chrome browser on the local machine using Selenium
16
+ When I establish a Chrome browser on the local machine using Selenium
17
+ Then I should be able to perform a google search for cheezyworld
18
+ And I should be able to close the connection
19
+
20
+ Scenario: Creating a Chrome browser on the local machine using Watir
21
+ When I establish a Chrome browser on the local machine using Watir
22
+ Then I should be able to perform a google search for cheezyworld
23
+ And I should be able to close the connection
24
+
25
+ Scenario: Creating a Safari browser on the local machine using Selenium
26
+ When I establish a Safari browser on the local machine using Selenium
27
+ Then I should be able to perform a google search for cheezyworld
28
+ And I should be able to close the connection
29
+
30
+ Scenario: Creating a Safari browser on the local machine using Watir
31
+ When I establish a Safari browser on the local machine using Watir
32
+ Then I should be able to perform a google search for cheezyworld
33
+ And I should be able to close the connection
34
+
35
+
@@ -0,0 +1,22 @@
1
+ When(/^I establish a (.+) browser on the local machine using (.+)$/) do |browser, platform|
2
+ @browser = RDee.send "#{platform.downcase}_browser", browser.downcase.to_sym
3
+ end
4
+
5
+ When(/^I establish a (.+) browser with a variable using (.+)$/) do |browser, platform|
6
+ ENV['RDEE_BROWSER'] = "#{browser.downcase}"
7
+ @browser = RDee.send "#{platform.downcase}_browser"
8
+ ENV.delete 'RDEE_BROWSER'
9
+ end
10
+
11
+ Then(/^I should be able to perform a google search for cheezyworld$/) do
12
+ visit(GoogleSearch) do |page|
13
+ page.perform_search
14
+ page.wait_until do
15
+ page.text.include? 'extremely cheezy'
16
+ end
17
+ end
18
+ end
19
+
20
+ Then(/^I should be able to close the connection$/) do
21
+ @browser.close
22
+ end
@@ -0,0 +1,9 @@
1
+
2
+ require 'rspec'
3
+ require 'watir-webdriver'
4
+ require 'selenium-webdriver'
5
+ require 'page-object'
6
+ require 'rdee'
7
+
8
+ World(PageObject::PageFactory)
9
+
@@ -0,0 +1,12 @@
1
+ class GoogleSearch
2
+ include PageObject
3
+
4
+ page_url 'http://google.com'
5
+
6
+ text_field(:criteria, name: 'q')
7
+
8
+ def perform_search
9
+ self.criteria = 'cheezyworld'
10
+ end
11
+
12
+ end
@@ -0,0 +1,25 @@
1
+ require 'rdee/version'
2
+ require 'rdee/browser_factory'
3
+ require 'rdee/target_parser'
4
+
5
+ module RDee
6
+
7
+ def self.watir_browser(target = :firefox, options = {})
8
+ factory.watir_browser(target, options)
9
+ end
10
+
11
+ def self.selenium_browser(target = :firefox, options = {})
12
+ factory.watir_browser(target, options)
13
+ end
14
+
15
+ def self.configure
16
+ yield factory
17
+ end
18
+
19
+ private
20
+
21
+ def self.factory
22
+ @factory ||= BrowserFactory.new
23
+ end
24
+
25
+ end
@@ -0,0 +1,88 @@
1
+ require_relative 'target_parser'
2
+
3
+ module RDee
4
+ class BrowserFactory
5
+ include TargetParser
6
+
7
+ attr_accessor :url, :persistent_http, :chrome_options, :firefox_options,
8
+ :ie_options, :safari_options, :opera_options
9
+
10
+ def watir_browser(target, options)
11
+ platform, options = platform_and_options(target, options)
12
+ watir_browser_for(platform, options)
13
+ end
14
+
15
+ def selenium_browser(target, options)
16
+ platform, options = platform_and_options(target, options)
17
+ selenium_browser_for(platform, options)
18
+ end
19
+
20
+ private
21
+
22
+ def watir_browser_for(platform, options)
23
+ if options.empty?
24
+ Watir::Browser.new platform
25
+ else
26
+ Watir::Browser.new platform, options
27
+ end
28
+ end
29
+
30
+ def selenium_browser_for(platform, options)
31
+ if options.empty?
32
+ Selenium::WebDriver.for platform
33
+ else
34
+ Selenium::WebDriver.for platform, options
35
+ end
36
+ end
37
+
38
+ def platform_and_options(target, options)
39
+ target = ENV['RDEE_BROWSER'].to_sym if ENV['RDEE_BROWSER']
40
+ platform, version, host = parse(target)
41
+ options.merge! additional_options_for target
42
+ capabilities = capabilities(platform, version, host)
43
+ options[:url] = url unless url.nil?
44
+ if options.include? :url
45
+ platform = :remote
46
+ options[:desired_capabilities] = capabilities
47
+ end
48
+ options[:http_client] = http_client if persistent_http or options.delete(:persistent_http)
49
+ return platform, options
50
+ end
51
+
52
+ def capabilities(platform, version, host)
53
+ capabilities = Selenium::WebDriver::Remote::Capabilities.send platform
54
+ capabilities.version = version unless version.nil?
55
+ capabilities.platform = host unless host.nil?
56
+ capabilities
57
+ end
58
+
59
+ def http_client
60
+ Selenium::WebDriver::Remote::Http::Persistent.new
61
+ end
62
+
63
+ def additional_options_for(target)
64
+ options = {}
65
+ options.merge!(chrome_options) if need_chrome_options? target
66
+ options.merge!(firefox_options) if need_firefox_options? target
67
+ options.merge!(ie_options) if need_ie_optons? target
68
+ options.merge!(safari_options) if need_safari_options? target
69
+ options
70
+ end
71
+
72
+ def need_chrome_options?(target)
73
+ not chrome_options.nil? and target.to_s.include? 'chrome'
74
+ end
75
+
76
+ def need_firefox_options?(target)
77
+ not firefox_options.nil? and target.to_s.include? 'firefox'
78
+ end
79
+
80
+ def need_ie_optons?(target)
81
+ not ie_options.nil? and target.to_s.include? 'ie'
82
+ end
83
+
84
+ def need_safari_options?(target)
85
+ not safari_options.nil? and target.to_s.include? 'safari'
86
+ end
87
+ end
88
+ end
@@ -0,0 +1,46 @@
1
+
2
+ module RDee
3
+ module TargetParser
4
+
5
+ def parse(value)
6
+ target = target_for(value).to_sym
7
+ version = version_for(value)
8
+ host = host_for(value)
9
+ return target, version, host
10
+ end
11
+
12
+ private
13
+
14
+ def target_for(value)
15
+ target = value.to_s.split(/\d+/)[0]
16
+ target = target.split('_')[0] if target.include? '_'
17
+ target
18
+ end
19
+
20
+ def version_for(value)
21
+ version = value.to_s.gsub(target_for(value), '').split(/_/)[0]
22
+ unless version.nil?
23
+ version = nil if version.empty?
24
+ end
25
+ version
26
+ end
27
+
28
+ def host_for(value)
29
+ host = value.to_s.split(/_/).slice(1..-1)
30
+ host_lookup[host.join('_').to_sym] if host
31
+ end
32
+
33
+ def host_lookup
34
+ @host_lookup ||= {
35
+ win81: 'Windows 8.1',
36
+ win8: 'Windows 8',
37
+ win7: 'Windows 7',
38
+ winxp: 'Windows XP',
39
+ snow_leopard: 'OS X 10.6',
40
+ mountain_lion: 'OS X 10.8',
41
+ mavricks: 'OS X 10.9',
42
+ linux: 'Linux'
43
+ }
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,3 @@
1
+ module RDee
2
+ VERSION = "0.1"
3
+ end
@@ -0,0 +1,29 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'rdee/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "RDee"
8
+ spec.version = RDee::VERSION
9
+ spec.authors = ["Jeffrey S. Morgan"]
10
+ spec.email = ["jeff.morgan@leandog.com"]
11
+ spec.summary = %q{Dynamically create a connection for Selenium or Watir.}
12
+ spec.description = %q{Dynamically create a connection for Selenium or Watir selecting the browser, version, and host os.}
13
+ spec.homepage = "https://github.com/cheezy/RDee"
14
+ spec.license = "MIT"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0")
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency 'watir-webdriver', '>= 0.6.10'
22
+ spec.add_dependency 'net-http-persistent'
23
+
24
+ spec.add_development_dependency "bundler", "~> 1.6"
25
+ spec.add_development_dependency "rake"
26
+ spec.add_development_dependency "rspec"
27
+ spec.add_development_dependency "cucumber"
28
+ spec.add_development_dependency "page-object"
29
+ end
@@ -0,0 +1,175 @@
1
+ require 'spec_helper'
2
+ require 'selenium/webdriver/remote/http/persistent'
3
+
4
+ describe RDee do
5
+
6
+ let(:watir_browser) { Watir::Browser }
7
+
8
+ context "when getting a connection for Watir" do
9
+ it "should create a Firefox browser by default" do
10
+ expect(watir_browser).to receive(:new).with(:firefox)
11
+ RDee.watir_browser
12
+ end
13
+ end
14
+
15
+ context "when getting a connection for Selenium" do
16
+ let(:selenium_browser) { Selenium::WebDriver }
17
+
18
+ it "should create a Firefox browser by default" do
19
+ expect(selenium_browser).to receive(:for).with(:firefox)
20
+ RDee.selenium_browser
21
+ end
22
+ end
23
+
24
+ context "when using common functionality" do
25
+ it "should use the BROWSER environment variable when present" do
26
+ ENV['RDEE_BROWSER'] = 'chrome'
27
+ expect(watir_browser).to receive(:new).with(:chrome)
28
+ RDee.watir_browser
29
+ ENV.delete 'RDEE_BROWSER'
30
+ end
31
+
32
+ it "should provide option to use persistent http client" do
33
+ client = double('http_client')
34
+ expect(Selenium::WebDriver::Remote::Http::Persistent).to receive(:new).and_return(client)
35
+ expect(watir_browser).to receive(:new).with(:firefox, http_client: client)
36
+ RDee.watir_browser(:firefox, persistent_http: true)
37
+ end
38
+
39
+ it "should not use the persistent http client when set to false" do
40
+ expect(Selenium::WebDriver::Remote::Http::Persistent).to_not receive(:new)
41
+ expect(watir_browser).to receive(:new).with(:firefox)
42
+ RDee.watir_browser(:firefox, persistent_http: false)
43
+ end
44
+
45
+ it "should allow users to set the persistent http setting by configuration" do
46
+ RDee.configure do |config|
47
+ config.persistent_http = true
48
+ end
49
+ client = double('http_client')
50
+ expect(Selenium::WebDriver::Remote::Http::Persistent).to receive(:new).and_return(client)
51
+ expect(watir_browser).to receive(:new).with(:firefox, http_client: client)
52
+ RDee.watir_browser(:firefox)
53
+ RDee.configure do |config|
54
+ config.persistent_http = nil
55
+ end
56
+ end
57
+
58
+ it "should provide option to use a remote url" do
59
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
60
+ RDee.watir_browser(:firefox, url: 'http://blah')
61
+ end
62
+
63
+ it "should allow users to set the remote url setting by configuration" do
64
+ RDee.configure do |config|
65
+ config.url = 'http://blah'
66
+ end
67
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
68
+ RDee.watir_browser(:firefox)
69
+ RDee.configure do |config|
70
+ config.url = nil
71
+ end
72
+ end
73
+ end
74
+
75
+ context "when passing additional browser options" do
76
+ it "should allow users to add additional options for chrome by configuration" do
77
+ RDee.configure do |config|
78
+ config.chrome_options = {chrome_options: 'option'}
79
+ end
80
+ expect(watir_browser).to receive(:new).with(:chrome, chrome_options: 'option')
81
+ RDee.watir_browser(:chrome)
82
+ RDee.configure do |config|
83
+ config.chrome_options = nil
84
+ end
85
+ end
86
+
87
+ it "should not add chrome_options when not using chrome" do
88
+ RDee.configure do |config|
89
+ config.chrome_options = {chrome_options: 'option'}
90
+ end
91
+ expect(watir_browser).to receive(:new).with(:firefox)
92
+ RDee.watir_browser(:firefox)
93
+ RDee.configure do |config|
94
+ config.chrome_options = nil
95
+ end
96
+ end
97
+
98
+ it "should allow users to add additional options for firefox by configuration" do
99
+ RDee.configure do |config|
100
+ config.firefox_options = {firefox_options: 'option'}
101
+ end
102
+ expect(watir_browser).to receive(:new).with(:firefox, firefox_options: 'option')
103
+ RDee.watir_browser(:firefox)
104
+ RDee.configure do |config|
105
+ config.firefox_options = nil
106
+ end
107
+ end
108
+
109
+ it "should not add firefox_options when not using firefox" do
110
+ RDee.configure do |config|
111
+ config.firefox_options = {firefox_options: 'option'}
112
+ end
113
+ expect(watir_browser).to receive(:new).with(:chrome)
114
+ RDee.watir_browser(:chrome)
115
+ RDee.configure do |config|
116
+ config.firefox_options = nil
117
+ end
118
+ end
119
+
120
+ it "should allow users to add additional options for IE by configuration" do
121
+ RDee.configure do |config|
122
+ config.ie_options = {ie_options: 'option'}
123
+ end
124
+ expect(watir_browser).to receive(:new).with(:ie, ie_options: 'option')
125
+ RDee.watir_browser(:ie)
126
+ RDee.configure do |config|
127
+ config.ie_options = nil
128
+ end
129
+ end
130
+
131
+ it "should not add ie_options when not using ie" do
132
+ RDee.configure do |config|
133
+ config.ie_options = {ie_options: 'option'}
134
+ end
135
+ expect(watir_browser).to receive(:new).with(:firefox)
136
+ RDee.watir_browser(:firefox)
137
+ RDee.configure do |config|
138
+ config.ie_options = nil
139
+ end
140
+ end
141
+
142
+ it "should allow users to add additional options for Safari by configuration" do
143
+ RDee.configure do |config|
144
+ config.safari_options = {safari_options: 'option'}
145
+ end
146
+ expect(watir_browser).to receive(:new).with(:safari, safari_options: 'option')
147
+ RDee.watir_browser(:safari)
148
+ RDee.configure do |config|
149
+ config.safari_options = nil
150
+ end
151
+ end
152
+
153
+ it "should not add safari_options when not using safari" do
154
+ RDee.configure do |config|
155
+ config.safari_options = {safari_options: 'option'}
156
+ end
157
+ expect(watir_browser).to receive(:new).with(:firefox)
158
+ RDee.watir_browser(:firefox)
159
+ RDee.configure do |config|
160
+ config.safari_options = nil
161
+ end
162
+ end
163
+
164
+ it "should not allow opera_options when not using opera" do
165
+ RDee.configure do |config|
166
+ config.opera_options = {opera_options: 'option'}
167
+ end
168
+ expect(watir_browser).to receive(:new).with(:firefox)
169
+ RDee.watir_browser(:firefox)
170
+ RDee.configure do |config|
171
+ config.opera_options = nil
172
+ end
173
+ end
174
+ end
175
+ end
@@ -0,0 +1,73 @@
1
+ require 'spec_helper'
2
+
3
+ class TestSubject
4
+ include RDee::TargetParser
5
+ end
6
+
7
+
8
+ describe RDee::TargetParser do
9
+
10
+ let(:parser) { TestSubject.new }
11
+
12
+ it "should parse generic Firefox" do
13
+ target, version, host = parser.parse(:firefox)
14
+ expect(target).to eql :firefox
15
+ end
16
+
17
+ it "should parse the version number" do
18
+ target, version, host = parser.parse(:firefox30)
19
+ expect(version).to eql '30'
20
+ end
21
+
22
+ it "should handle just target and host" do
23
+ target, version, host = parser.parse(:firefox_win81)
24
+ expect(target).to eql :firefox
25
+ expect(host).to eql 'Windows 8.1'
26
+ expect(version).to be_nil
27
+ end
28
+
29
+ it "should parse the windows 8.1 host" do
30
+ target, version, host = parser.parse(:firefox30_win81)
31
+ expect(host).to eql 'Windows 8.1'
32
+ end
33
+
34
+ it "should parse the windows 8 host" do
35
+ target, version, host = parser.parse(:firefox30_win8)
36
+ expect(host).to eql 'Windows 8'
37
+ end
38
+
39
+ it "should parse the windows 7 host" do
40
+ target, version, host = parser.parse(:firefox30_win7)
41
+ expect(host).to eql 'Windows 7'
42
+ end
43
+
44
+ it "should parse the windows xp host" do
45
+ target, version, host = parser.parse(:firefox30_winxp)
46
+ expect(host).to eql 'Windows XP'
47
+ end
48
+
49
+ it "should parse snow leopard" do
50
+ target, version, host = parser.parse(:firefox30_snow_leopard)
51
+ expect(host).to eql 'OS X 10.6'
52
+ end
53
+
54
+ it "should parse mountain lion" do
55
+ target, version, host = parser.parse(:firefox30_mountain_lion)
56
+ expect(host).to eql 'OS X 10.8'
57
+ end
58
+
59
+ it "should parse mavricks" do
60
+ target, version, host = parser.parse(:firefox30_mavricks)
61
+ expect(host).to eql 'OS X 10.9'
62
+ end
63
+
64
+ it "should parse linux" do
65
+ target, version, host = parser.parse(:firefox30_linux)
66
+ expect(host).to eql 'Linux'
67
+ end
68
+
69
+ it "should cleanly handle an invalid host" do
70
+ target, version, host = parser.parse(:firefox30_foobar)
71
+ expect(host).to be_nil
72
+ end
73
+ end
@@ -0,0 +1,241 @@
1
+ require 'spec_helper'
2
+
3
+ describe "Supported browser combinations" do
4
+
5
+ let(:watir_browser) { Watir::Browser }
6
+ let(:capabilities) { Selenium::WebDriver::Remote::Capabilities }
7
+ let(:desired_capabilities) { double('capabilities') }
8
+
9
+ context "for Firefox" do
10
+
11
+ before(:each) do
12
+ allow(capabilities).to receive(:firefox).and_return(desired_capabilities)
13
+ end
14
+
15
+ it "includes generic Firefox" do
16
+ expect(watir_browser).to receive(:new).with(:firefox)
17
+ RDee.watir_browser :firefox
18
+ end
19
+
20
+ it "includes Firefox 30" do
21
+ expect(desired_capabilities).to receive(:version=).with('30')
22
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
23
+ RDee.watir_browser :firefox30, url: 'http://blah'
24
+ end
25
+
26
+ it "includes Firefox 29" do
27
+ expect(desired_capabilities).to receive(:version=).with('29')
28
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
29
+ RDee.watir_browser :firefox29, url: 'http://blah'
30
+ end
31
+
32
+ it "includes Firefox 28" do
33
+ expect(desired_capabilities).to receive(:version=).with('28')
34
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
35
+ RDee.watir_browser :firefox28, url: 'http://blah'
36
+ end
37
+
38
+ it "includes Firefox 27" do
39
+ expect(desired_capabilities).to receive(:version=).with('27')
40
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
41
+ RDee.watir_browser :firefox27, url: 'http://blah'
42
+ end
43
+
44
+ it "includes Firefox 26" do
45
+ expect(desired_capabilities).to receive(:version=).with('26')
46
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
47
+ RDee.watir_browser :firefox26, url: 'http://blah'
48
+ end
49
+
50
+ end
51
+
52
+ context "for Chrome" do
53
+
54
+ before(:each) do
55
+ allow(capabilities).to receive(:chrome).and_return(desired_capabilities)
56
+ end
57
+
58
+ it "includes generic Chrome" do
59
+ expect(watir_browser).to receive(:new).with(:chrome)
60
+ RDee.watir_browser :chrome
61
+ end
62
+
63
+ it "includes Chrome 35" do
64
+ expect(desired_capabilities).to receive(:version=).with('35')
65
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
66
+ RDee.watir_browser :chrome35, url: 'http://blah'
67
+ end
68
+
69
+ it "includes Chrome 34" do
70
+ expect(desired_capabilities).to receive(:version=).with('34')
71
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
72
+ RDee.watir_browser :chrome34, url: 'http://blah'
73
+ end
74
+
75
+ it "includes Chrome 33" do
76
+ expect(desired_capabilities).to receive(:version=).with('33')
77
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
78
+ RDee.watir_browser :chrome33, url: 'http://blah'
79
+ end
80
+
81
+ it "includes Chrome 32" do
82
+ expect(desired_capabilities).to receive(:version=).with('32')
83
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
84
+ RDee.watir_browser :chrome32, url: 'http://blah'
85
+ end
86
+
87
+ it "includes Chrome 31" do
88
+ expect(desired_capabilities).to receive(:version=).with('31')
89
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
90
+ RDee.watir_browser :chrome31, url: 'http://blah'
91
+ end
92
+ end
93
+
94
+ context "for Internet Explorer" do
95
+
96
+ before(:each) do
97
+ allow(capabilities).to receive(:ie).and_return(desired_capabilities)
98
+ end
99
+
100
+ it "includes generic Internet Explorer" do
101
+ expect(watir_browser).to receive(:new).with(:ie)
102
+ RDee.watir_browser :ie
103
+ end
104
+
105
+ it "includes Internet Explorer 11" do
106
+ expect(desired_capabilities).to receive(:version=).with('11')
107
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
108
+ RDee.watir_browser :ie11, url: 'http://blah'
109
+ end
110
+
111
+ it "includes Internet Explorer 10" do
112
+ expect(desired_capabilities).to receive(:version=).with('10')
113
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
114
+ RDee.watir_browser :ie10, url: 'http://blah'
115
+ end
116
+
117
+ it "includes Internet Explorer 9" do
118
+ expect(desired_capabilities).to receive(:version=).with('9')
119
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
120
+ RDee.watir_browser :ie9, url: 'http://blah'
121
+ end
122
+
123
+ it "includes Internet Explorer 8" do
124
+ expect(desired_capabilities).to receive(:version=).with('8')
125
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
126
+ RDee.watir_browser :ie8, url: 'http://blah'
127
+ end
128
+
129
+ it "includes Internet Explorer 7" do
130
+ expect(desired_capabilities).to receive(:version=).with('7')
131
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
132
+ RDee.watir_browser :ie7, url: 'http://blah'
133
+ end
134
+
135
+ it "includes Internet Explorer 6" do
136
+ expect(desired_capabilities).to receive(:version=).with('6')
137
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
138
+ RDee.watir_browser :ie6, url: 'http://blah'
139
+ end
140
+
141
+ end
142
+
143
+ context "for Phantomjs" do
144
+ it "includes generic Phantomjs" do
145
+ expect(watir_browser).to receive(:new).with(:phantomjs)
146
+ RDee.watir_browser :phantomjs
147
+ end
148
+ end
149
+
150
+ context "for Safari" do
151
+
152
+ before(:each) do
153
+ allow(capabilities).to receive(:safari).and_return(desired_capabilities)
154
+ end
155
+
156
+ it "includes generic Safari" do
157
+ expect(watir_browser).to receive(:new).with(:safari)
158
+ RDee.watir_browser :safari
159
+ end
160
+
161
+ it "includes Safari 7" do
162
+ expect(desired_capabilities).to receive(:version=).with('7')
163
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
164
+ RDee.watir_browser :safari7, url: 'http://blah'
165
+ end
166
+
167
+ it "includes Safari 6" do
168
+ expect(desired_capabilities).to receive(:version=).with('6')
169
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
170
+ RDee.watir_browser :safari6, url: 'http://blah'
171
+ end
172
+
173
+ it "includes Safari 5" do
174
+ expect(desired_capabilities).to receive(:version=).with('5')
175
+ expect(watir_browser).to receive(:new).with(:remote, url: 'http://blah', desired_capabilities: anything())
176
+ RDee.watir_browser :safari5, url: 'http://blah'
177
+ end
178
+ end
179
+
180
+ context "for hosts" do
181
+ before(:each) do
182
+ allow(capabilities).to receive(:firefox).and_return(desired_capabilities)
183
+ end
184
+
185
+ it "should properly identify Windows 8.1" do
186
+ expect(desired_capabilities).to receive(:version=).with('30')
187
+ expect(desired_capabilities).to receive(:platform=).with('Windows 8.1')
188
+ expect(watir_browser).to receive(:new)
189
+ RDee.watir_browser :firefox30_win81, url: 'http://blah'
190
+ end
191
+
192
+ it "should properly identify Windows 8" do
193
+ expect(desired_capabilities).to receive(:version=).with('30')
194
+ expect(desired_capabilities).to receive(:platform=).with('Windows 8')
195
+ expect(watir_browser).to receive(:new)
196
+ RDee.watir_browser :firefox30_win8, url: 'http://blah'
197
+ end
198
+
199
+ it "should properly identify Windows 7" do
200
+ expect(desired_capabilities).to receive(:version=).with('30')
201
+ expect(desired_capabilities).to receive(:platform=).with('Windows 7')
202
+ expect(watir_browser).to receive(:new)
203
+ RDee.watir_browser :firefox30_win7, url: 'http://blah'
204
+ end
205
+
206
+ it "should properly identify Windows XP" do
207
+ expect(desired_capabilities).to receive(:version=).with('30')
208
+ expect(desired_capabilities).to receive(:platform=).with('Windows XP')
209
+ expect(watir_browser).to receive(:new)
210
+ RDee.watir_browser :firefox30_winxp, url: 'http://blah'
211
+ end
212
+
213
+ it "should properly identify Snow Leopard" do
214
+ expect(desired_capabilities).to receive(:version=).with('30')
215
+ expect(desired_capabilities).to receive(:platform=).with('OS X 10.6')
216
+ expect(watir_browser).to receive(:new)
217
+ RDee.watir_browser :firefox30_snow_leopard, url: 'http://blah'
218
+ end
219
+
220
+ it "should properly identify Mountain Lion" do
221
+ expect(desired_capabilities).to receive(:version=).with('30')
222
+ expect(desired_capabilities).to receive(:platform=).with('OS X 10.8')
223
+ expect(watir_browser).to receive(:new)
224
+ RDee.watir_browser :firefox30_mountain_lion, url: 'http://blah'
225
+ end
226
+
227
+ it "should properly identify Mavricks" do
228
+ expect(desired_capabilities).to receive(:version=).with('30')
229
+ expect(desired_capabilities).to receive(:platform=).with('OS X 10.9')
230
+ expect(watir_browser).to receive(:new)
231
+ RDee.watir_browser :firefox30_mavricks, url: 'http://blah'
232
+ end
233
+
234
+ it "should properly identify Linux" do
235
+ expect(desired_capabilities).to receive(:version=).with('30')
236
+ expect(desired_capabilities).to receive(:platform=).with('Linux')
237
+ expect(watir_browser).to receive(:new)
238
+ RDee.watir_browser :firefox30_linux, url: 'http://blah'
239
+ end
240
+ end
241
+ end
@@ -0,0 +1,6 @@
1
+ require 'rdee'
2
+ require 'watir-webdriver'
3
+ require 'selenium-webdriver'
4
+
5
+
6
+
metadata ADDED
@@ -0,0 +1,176 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: RDee
3
+ version: !ruby/object:Gem::Version
4
+ version: '0.1'
5
+ platform: ruby
6
+ authors:
7
+ - Jeffrey S. Morgan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-07-23 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: watir-webdriver
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 0.6.10
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.10
27
+ - !ruby/object:Gem::Dependency
28
+ name: net-http-persistent
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: cucumber
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: page-object
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Dynamically create a connection for Selenium or Watir selecting the browser,
112
+ version, and host os.
113
+ email:
114
+ - jeff.morgan@leandog.com
115
+ executables: []
116
+ extensions: []
117
+ extra_rdoc_files: []
118
+ files:
119
+ - ".gitignore"
120
+ - ".rspec"
121
+ - ".travis.yml"
122
+ - ChangeLog
123
+ - Gemfile
124
+ - Guardfile
125
+ - LICENSE.txt
126
+ - README.md
127
+ - Rakefile
128
+ - cucumber.yml
129
+ - features/environment_variable.feature
130
+ - features/local_browsers.feature
131
+ - features/step_definitions/rdee_steps.rb
132
+ - features/support/env.rb
133
+ - features/support/pages/google_search.rb
134
+ - lib/rdee.rb
135
+ - lib/rdee/browser_factory.rb
136
+ - lib/rdee/target_parser.rb
137
+ - lib/rdee/version.rb
138
+ - rdee.gemspec
139
+ - spec/lib/rd_spec.rb
140
+ - spec/lib/target_parser_spec.rb
141
+ - spec/lib/targets_spec.rb
142
+ - spec/spec_helper.rb
143
+ homepage: https://github.com/cheezy/RDee
144
+ licenses:
145
+ - MIT
146
+ metadata: {}
147
+ post_install_message:
148
+ rdoc_options: []
149
+ require_paths:
150
+ - lib
151
+ required_ruby_version: !ruby/object:Gem::Requirement
152
+ requirements:
153
+ - - ">="
154
+ - !ruby/object:Gem::Version
155
+ version: '0'
156
+ required_rubygems_version: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - ">="
159
+ - !ruby/object:Gem::Version
160
+ version: '0'
161
+ requirements: []
162
+ rubyforge_project:
163
+ rubygems_version: 2.2.2
164
+ signing_key:
165
+ specification_version: 4
166
+ summary: Dynamically create a connection for Selenium or Watir.
167
+ test_files:
168
+ - features/environment_variable.feature
169
+ - features/local_browsers.feature
170
+ - features/step_definitions/rdee_steps.rb
171
+ - features/support/env.rb
172
+ - features/support/pages/google_search.rb
173
+ - spec/lib/rd_spec.rb
174
+ - spec/lib/target_parser_spec.rb
175
+ - spec/lib/targets_spec.rb
176
+ - spec/spec_helper.rb