watir_drops 0.1.0

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f3e24edb52bd7fb125ae9ac1ac76726512fe19bb
4
+ data.tar.gz: 4d32c7c25b00e5f24ae2a39072e389c34374abfa
5
+ SHA512:
6
+ metadata.gz: fccd40947902f0ad2727d67e294b63c824c13edd256ffb4fedeb35731ed551e0d11d8b74d49ef36e5429347aae994d68d2d2016e0b8029aca3dab434e346ae0f
7
+ data.tar.gz: a20448e6949ca2c964218966e57c5143763432b38794341789f552e70026be2cd3f61cb6d2a29f83699d1e29d2fd7cb22ba9cff9c99d9fb92342c764524d62f8
data/.gitignore ADDED
@@ -0,0 +1,10 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
10
+ *.idea
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in watir_drops.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Titus Fortner
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,20 @@
1
+ # WatirDrops
2
+
3
+ This gem leverages the Watir test framework to allow for easy modeling of specific web application information,
4
+ allowing it to be decoupled from the tests.
5
+ The intention is to provide a solution that is easy to use and maintain, while still providing power and flexibility.
6
+
7
+ ## Usage
8
+
9
+ Create a class that represents a unique page or modal on your site and have it inherit WatirDrops.
10
+
11
+
12
+ ## Contributing
13
+
14
+ Bug reports and pull requests are welcome on [GitHub](https://github.com/titusfortner/watir_drops)
15
+
16
+
17
+ ## License
18
+
19
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
20
+
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,7 @@
1
+ require 'watir-webdriver'
2
+
3
+ require "watir_drops/version"
4
+ require "watir_drops/session"
5
+ require "watir_drops/page_object"
6
+
7
+ include WatirDrops
@@ -0,0 +1,57 @@
1
+ module WatirDrops
2
+ class PageObject
3
+
4
+ class << self
5
+ def page_url url
6
+ define_method("goto") do
7
+ browser.goto url
8
+ end
9
+ end
10
+
11
+ def elements
12
+ @elements ||= []
13
+ end
14
+
15
+ def element(name, &block)
16
+ define_method(name) do |*args|
17
+ self.instance_exec(*args, &block)
18
+ end
19
+
20
+ define_method("#{name}=") do |val|
21
+ watir_element = self.instance_exec &block
22
+ case watir_element
23
+ when Watir::Radio
24
+ watir_element.set val
25
+ when Watir::CheckBox
26
+ val ? watir_element.set : watir_element.clear
27
+ when Watir::Select
28
+ watir_element.select val
29
+ when Watir::Button
30
+ watir_element.click
31
+ else
32
+ watir_element.value = val
33
+ end
34
+ end
35
+
36
+ elements << {name.to_sym => block}
37
+ end
38
+
39
+ end
40
+
41
+ attr_reader :browser
42
+
43
+ def initialize(browser=nil)
44
+ @browser = browser || WatirDrops::Session.instance.browser
45
+ end
46
+
47
+ def visit
48
+ goto if self.respond_to? :goto
49
+ self
50
+ end
51
+
52
+ def title
53
+ browser.title
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,17 @@
1
+ require 'singleton'
2
+
3
+ module WatirDrops
4
+ class Session
5
+ include Singleton
6
+
7
+ def browser
8
+ @browser ||= Watir::Browser.new :chrome
9
+ end
10
+
11
+ def quit
12
+ @browser.quit
13
+ @browser = nil
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module WatirDrops
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'watir_drops/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "watir_drops"
8
+ spec.version = WatirDrops::VERSION
9
+ spec.authors = ["Titus Fortner"]
10
+ spec.email = ["titusfortner@gmail.com"]
11
+
12
+ spec.summary = %q{Page Object Framework for use with Watir}
13
+ spec.description = %q{This gem leverages the Watir test framework to allow for easy modeling of specific web
14
+ application information, allowing it to be decoupled from the tests}
15
+ spec.homepage = "https://github.com/titusfortner/watir_drops"
16
+ spec.license = "MIT"
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = "exe"
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ["lib"]
22
+
23
+ spec.add_development_dependency "bundler", "~> 1.10"
24
+ spec.add_development_dependency "rake", "~> 10.0"
25
+ spec.add_development_dependency "rspec", "~> 0"
26
+ spec.add_development_dependency "watir-webdriver", "~> 0.8.0"
27
+ end
metadata ADDED
@@ -0,0 +1,113 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: watir_drops
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Titus Fortner
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.10'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.10'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
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.8.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.8.0
69
+ description: |-
70
+ This gem leverages the Watir test framework to allow for easy modeling of specific web
71
+ application information, allowing it to be decoupled from the tests
72
+ email:
73
+ - titusfortner@gmail.com
74
+ executables: []
75
+ extensions: []
76
+ extra_rdoc_files: []
77
+ files:
78
+ - ".gitignore"
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - lib/watir_drops.rb
84
+ - lib/watir_drops/page_object.rb
85
+ - lib/watir_drops/session.rb
86
+ - lib/watir_drops/version.rb
87
+ - watir_drops.gemspec
88
+ homepage: https://github.com/titusfortner/watir_drops
89
+ licenses:
90
+ - MIT
91
+ metadata: {}
92
+ post_install_message:
93
+ rdoc_options: []
94
+ require_paths:
95
+ - lib
96
+ required_ruby_version: !ruby/object:Gem::Requirement
97
+ requirements:
98
+ - - ">="
99
+ - !ruby/object:Gem::Version
100
+ version: '0'
101
+ required_rubygems_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ requirements: []
107
+ rubyforge_project:
108
+ rubygems_version: 2.4.8
109
+ signing_key:
110
+ specification_version: 4
111
+ summary: Page Object Framework for use with Watir
112
+ test_files: []
113
+ has_rdoc: