rlicker 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ NDcyY2FkODQ2NzRkYjZjZTRhOGRhY2FkZTI3ZDQyOGU0YjExN2YwOQ==
5
+ data.tar.gz: !binary |-
6
+ MGM1YjlmMDQyMWY1YTRkYjE1ZDA3YWQxNmNmOGI1M2M2ZDZhMjY5OA==
7
+ SHA512:
8
+ metadata.gz: !binary |-
9
+ Y2ViZWEwYTU5MDUwNmQwMGUwZDgwMWRiOTQwYWEzOWRlZDdkZWNhMjEwNmFm
10
+ YWQ0ZTdkMTAwYmFjNmYxZDgxYTNmNGFkYzRjYTg5YTMzMDlkMmNkZDhkZjVj
11
+ NzgzYzA0Mzk2YTA4OGVmZGVlZWQzNDFhNjI4NjRjMjk5YTg4Yjc=
12
+ data.tar.gz: !binary |-
13
+ MzYyMWFhYjQ4ZmJjNTZhMzBiZmJhMGIxMTg5ZjljMzI3N2U5MWU0MzVmODVm
14
+ ZTE0YTViZWNiYzQxMjZhMjVjMmIwM2JjMzI1YzJmMzdmODM5ZDRlOWJjM2M1
15
+ YzY4YjA0ZTc5MmJlMzMzNGVjOTA2ZTA3NTBhMjRjZjYyOTBlMzQ=
data/.document ADDED
@@ -0,0 +1,5 @@
1
+ lib/**/*.rb
2
+ bin/*
3
+ -
4
+ features/**/*.feature
5
+ LICENSE.txt
data/.travis.yml ADDED
@@ -0,0 +1,14 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ branches:
6
+ only:
7
+ - master
8
+ gemfile: Gemfile
9
+ notifications:
10
+ recipients:
11
+ - ben.biddington@gmail.com
12
+ before_script:
13
+ - "export DISPLAY=:99.0"
14
+ - "sh -e /etc/init.d/xvfb start"
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ source "https://rubygems.org"
2
+
3
+ group :development do
4
+ gem "bundler", "~> 1.0"
5
+ gem "jeweler", "~> 1.8.7"
6
+ end
7
+
8
+ gem "sauce"
9
+ gem "sauce-connect"
10
+ gem "audible"
11
+ gem "watir-webdriver"
12
+ gem "capybara"
13
+ gem "capybara-webkit", "0.14.2"
14
+
15
+ group :test do
16
+ gem "rake"
17
+ gem "rspec"
18
+ gem "travis-lint"
19
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,131 @@
1
+ GEM
2
+ remote: https://rubygems.org/
3
+ specs:
4
+ activesupport (3.2.1)
5
+ i18n (~> 0.6)
6
+ multi_json (~> 1.0)
7
+ addressable (2.3.5)
8
+ audible (0.1.0)
9
+ builder (3.2.2)
10
+ capybara (2.2.0)
11
+ mime-types (>= 1.16)
12
+ nokogiri (>= 1.3.3)
13
+ rack (>= 1.0.0)
14
+ rack-test (>= 0.5.4)
15
+ xpath (~> 2.0)
16
+ capybara-webkit (0.14.2)
17
+ capybara (~> 2.0, >= 2.0.2)
18
+ json
19
+ childprocess (0.3.9)
20
+ ffi (~> 1.0, >= 1.0.11)
21
+ cmdparse (2.0.5)
22
+ diff-lcs (1.1.3)
23
+ faraday (0.8.8)
24
+ multipart-post (~> 1.2.0)
25
+ ffi (1.9.3)
26
+ git (1.2.6)
27
+ github_api (0.10.1)
28
+ addressable
29
+ faraday (~> 0.8.1)
30
+ hashie (>= 1.2)
31
+ multi_json (~> 1.4)
32
+ nokogiri (~> 1.5.2)
33
+ oauth2
34
+ hashie (2.0.5)
35
+ hashr (0.0.19)
36
+ highline (1.6.19)
37
+ httpauth (0.2.0)
38
+ i18n (0.6.0)
39
+ jeweler (1.8.8)
40
+ builder
41
+ bundler (~> 1.0)
42
+ git (>= 1.2.5)
43
+ github_api (= 0.10.1)
44
+ highline (>= 1.6.15)
45
+ nokogiri (= 1.5.10)
46
+ rake
47
+ rdoc
48
+ json (1.8.1)
49
+ jwt (0.1.8)
50
+ multi_json (>= 1.5)
51
+ mime-types (2.0)
52
+ multi_json (1.8.2)
53
+ multi_xml (0.5.5)
54
+ multipart-post (1.2.0)
55
+ net-http-persistent (2.9)
56
+ net-ssh (2.7.0)
57
+ net-ssh-gateway (1.2.0)
58
+ net-ssh (>= 2.6.5)
59
+ nokogiri (1.5.10)
60
+ oauth2 (0.9.2)
61
+ faraday (~> 0.8)
62
+ httpauth (~> 0.2)
63
+ jwt (~> 0.1.4)
64
+ multi_json (~> 1.0)
65
+ multi_xml (~> 0.5)
66
+ rack (~> 1.2)
67
+ parallel (0.8.2)
68
+ parallel_tests (0.15.0)
69
+ parallel
70
+ rack (1.5.2)
71
+ rack-test (0.6.2)
72
+ rack (>= 1.0)
73
+ rake (0.9.2.2)
74
+ rdoc (4.0.1)
75
+ json (~> 1.4)
76
+ rest-client (1.6.7)
77
+ mime-types (>= 1.16)
78
+ rspec (2.8.0)
79
+ rspec-core (~> 2.8.0)
80
+ rspec-expectations (~> 2.8.0)
81
+ rspec-mocks (~> 2.8.0)
82
+ rspec-core (2.8.0)
83
+ rspec-expectations (2.8.0)
84
+ diff-lcs (~> 1.1.2)
85
+ rspec-mocks (2.8.0)
86
+ rubyzip (1.0.0)
87
+ sauce (3.1.3)
88
+ childprocess (>= 0.1.6)
89
+ cmdparse (>= 2.0.2)
90
+ highline (>= 1.5.0)
91
+ json (>= 1.2.0)
92
+ net-http-persistent
93
+ net-ssh
94
+ net-ssh-gateway
95
+ parallel_tests (= 0.15.0)
96
+ rest-client
97
+ sauce_whisk (~> 0.0.8)
98
+ selenium-webdriver (>= 0.1.2)
99
+ sauce-connect (3.1.0)
100
+ sauce (~> 3.1)
101
+ sauce_whisk (0.0.10)
102
+ rest-client
103
+ selenium-webdriver (2.37.0)
104
+ childprocess (>= 0.2.5)
105
+ multi_json (~> 1.0)
106
+ rubyzip (~> 1.0.0)
107
+ websocket (~> 1.0.4)
108
+ travis-lint (1.0.0)
109
+ activesupport (~> 3.2.0)
110
+ hashr (>= 0.0.19)
111
+ watir-webdriver (0.6.4)
112
+ selenium-webdriver (>= 2.18.0)
113
+ websocket (1.0.7)
114
+ xpath (2.0.0)
115
+ nokogiri (~> 1.3)
116
+
117
+ PLATFORMS
118
+ ruby
119
+
120
+ DEPENDENCIES
121
+ audible
122
+ bundler (~> 1.0)
123
+ capybara
124
+ capybara-webkit (= 0.14.2)
125
+ jeweler (~> 1.8.7)
126
+ rake
127
+ rspec
128
+ sauce
129
+ sauce-connect
130
+ travis-lint
131
+ watir-webdriver
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Ben Biddington
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,12 @@
1
+ # RLicker
2
+ [![Build Status](https://secure.travis-ci.org/ben-biddington/rlicker.png)](http://travis-ci.org/ben-biddington/rlicker)
3
+
4
+ Why should I have to subscribe to one particular browser driver? Each seems to have incompatible DSLs and different ideas about abstraction. Changing from one to the other is a non-trivial exercise.
5
+
6
+ RLicker aims to perform a kind of [dependency inversion](http://www.objectmentor.com/resources/articles/Principles_and_Patterns.pdf), providing an abstraction to program against, enabling the implementation to be switched easily -- even at runtime.
7
+
8
+ I am starting with [capybara webkit](https://github.com/thoughtbot/capybara-webkit) as a reference implementation because it rules.
9
+
10
+ # References
11
+ * [Continuous Delivery](http://martinfowler.com/books.html#continuousDelivery)
12
+ * [GOOS](http://www.growing-object-oriented-software.com)
data/README.rdoc ADDED
@@ -0,0 +1,19 @@
1
+ = rlicker
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to rlicker
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2013 Ben Biddington. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,40 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+
6
+ begin
7
+ Bundler.setup(:default, :development)
8
+ rescue Bundler::BundlerError => e
9
+ $stderr.puts e.message
10
+ $stderr.puts "Run `bundle install` to install missing gems"
11
+ exit e.status_code
12
+ end
13
+
14
+ require 'rake'
15
+
16
+ require 'jeweler'
17
+ Jeweler::Tasks.new do |gem|
18
+ gem.name = "rlicker"
19
+ gem.homepage = "http://github.com/ben-biddington/rlicker"
20
+ gem.license = "MIT"
21
+ gem.summary = %Q{}
22
+ gem.description = %Q{}
23
+ gem.email = "ben.biddington@gmail.com"
24
+ gem.authors = ["Ben Biddington"]
25
+ # dependencies defined in Gemfile
26
+ end
27
+ Jeweler::RubygemsDotOrgTasks.new
28
+
29
+ require 'rspec/core/rake_task'
30
+
31
+ task :default => :ci
32
+
33
+ desc "Run all tests"
34
+ RSpec::Core::RakeTask.new
35
+
36
+ desc "Run just the tests suitable for CI"
37
+ RSpec::Core::RakeTask.new do |t|
38
+ t.name = :ci
39
+ t.pattern = "spec/integration/capybara_webkit_spec.rb"
40
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 1.1.0
data/lib/rlicker.rb ADDED
@@ -0,0 +1,5 @@
1
+ lib = File.expand_path(File.join(File.dirname(__FILE__), "rlicker"))
2
+
3
+ $:.unshift lib
4
+
5
+ Dir.glob(File.join(lib, "**", "*.rb")).each {|file| require file}
@@ -0,0 +1,36 @@
1
+ module RLicker
2
+ module Lickers
3
+ class CapybaraWebkitLicker
4
+ def initialize
5
+ require "capybara-webkit"
6
+ connection = Capybara::Webkit::Connection.new
7
+ @browser = Capybara::Webkit::Driver.new Capybara::Webkit::Browser.new connection
8
+ end
9
+
10
+ def goto(earl)
11
+ @browser.visit earl
12
+ end
13
+
14
+ def url; @browser.current_url; end
15
+ def close; end
16
+
17
+ def find_by_id(id)
18
+ find :id => id
19
+ end
20
+
21
+ def find(selector = {})
22
+ attribute_name = selector.keys.first
23
+ attribute_value = selector[attribute_name]
24
+ @browser.find("//*[@#{attribute_name}='#{attribute_value}']").first
25
+ end
26
+
27
+ def evaluate_script(what)
28
+ @browser.evaluate_script what
29
+ end
30
+
31
+ def execute_script(what)
32
+ @browser.execute_script what
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,83 @@
1
+ module RLicker
2
+ module Lickers
3
+ class ChromeLicker
4
+ require "audible"; include Audible
5
+
6
+ def visit(earl)
7
+ browser.goto ChromeEarl.new(earl).to_s
8
+ end
9
+
10
+ alias :goto :visit
11
+
12
+ def find_by_id(id)
13
+ find(:id => id)
14
+ end
15
+
16
+ def find(selector = {})
17
+ return nil if selector.empty?
18
+
19
+ attribute_name = selector.keys.first
20
+ attribute_value = selector[attribute_name]
21
+
22
+ all.each do |tag_name|
23
+ begin
24
+ found_thing = browser.send(tag_name, selector)
25
+ return found_thing if found_thing && found_thing.exists?
26
+ rescue Watir::Exception::UnknownObjectException => e
27
+
28
+ end
29
+ end
30
+
31
+ fail "Could not locate an element with selector <#{selector}>. Searched elements #{all.inspect}."
32
+ end
33
+
34
+ def screenshot; fail "Not supported."; end
35
+
36
+ def close; @browser.close if @browser; end
37
+
38
+ def evaluate_script(what)
39
+ execute_script what
40
+ end
41
+
42
+ def execute_script(what)
43
+ browser.execute_script "javascript:#{what}"
44
+ end
45
+
46
+ def url; browser.url; end
47
+
48
+ private
49
+
50
+ def browser
51
+ require 'watir-webdriver'
52
+
53
+ @browser ||= new_browser
54
+ end
55
+
56
+ def new_browser
57
+ #See: http://chromedriver.storage.googleapis.com/index.html for chromedriver executable
58
+ @browser = Watir::Browser.new :chrome
59
+ end
60
+
61
+ def all
62
+ [:text_field, :button, :form, :link, :div, :span, :h1, :h2, :h3, :h4, :h5, :input, :password]
63
+ end
64
+ end
65
+
66
+ class ChromeEarl
67
+ def initialize(value)
68
+ @value = value
69
+ end
70
+
71
+ def to_s
72
+ return "file://#{@value}" unless starts_with_scheme
73
+ @value
74
+ end
75
+
76
+ private
77
+
78
+ def starts_with_scheme
79
+ @value.start_with? "http"
80
+ end
81
+ end
82
+ end
83
+ end
@@ -0,0 +1,75 @@
1
+ module RLicker
2
+ module Lickers
3
+ class SauceLabsSettings
4
+ class << self
5
+ def username; setting_called "sauce_labs_username"; end
6
+ def access_key; setting_called "sauce_labs_accesskey"; end
7
+ def job_name; setting_called "sauce_labs_job_name"; end
8
+
9
+ private
10
+
11
+ def setting_called(name)
12
+ ENV[name].tap{fail "You must supply the <#{name}> environment variable." unless exists?(name)}
13
+ end
14
+
15
+ def exists?(name) ENV.include? name; end
16
+ end
17
+ end
18
+
19
+ # For config: https://github.com/saucelabs/sauce_ruby/wiki/Configuration----The-(in)Complete-Guide
20
+ class SauceLabsLicker
21
+ require "audible"; include Audible
22
+
23
+ def initialize
24
+ require "capybara"
25
+ require "sauce/capybara"
26
+
27
+ ENV["SAUCE_USERNAME"] = SauceLabsSettings.username
28
+ ENV["SAUCE_ACCESS_KEY"] = SauceLabsSettings.access_key
29
+
30
+ Sauce.config do |c|
31
+ c[:job_name] = SauceLabsSettings.job_name
32
+ c[:start_local_application] = false
33
+ c[:browser] = "Chrome"
34
+ c[:browser_version] = nil
35
+ c[:record_screenshots] = false
36
+ c[:command_timeout] = 15
37
+ c[:max_duration] = 300
38
+ end
39
+
40
+ Capybara.default_driver = :sauce
41
+
42
+ notify :initialized, Sauce.get_config.opts
43
+ end
44
+
45
+ def find_by_id(id)
46
+ find(:id => id)
47
+ end
48
+
49
+ def find(selector = {})
50
+ attribute_name = selector.keys.first
51
+ attribute_value = selector[attribute_name]
52
+
53
+ driver.find(:xpath, "//*[@#{attribute_name}='#{attribute_value}']")
54
+ end
55
+
56
+ def goto(earl); driver.visit earl; end
57
+
58
+ def close; end
59
+
60
+ def status_code; driver.status_code; end
61
+
62
+ def url; driver.current_url; end
63
+
64
+ def evaluate_script(script); driver.evaluate_script script; end
65
+
66
+ def execute_script(script); driver.execute_script script; end
67
+
68
+ def body; driver.body; end
69
+
70
+ private
71
+
72
+ def driver; Capybara.current_session; end
73
+ end
74
+ end
75
+ end
data/rlicker.gemspec ADDED
@@ -0,0 +1,83 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: rlicker 1.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "rlicker"
9
+ s.version = "1.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Ben Biddington"]
14
+ s.date = "2015-01-28"
15
+ s.description = ""
16
+ s.email = "ben.biddington@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md",
20
+ "README.rdoc"
21
+ ]
22
+ s.files = [
23
+ ".document",
24
+ ".travis.yml",
25
+ "Gemfile",
26
+ "Gemfile.lock",
27
+ "LICENSE.txt",
28
+ "README.md",
29
+ "README.rdoc",
30
+ "Rakefile",
31
+ "VERSION",
32
+ "lib/rlicker.rb",
33
+ "lib/rlicker/capybara_webkit_licker.rb",
34
+ "lib/rlicker/chrome_licker.rb",
35
+ "lib/rlicker/sauce_labs_licker.rb",
36
+ "rlicker.gemspec",
37
+ "spec/integration/capybara_webkit_spec.rb",
38
+ "spec/integration/chrome_licker_spec.rb",
39
+ "spec/integration/given.rb",
40
+ "spec/integration/samples/.gitkeep",
41
+ "spec/integration/sauce_labs_spec.rb",
42
+ "spec/integration/shared_examples/window_licker.rb",
43
+ "spec/spec_helper.rb"
44
+ ]
45
+ s.homepage = "http://github.com/ben-biddington/rlicker"
46
+ s.licenses = ["MIT"]
47
+ s.rubygems_version = "2.4.3"
48
+ s.summary = ""
49
+
50
+ if s.respond_to? :specification_version then
51
+ s.specification_version = 4
52
+
53
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
54
+ s.add_runtime_dependency(%q<sauce>, [">= 0"])
55
+ s.add_runtime_dependency(%q<sauce-connect>, [">= 0"])
56
+ s.add_runtime_dependency(%q<audible>, [">= 0"])
57
+ s.add_runtime_dependency(%q<watir-webdriver>, [">= 0"])
58
+ s.add_runtime_dependency(%q<capybara>, [">= 0"])
59
+ s.add_runtime_dependency(%q<capybara-webkit>, ["= 0.14.2"])
60
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
61
+ s.add_development_dependency(%q<jeweler>, ["~> 1.8.7"])
62
+ else
63
+ s.add_dependency(%q<sauce>, [">= 0"])
64
+ s.add_dependency(%q<sauce-connect>, [">= 0"])
65
+ s.add_dependency(%q<audible>, [">= 0"])
66
+ s.add_dependency(%q<watir-webdriver>, [">= 0"])
67
+ s.add_dependency(%q<capybara>, [">= 0"])
68
+ s.add_dependency(%q<capybara-webkit>, ["= 0.14.2"])
69
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
70
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
71
+ end
72
+ else
73
+ s.add_dependency(%q<sauce>, [">= 0"])
74
+ s.add_dependency(%q<sauce-connect>, [">= 0"])
75
+ s.add_dependency(%q<audible>, [">= 0"])
76
+ s.add_dependency(%q<watir-webdriver>, [">= 0"])
77
+ s.add_dependency(%q<capybara>, [">= 0"])
78
+ s.add_dependency(%q<capybara-webkit>, ["= 0.14.2"])
79
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
80
+ s.add_dependency(%q<jeweler>, ["~> 1.8.7"])
81
+ end
82
+ end
83
+
@@ -0,0 +1,8 @@
1
+ require "spec_helper"
2
+ require "integration/shared_examples/window_licker"
3
+
4
+ describe "The capybara-webkit implementation" do
5
+ let(:licker) { RLicker::Lickers::CapybaraWebkitLicker.new }
6
+ it_behaves_like "a window licker"
7
+ it_behaves_like "a window licker that can locate elements"
8
+ end
@@ -0,0 +1,26 @@
1
+ require "spec_helper"
2
+ require "integration/shared_examples/window_licker"
3
+
4
+ describe "The chrome implementation" do
5
+ include Given
6
+ let(:licker) { RLicker::Lickers::ChromeLicker.new }
7
+ it_behaves_like "a window licker"
8
+ it_behaves_like "a window licker that can locate elements"
9
+
10
+ it "when there are two elements with the same tag name and id it only returns one of them" do
11
+ earl = File.expand_path File.join(".", "spec/integration/samples/licker_test.html")
12
+
13
+ given earl => <<-HTML
14
+ <div id="a">An element with id "a"</div>
15
+ <div id="a">Another element with id "a"</div>
16
+ HTML
17
+
18
+ licker.goto earl
19
+
20
+ licker.find_by_id("a").text.must === "An element with id \"a\""
21
+ end
22
+
23
+ after do
24
+ licker.close
25
+ end
26
+ end
@@ -0,0 +1,7 @@
1
+ module Given
2
+ def given(name_and_value)
3
+ File.open(File.expand_path(name_and_value.keys.first),"w+") do |file|
4
+ file.puts name_and_value[name_and_value.keys.first]
5
+ end
6
+ end
7
+ end
File without changes
@@ -0,0 +1,24 @@
1
+ require "spec_helper"
2
+ require "integration/shared_examples/window_licker"
3
+
4
+ describe "The saucelabs implementation" do
5
+ let(:licker) { RLicker::Lickers::SauceLabsLicker.new }
6
+
7
+ it_behaves_like "a window licker that can execute javascript"
8
+
9
+ it "handles multiples with the same id by returning the first" do
10
+ licker.goto "https://login.xero.com"
11
+ licker.find_by_id("email").must_not be_an Array
12
+ licker.find_by_id("email").must_not be_nil
13
+ end
14
+
15
+ it "can find elements by other attributes like class for example" do
16
+ licker.goto "https://login.xero.com/"
17
+ licker.find(:href => "http://www.xero.com/about/").must_not be_nil
18
+ end
19
+
20
+ it "returns things that are clickable" do
21
+ licker.goto "https://login.xero.com/"
22
+ licker.find(:href => "http://www.xero.com/about/").must respond_to :click
23
+ end
24
+ end
@@ -0,0 +1,90 @@
1
+ require "spec_helper"
2
+ require "integration/given"
3
+
4
+ include RLicker
5
+
6
+ shared_examples_for "a window licker that can execute javascript" do
7
+ it "can EXECUTE javascript with a return statement" do
8
+ earl = "https://www.google.com/"
9
+
10
+ licker.goto earl
11
+
12
+ result = licker.execute_script "return document.title"
13
+
14
+ result.must match /Google/
15
+ end
16
+
17
+ it "can EVALUATE javascript" do
18
+ earl = "https://www.google.com/"
19
+
20
+ licker.goto earl
21
+
22
+ result = licker.evaluate_script "document.title"
23
+
24
+ result.must match /Google/
25
+ end
26
+ end
27
+
28
+ shared_examples_for "a window licker that can locate elements" do
29
+ include Given
30
+
31
+ let(:earl) do
32
+ File.expand_path File.join(".", "spec/integration/samples/licker_test.html")
33
+ end
34
+
35
+ it "can locate an element by id" do
36
+ given earl => <<-HTML
37
+ <div id="phils-bike-seat"></div>
38
+ HTML
39
+
40
+ licker.goto earl
41
+ licker.find_by_id("phils-bike-seat").must_not be_nil
42
+ end
43
+
44
+ it "returns things that are clickable" do
45
+ given earl => <<-HTML
46
+ <button id="phils-bike-seat"></button>
47
+ HTML
48
+
49
+ licker.goto earl
50
+ licker.find_by_id("phils-bike-seat").click
51
+ end
52
+
53
+ it "can locate elements by other attributes like href for example" do
54
+ given earl => <<-HTML
55
+ <div id="one">
56
+ <a href="http://example.com"></a>
57
+ </div>
58
+ HTML
59
+
60
+ licker.goto earl
61
+ licker.find(:href => "http://example.com").must_not be_nil
62
+ end
63
+
64
+ it "can locate my regex matching attribute values"
65
+ it "returns nil when attribute does not exist"
66
+
67
+ it "when multiple elements have the same id it returns the first one" do
68
+ given earl => <<-HTML
69
+ <div id="phils-bike-seat"></div>
70
+ <span id="phils-bike-seat"></span>
71
+ HTML
72
+
73
+ licker.goto earl
74
+ licker.find_by_id("phils-bike-seat").must_not be_an Array
75
+ end
76
+ end
77
+
78
+ shared_examples_for "a window licker" do
79
+ include Given
80
+
81
+ let(:earl) do
82
+ File.expand_path File.join(".", "spec/integration/samples/licker_test.html")
83
+ end
84
+
85
+ it "can open an earl" do
86
+ given earl => ""
87
+
88
+ lambda{licker.goto "spec/integration/samples/licker_test.html"}.must_not raise_error
89
+ end
90
+ end
@@ -0,0 +1,8 @@
1
+ require "rspec"
2
+
3
+ Object.class_eval do
4
+ alias :must :should
5
+ alias :must_not :should_not
6
+ end
7
+
8
+ require "rlicker"
metadata ADDED
@@ -0,0 +1,185 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rlicker
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Ben Biddington
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-01-28 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sauce
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ! '>='
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ! '>='
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sauce-connect
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: audible
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ! '>='
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: watir-webdriver
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
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: capybara
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ! '>='
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
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: capybara-webkit
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: !binary |-
90
+ MC4xNC4y
91
+ type: :runtime
92
+ prerelease: false
93
+ version_requirements: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - '='
96
+ - !ruby/object:Gem::Version
97
+ version: !binary |-
98
+ MC4xNC4y
99
+ - !ruby/object:Gem::Dependency
100
+ name: bundler
101
+ requirement: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ~>
104
+ - !ruby/object:Gem::Version
105
+ version: !binary |-
106
+ MS4w
107
+ type: :development
108
+ prerelease: false
109
+ version_requirements: !ruby/object:Gem::Requirement
110
+ requirements:
111
+ - - ~>
112
+ - !ruby/object:Gem::Version
113
+ version: !binary |-
114
+ MS4w
115
+ - !ruby/object:Gem::Dependency
116
+ name: jeweler
117
+ requirement: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ~>
120
+ - !ruby/object:Gem::Version
121
+ version: !binary |-
122
+ MS44Ljc=
123
+ type: :development
124
+ prerelease: false
125
+ version_requirements: !ruby/object:Gem::Requirement
126
+ requirements:
127
+ - - ~>
128
+ - !ruby/object:Gem::Version
129
+ version: !binary |-
130
+ MS44Ljc=
131
+ description: ''
132
+ email: ben.biddington@gmail.com
133
+ executables: []
134
+ extensions: []
135
+ extra_rdoc_files:
136
+ - LICENSE.txt
137
+ - README.md
138
+ - README.rdoc
139
+ files:
140
+ - .document
141
+ - .travis.yml
142
+ - Gemfile
143
+ - Gemfile.lock
144
+ - LICENSE.txt
145
+ - README.md
146
+ - README.rdoc
147
+ - Rakefile
148
+ - VERSION
149
+ - lib/rlicker.rb
150
+ - lib/rlicker/capybara_webkit_licker.rb
151
+ - lib/rlicker/chrome_licker.rb
152
+ - lib/rlicker/sauce_labs_licker.rb
153
+ - rlicker.gemspec
154
+ - spec/integration/capybara_webkit_spec.rb
155
+ - spec/integration/chrome_licker_spec.rb
156
+ - spec/integration/given.rb
157
+ - spec/integration/samples/.gitkeep
158
+ - spec/integration/sauce_labs_spec.rb
159
+ - spec/integration/shared_examples/window_licker.rb
160
+ - spec/spec_helper.rb
161
+ homepage: http://github.com/ben-biddington/rlicker
162
+ licenses:
163
+ - MIT
164
+ metadata: {}
165
+ post_install_message:
166
+ rdoc_options: []
167
+ require_paths:
168
+ - lib
169
+ required_ruby_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ required_rubygems_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ! '>='
177
+ - !ruby/object:Gem::Version
178
+ version: '0'
179
+ requirements: []
180
+ rubyforge_project:
181
+ rubygems_version: 2.4.3
182
+ signing_key:
183
+ specification_version: 4
184
+ summary: ''
185
+ test_files: []