watirsome 0.1.6 → 0.1.7
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 +4 -4
- data/.rubocop.yml +19 -0
- data/.travis.yml +6 -3
- data/CHANGELOG.md +5 -0
- data/LICENSE.md +1 -1
- data/README.md +3 -3
- data/Rakefile +7 -5
- data/doctest_helper.rb +16 -0
- data/lib/watirsome.rb +89 -49
- data/lib/watirsome/accessors.rb +22 -45
- data/lib/watirsome/errors.rb +1 -5
- data/lib/watirsome/initializers.rb +43 -15
- data/lib/watirsome/version.rb +1 -1
- data/support/doctest.html +16 -0
- data/watirsome.gemspec +4 -7
- metadata +12 -59
- data/.coveralls.yml +0 -1
- data/spec/lib/watirsome/accessors_spec.rb +0 -20
- data/spec/lib/watirsome/errors_spec.rb +0 -5
- data/spec/lib/watirsome/initializers_spec.rb +0 -38
- data/spec/lib/watirsome_spec.rb +0 -109
- data/spec/spec_helper.rb +0 -31
- data/spec/support/page.rb +0 -52
- data/spec/support/shared_examples/click_accessor.rb +0 -53
- data/spec/support/shared_examples/element_accessor.rb +0 -48
- data/spec/support/shared_examples/read_accessor.rb +0 -68
- data/spec/support/shared_examples/select_accessor.rb +0 -47
- data/spec/support/shared_examples/set_accessor.rb +0 -54
data/lib/watirsome/errors.rb
CHANGED
@@ -1,11 +1,43 @@
|
|
1
1
|
module Watirsome
|
2
|
+
#
|
3
|
+
# Initializes page class.
|
4
|
+
# Allows to define "#initialize_page" which will be called as page constructor.
|
5
|
+
# After page is initialized, iterates through region and initialize each of them.
|
6
|
+
#
|
7
|
+
# @example Page Initializer
|
8
|
+
# class Page
|
9
|
+
# include Watirsome
|
10
|
+
#
|
11
|
+
# attr_accessor :page_loaded
|
12
|
+
#
|
13
|
+
# def initialize_page
|
14
|
+
# self.page_loaded = true
|
15
|
+
# end
|
16
|
+
# end
|
17
|
+
#
|
18
|
+
# page = Page.new(browser)
|
19
|
+
# page.page_loaded
|
20
|
+
# #=> true
|
21
|
+
#
|
22
|
+
# @example Region Initializer
|
23
|
+
# module HeaderRegion
|
24
|
+
# def initialize_region
|
25
|
+
# self.page_loaded = true
|
26
|
+
# end
|
27
|
+
# end
|
28
|
+
#
|
29
|
+
# class Page
|
30
|
+
# include Watirsome
|
31
|
+
# include HeaderRegion
|
32
|
+
#
|
33
|
+
# attr_accessor :page_loaded
|
34
|
+
# end
|
35
|
+
#
|
36
|
+
# page = Page.new(browser)
|
37
|
+
# page.page_loaded
|
38
|
+
# #=> true
|
39
|
+
#
|
2
40
|
module Initializers
|
3
|
-
|
4
|
-
#
|
5
|
-
# Initializes page class.
|
6
|
-
# Allows to define "#initialize_page" which will be called as page constructor.
|
7
|
-
# After page is initialized, iterates through region and initialize each of them.
|
8
|
-
#
|
9
41
|
def initialize(browser)
|
10
42
|
@browser = browser
|
11
43
|
initialize_page if respond_to?(:initialize_page)
|
@@ -16,9 +48,6 @@ module Watirsome
|
|
16
48
|
# Iterates through definitions of "#initialize_region", thus implementing
|
17
49
|
# polymorphic Ruby modules (i.e. page regions).
|
18
50
|
#
|
19
|
-
# Only works with modules matching "Watirsome.region_matcher" regexp.
|
20
|
-
# @see Watirsome.region_matcher
|
21
|
-
#
|
22
51
|
def initialize_regions
|
23
52
|
# regions cacher
|
24
53
|
@initialized_regions ||= []
|
@@ -28,13 +57,12 @@ module Watirsome
|
|
28
57
|
# initialize each module
|
29
58
|
modules.each do |m|
|
30
59
|
# check that constructor is defined and we haven't called it before
|
31
|
-
if
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
60
|
+
next if @initialized_regions.include?(m) || !m.instance_methods.include?(:initialize_region)
|
61
|
+
|
62
|
+
m.instance_method(:initialize_region).bind(self).call
|
63
|
+
# cache region
|
64
|
+
@initialized_regions << m
|
36
65
|
end
|
37
66
|
end
|
38
|
-
|
39
67
|
end # Initializers
|
40
68
|
end # Watirsome
|
data/lib/watirsome/version.rb
CHANGED
@@ -0,0 +1,16 @@
|
|
1
|
+
<html>
|
2
|
+
<body>
|
3
|
+
<div class="container">Container</div>
|
4
|
+
<a href="http://www.google.com">Open Google</a>
|
5
|
+
<div>
|
6
|
+
<input type="text" placeholder="Enter your name" />
|
7
|
+
<select name="Country">
|
8
|
+
<option value="USA">USA</option>
|
9
|
+
<option value="Russia">Russia</option>
|
10
|
+
</select>
|
11
|
+
<input type="checkbox" name="I Agree" />
|
12
|
+
<input type="radio" name="sex" value="Male">
|
13
|
+
<input type="radio" name="sex" value="Female">
|
14
|
+
</div>
|
15
|
+
</body>
|
16
|
+
</html>
|
data/watirsome.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
2
2
|
require 'watirsome/version'
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
@@ -13,14 +13,11 @@ Gem::Specification.new do |s|
|
|
13
13
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
15
15
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
-
s.
|
17
|
-
s.require_paths = %w(lib)
|
16
|
+
s.require_paths = %w[lib]
|
18
17
|
|
19
18
|
s.add_dependency 'watir-webdriver', '>= 0.6.9'
|
20
19
|
|
21
|
-
s.add_development_dependency '
|
20
|
+
s.add_development_dependency 'yard-doctest', '>= 0.1.5'
|
22
21
|
s.add_development_dependency 'rake'
|
23
|
-
s.add_development_dependency '
|
24
|
-
s.add_development_dependency 'simplecov'
|
25
|
-
s.add_development_dependency 'coveralls'
|
22
|
+
s.add_development_dependency 'rubocop'
|
26
23
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: watirsome
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alex Rodionov
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-07-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: watir-webdriver
|
@@ -25,19 +25,19 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.6.9
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
28
|
+
name: yard-doctest
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version:
|
33
|
+
version: 0.1.5
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version:
|
40
|
+
version: 0.1.5
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rake
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -53,35 +53,7 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
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: simplecov
|
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: coveralls
|
56
|
+
name: rubocop
|
85
57
|
requirement: !ruby/object:Gem::Requirement
|
86
58
|
requirements:
|
87
59
|
- - ">="
|
@@ -100,29 +72,20 @@ executables: []
|
|
100
72
|
extensions: []
|
101
73
|
extra_rdoc_files: []
|
102
74
|
files:
|
103
|
-
- ".
|
75
|
+
- ".rubocop.yml"
|
104
76
|
- ".travis.yml"
|
105
77
|
- CHANGELOG.md
|
106
78
|
- Gemfile
|
107
79
|
- LICENSE.md
|
108
80
|
- README.md
|
109
81
|
- Rakefile
|
82
|
+
- doctest_helper.rb
|
110
83
|
- lib/watirsome.rb
|
111
84
|
- lib/watirsome/accessors.rb
|
112
85
|
- lib/watirsome/errors.rb
|
113
86
|
- lib/watirsome/initializers.rb
|
114
87
|
- lib/watirsome/version.rb
|
115
|
-
-
|
116
|
-
- spec/lib/watirsome/errors_spec.rb
|
117
|
-
- spec/lib/watirsome/initializers_spec.rb
|
118
|
-
- spec/lib/watirsome_spec.rb
|
119
|
-
- spec/spec_helper.rb
|
120
|
-
- spec/support/page.rb
|
121
|
-
- spec/support/shared_examples/click_accessor.rb
|
122
|
-
- spec/support/shared_examples/element_accessor.rb
|
123
|
-
- spec/support/shared_examples/read_accessor.rb
|
124
|
-
- spec/support/shared_examples/select_accessor.rb
|
125
|
-
- spec/support/shared_examples/set_accessor.rb
|
88
|
+
- support/doctest.html
|
126
89
|
- watirsome.gemspec
|
127
90
|
homepage: http://github.com/p0deje/watirsome
|
128
91
|
licenses: []
|
@@ -143,19 +106,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
143
106
|
version: '0'
|
144
107
|
requirements: []
|
145
108
|
rubyforge_project:
|
146
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.4.5.1
|
147
110
|
signing_key:
|
148
111
|
specification_version: 4
|
149
112
|
summary: Awesome page objects with Watir
|
150
|
-
test_files:
|
151
|
-
|
152
|
-
- spec/lib/watirsome/errors_spec.rb
|
153
|
-
- spec/lib/watirsome/initializers_spec.rb
|
154
|
-
- spec/lib/watirsome_spec.rb
|
155
|
-
- spec/spec_helper.rb
|
156
|
-
- spec/support/page.rb
|
157
|
-
- spec/support/shared_examples/click_accessor.rb
|
158
|
-
- spec/support/shared_examples/element_accessor.rb
|
159
|
-
- spec/support/shared_examples/read_accessor.rb
|
160
|
-
- spec/support/shared_examples/select_accessor.rb
|
161
|
-
- spec/support/shared_examples/set_accessor.rb
|
113
|
+
test_files: []
|
114
|
+
has_rdoc:
|
data/.coveralls.yml
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
service_name: 'travis-ci'
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Watirsome::Accessors do
|
4
|
-
include_context :page
|
5
|
-
include_context :element
|
6
|
-
|
7
|
-
it_defines :element_accessor, %w(div a text_field select_list)
|
8
|
-
it_defines :read_accessor, %w(div text_field select_list)
|
9
|
-
it_defines :click_accessor, %w(a)
|
10
|
-
it_defines :set_accessor, %w(text_field checkbox)
|
11
|
-
it_defines :select_accessor, %w(select_list)
|
12
|
-
|
13
|
-
it 'supports subtype custom locators' do
|
14
|
-
element2 = double('element')
|
15
|
-
expect(watir).to receive(:select_lists).with(id: 'select_list').and_return([element, element2])
|
16
|
-
expect(element).to receive(:selected?).with('Test').and_return(true)
|
17
|
-
expect(element2).to receive(:selected?).with('Test').and_return(false)
|
18
|
-
expect(page.select_list8_select_list).to eq(element)
|
19
|
-
end
|
20
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Watirsome::Initializers do
|
4
|
-
include_context :page
|
5
|
-
|
6
|
-
describe '#initialze' do
|
7
|
-
it 'does not initalize page if there is no constructor defined' do
|
8
|
-
page = Page.dup
|
9
|
-
page.class_eval { remove_method :initialize_page }
|
10
|
-
expect(page).not_to receive(:initialize_page)
|
11
|
-
page.new(watir)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'initializes page if there is constructor defined' do
|
15
|
-
expect(page.instance_variable_get(:@initialized)).to eq(true)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'initalizes regions' do
|
19
|
-
expect_any_instance_of(Page).to receive(:initialize_regions)
|
20
|
-
Page.new(watir)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#initialize_regions' do
|
25
|
-
it 'initalizes included regions' do
|
26
|
-
expect(page.instance_variable_get(:@included_initialized)).to eq(1)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'initalizes extended regions' do
|
30
|
-
expect(page.instance_variable_get(:@extended_initialized)).to eq(1)
|
31
|
-
end
|
32
|
-
|
33
|
-
it 'caches initalized regions' do
|
34
|
-
page.initialize_regions
|
35
|
-
expect(page.instance_variable_get(:@included_initialized)).to eq(1)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/spec/lib/watirsome_spec.rb
DELETED
@@ -1,109 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Watirsome do
|
4
|
-
%w(readable clickable settable selectable).each do |method|
|
5
|
-
describe ".#{method}" do
|
6
|
-
it 'returns array of accessors' do
|
7
|
-
accessors = described_class.send(method)
|
8
|
-
expect(accessors).to be_an(Array)
|
9
|
-
accessors.each do |accessor|
|
10
|
-
expect(accessor).to be_a(Symbol)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'allows to add custom accessors' do
|
15
|
-
described_class.send(method) << :custom
|
16
|
-
expect(described_class.send(method)).to include(:custom)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
describe ".#{method}?" do
|
21
|
-
let(:tag) do
|
22
|
-
case method
|
23
|
-
when 'readable' then :div
|
24
|
-
when 'clickable' then :button
|
25
|
-
when 'settable' then :text_field
|
26
|
-
when 'selectable' then :select_list
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "returns true if element is #{method}" do
|
31
|
-
expect(described_class.send(:"#{method}?", tag)).to eq(true)
|
32
|
-
end
|
33
|
-
|
34
|
-
it "returns false if element is not #{method}" do
|
35
|
-
expect(described_class.send(:"#{method}?", :foo)).to eq(false)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe '.watir_methods' do
|
41
|
-
it 'returns array of watir container methods' do
|
42
|
-
described_class.watir_methods.each do |method|
|
43
|
-
expect(Watir::Container.instance_methods).to include(method)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '.watirsome?' do
|
49
|
-
it 'returns true if method is watir-contained' do
|
50
|
-
expect(described_class.watirsome?(:div)).to eq(true)
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'returns false if method is not watir-contained' do
|
54
|
-
expect(described_class.watirsome?(:foo)).to eq(false)
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
describe '.plural?' do
|
59
|
-
it 'returns true if watir-contained method is plural with "s" ending' do
|
60
|
-
expect(described_class.plural?(:divs)).to eq(true)
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'returns true if watir-contained method is plural with "es" ending' do
|
64
|
-
expect(described_class.plural?(:checkboxes)).to eq(true)
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'returns false if watir-contained method is singular' do
|
68
|
-
expect(described_class.plural?(:div)).to eq(false)
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'returns false if method is not watir-contained' do
|
72
|
-
expect(described_class.plural?(:foo)).to eq(false)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
describe '.pluralize' do
|
77
|
-
it 'pluralizes method name with "s"' do
|
78
|
-
expect(described_class.pluralize(:div)).to eq(:divs)
|
79
|
-
end
|
80
|
-
|
81
|
-
it 'pluralizes method name with "es"' do
|
82
|
-
expect(described_class.pluralize(:checkbox)).to eq(:checkboxes)
|
83
|
-
end
|
84
|
-
|
85
|
-
it 'raises error when cannot pluralizes method' do
|
86
|
-
expect { described_class.pluralize(:foo) }.to raise_error(Watirsome::Errors::CannotPluralizeError)
|
87
|
-
end
|
88
|
-
end
|
89
|
-
|
90
|
-
context 'when included' do
|
91
|
-
include_context :page
|
92
|
-
|
93
|
-
it 'adds accessor class methods' do
|
94
|
-
expect(page.class).to respond_to(:div)
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'does not add #extract_selector' do
|
98
|
-
expect(page.class).not_to respond_to(:extract_selector)
|
99
|
-
end
|
100
|
-
|
101
|
-
it 'adds accessor instance methods' do
|
102
|
-
expect(page.private_methods).to include(:grab_elements)
|
103
|
-
end
|
104
|
-
|
105
|
-
it 'adds regions initializer' do
|
106
|
-
expect(page).to respond_to(:initialize_regions)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|