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/spec/spec_helper.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'coveralls'
|
3
|
-
|
4
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
-
SimpleCov::Formatter::HTMLFormatter,
|
6
|
-
Coveralls::SimpleCov::Formatter
|
7
|
-
]
|
8
|
-
SimpleCov.start do
|
9
|
-
add_filter "/spec/"
|
10
|
-
add_filter "/vendor/"
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'watir-webdriver'
|
14
|
-
require 'watirsome'
|
15
|
-
|
16
|
-
Dir['spec/support/**/*.rb'].each do |file|
|
17
|
-
require file.sub(/spec\//, '')
|
18
|
-
end
|
19
|
-
|
20
|
-
RSpec.configure do |spec|
|
21
|
-
spec.alias_it_should_behave_like_to :it_defines, 'it defines'
|
22
|
-
|
23
|
-
shared_context :page do
|
24
|
-
let(:watir) { double('watir') }
|
25
|
-
let(:page) { Page.new(watir) }
|
26
|
-
end
|
27
|
-
|
28
|
-
shared_context :element do
|
29
|
-
let(:element) { double('element', visible?: true) }
|
30
|
-
end
|
31
|
-
end
|
data/spec/support/page.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
module IncludedRegion
|
2
|
-
def initialize_region
|
3
|
-
@included_initialized ||= 0
|
4
|
-
@included_initialized += 1
|
5
|
-
end
|
6
|
-
end # IncludedRegion
|
7
|
-
|
8
|
-
|
9
|
-
module ExtendedRegion
|
10
|
-
def initialize_region
|
11
|
-
@extended_initialized = 1
|
12
|
-
end
|
13
|
-
end # ExtendedRegion
|
14
|
-
|
15
|
-
|
16
|
-
module Helper
|
17
|
-
def initialize_region
|
18
|
-
@helper_initialized = 1
|
19
|
-
end
|
20
|
-
end # Helper
|
21
|
-
|
22
|
-
|
23
|
-
class Page
|
24
|
-
include Watirsome
|
25
|
-
include IncludedRegion
|
26
|
-
include Helper
|
27
|
-
|
28
|
-
def initialize_page
|
29
|
-
extend ExtendedRegion
|
30
|
-
@initialized = true
|
31
|
-
end
|
32
|
-
|
33
|
-
%w(div a text_field checkbox select_list).each do |tag|
|
34
|
-
send tag, :"#{tag}1"
|
35
|
-
send tag, :"#{tag}2", id: tag
|
36
|
-
send tag, :"#{tag}3", id: tag, class: /#{tag}/
|
37
|
-
send tag, :"#{tag}4", id: tag, class: tag, visible: true
|
38
|
-
send tag, :"#{tag}5", proc { @browser.send(tag, id: tag) }
|
39
|
-
send tag, :"#{tag}6", -> { @browser.send(tag, id: tag) }
|
40
|
-
# set/select accessor cannot have block arguments
|
41
|
-
case tag
|
42
|
-
when 'div', 'a'
|
43
|
-
send(tag, :"#{tag}7") { |id| @browser.send(tag, id: id) }
|
44
|
-
when 'text_field', 'select_list'
|
45
|
-
send(tag, :"#{tag}7") { @browser.send(tag, id: tag) }
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
# custom subtype locators
|
50
|
-
select_list :select_list8, id: 'select_list', selected: 'Test'
|
51
|
-
|
52
|
-
end # Page
|
@@ -1,53 +0,0 @@
|
|
1
|
-
shared_examples_for :click_accessor do |tags|
|
2
|
-
tags.each do |tag|
|
3
|
-
context tag do
|
4
|
-
def accessor(tag, index, *args)
|
5
|
-
page.send :"#{tag}#{index}", *args
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'clicks element with no locators' do
|
9
|
-
expect(watir).to receive(tag).with(no_args).and_return(element)
|
10
|
-
expect(element).to receive(:click).with(any_args)
|
11
|
-
accessor(tag, 1)
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'clicks element with single watir locator' do
|
15
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
16
|
-
expect(element).to receive(:click).with(any_args)
|
17
|
-
accessor(tag, 2)
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'clicks element with multiple watir locator' do
|
21
|
-
expect(watir).to receive(tag).with(id: tag, class: /#{tag}/).and_return(element)
|
22
|
-
expect(element).to receive(:click).with(any_args)
|
23
|
-
accessor(tag, 3)
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'clicks element with custom locator' do
|
27
|
-
element2 = double('element', visible?: false)
|
28
|
-
plural = Watirsome.pluralize(tag)
|
29
|
-
expect(watir).to receive(plural).with(id: tag, class: tag).and_return([element, element2])
|
30
|
-
expect(element).to receive(:click).with(any_args)
|
31
|
-
accessor(tag, 4)
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'clicks element with proc' do
|
35
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
36
|
-
expect(element).to receive(:click).with(any_args)
|
37
|
-
accessor(tag, 5)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'clicks element with lambda' do
|
41
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
42
|
-
expect(element).to receive(:click).with(any_args)
|
43
|
-
accessor(tag, 6)
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'clicks element with block and custom arguments' do
|
47
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
48
|
-
expect(element).to receive(:click).with(any_args)
|
49
|
-
accessor(tag, 7, tag)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
shared_examples_for :element_accessor do |tags|
|
2
|
-
tags.each do |tag|
|
3
|
-
context tag do
|
4
|
-
def accessor(tag, index, *args)
|
5
|
-
page.send :"#{tag}#{index}_#{tag}", *args
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'finds element with no locators' do
|
9
|
-
expect(watir).to receive(tag).with(no_args).and_return(element)
|
10
|
-
expect(accessor(tag, 1)).to eq(element)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'finds element with single watir locator' do
|
14
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
15
|
-
expect(accessor(tag, 2)).to eq(element)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'finds element with multiple watir locator' do
|
19
|
-
expect(watir).to receive(tag).with(id: tag, class: /#{tag}/).and_return(element)
|
20
|
-
expect(accessor(tag, 3)).to eq(element)
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'finds element with custom locator' do
|
24
|
-
element2 = double('element')
|
25
|
-
plural = Watirsome.pluralize(tag)
|
26
|
-
expect(watir).to receive(plural).with(id: tag, class: tag).and_return([element, element2])
|
27
|
-
expect(element).to receive(:visible?).and_return(true)
|
28
|
-
expect(element2).to receive(:visible?).and_return(false)
|
29
|
-
expect(accessor(tag, 4)).to eq(element)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'finds element with proc' do
|
33
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
34
|
-
expect(accessor(tag, 5)).to eq(element)
|
35
|
-
end
|
36
|
-
|
37
|
-
it 'finds element with lambda' do
|
38
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
39
|
-
expect(accessor(tag, 6)).to eq(element)
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'finds element with block and custom arguments' do
|
43
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
44
|
-
expect(accessor(tag, 7, tag)).to eq(element)
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
@@ -1,68 +0,0 @@
|
|
1
|
-
shared_examples_for :read_accessor do |tags|
|
2
|
-
tags.each do |tag|
|
3
|
-
context tag do
|
4
|
-
def accessor(tag, index, *args)
|
5
|
-
page.send :"#{tag}#{index}", *args
|
6
|
-
end
|
7
|
-
|
8
|
-
def read_expectation(tag)
|
9
|
-
case tag
|
10
|
-
when 'text_field'
|
11
|
-
expect(element).to receive(:value).and_return('text')
|
12
|
-
when 'select_list'
|
13
|
-
option1 = double('option1', selected?: true)
|
14
|
-
option2 = double('option2', selected?: false)
|
15
|
-
expect(element).to receive(:options).and_return([option1, option2])
|
16
|
-
expect(option1).to receive(:text).and_return('text')
|
17
|
-
expect(option2).not_to receive(:text)
|
18
|
-
else
|
19
|
-
expect(element).to receive(:text).and_return('text')
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'gets text from element with no locators' do
|
24
|
-
expect(watir).to receive(tag).with(no_args).and_return(element)
|
25
|
-
read_expectation(tag)
|
26
|
-
expect(accessor(tag, 1)).to eq('text')
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'gets text from element with single watir locator' do
|
30
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
31
|
-
read_expectation(tag)
|
32
|
-
expect(accessor(tag, 2)).to eq('text')
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'gets text from element with multiple watir locator' do
|
36
|
-
expect(watir).to receive(tag).with(id: tag, class: /#{tag}/).and_return(element)
|
37
|
-
read_expectation(tag)
|
38
|
-
expect(accessor(tag, 3)).to eq('text')
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'gets text from element with custom locator' do
|
42
|
-
element2 = double('element', visible?: false)
|
43
|
-
plural = Watirsome.pluralize(tag)
|
44
|
-
expect(watir).to receive(plural).with(id: tag, class: tag).and_return([element, element2])
|
45
|
-
read_expectation(tag)
|
46
|
-
expect(accessor(tag, 4)).to eq('text')
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'gets text from element with proc' do
|
50
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
51
|
-
read_expectation(tag)
|
52
|
-
expect(accessor(tag, 5)).to eq('text')
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'gets text from element with lambda' do
|
56
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
57
|
-
read_expectation(tag)
|
58
|
-
expect(accessor(tag, 6)).to eq('text')
|
59
|
-
end
|
60
|
-
|
61
|
-
it 'gets text from element with block and custom arguments' do
|
62
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
63
|
-
read_expectation(tag)
|
64
|
-
expect(accessor(tag, 7, tag)).to eq('text')
|
65
|
-
end
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
@@ -1,47 +0,0 @@
|
|
1
|
-
shared_examples_for :select_accessor do |tags|
|
2
|
-
tags.each do |tag|
|
3
|
-
context tag do
|
4
|
-
def accessor(tag, index, *args)
|
5
|
-
page.send :"#{tag}#{index}=", *args
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'selects option for element with no locators' do
|
9
|
-
expect(watir).to receive(tag).with(no_args).and_return(element)
|
10
|
-
expect(element).to receive(:select).with('value')
|
11
|
-
accessor(tag, 1, 'value')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'selects option for element with single watir locator' do
|
15
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
16
|
-
expect(element).to receive(:select).with('value')
|
17
|
-
accessor(tag, 2, 'value')
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'selects option for element with multiple watir locator' do
|
21
|
-
expect(watir).to receive(tag).with(id: tag, class: /#{tag}/).and_return(element)
|
22
|
-
expect(element).to receive(:select).with('value')
|
23
|
-
accessor(tag, 3, 'value')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'selects option for element with custom locator' do
|
27
|
-
element2 = double('element', visible?: false)
|
28
|
-
plural = Watirsome.pluralize(tag)
|
29
|
-
expect(watir).to receive(plural).with(id: tag, class: tag).and_return([element, element2])
|
30
|
-
expect(element).to receive(:select).with('value')
|
31
|
-
accessor(tag, 4, 'value')
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'selects option for element with proc' do
|
35
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
36
|
-
expect(element).to receive(:select).with('value')
|
37
|
-
accessor(tag, 5, 'value')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'selects option for element with lambda' do
|
41
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
42
|
-
expect(element).to receive(:select).with('value')
|
43
|
-
accessor(tag, 6, 'value')
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|
@@ -1,54 +0,0 @@
|
|
1
|
-
shared_examples_for :set_accessor do |tags|
|
2
|
-
tags.each do |tag|
|
3
|
-
context tag do
|
4
|
-
def accessor(tag, index, *args)
|
5
|
-
page.send :"#{tag}#{index}=", *args
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'sets value on element with no locators' do
|
9
|
-
expect(watir).to receive(tag).with(no_args).and_return(element)
|
10
|
-
expect(element).to receive(:set).with('value')
|
11
|
-
accessor(tag, 1, 'value')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'sets value on element with single watir locator' do
|
15
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
16
|
-
expect(element).to receive(:set).with('value')
|
17
|
-
accessor(tag, 2, 'value')
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'sets value on element with multiple watir locator' do
|
21
|
-
expect(watir).to receive(tag).with(id: tag, class: /#{tag}/).and_return(element)
|
22
|
-
expect(element).to receive(:set).with('value')
|
23
|
-
accessor(tag, 3, 'value')
|
24
|
-
end
|
25
|
-
|
26
|
-
it 'sets value on element with custom locator' do
|
27
|
-
element2 = double('element', visible?: false)
|
28
|
-
plural = Watirsome.pluralize(tag)
|
29
|
-
expect(watir).to receive(plural).with(id: tag, class: tag).and_return([element, element2])
|
30
|
-
expect(element).to receive(:set).with('value')
|
31
|
-
accessor(tag, 4, 'value')
|
32
|
-
end
|
33
|
-
|
34
|
-
it 'sets value on element with proc' do
|
35
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
36
|
-
expect(element).to receive(:set).with('value')
|
37
|
-
accessor(tag, 5, 'value')
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'sets value on element with lambda' do
|
41
|
-
expect(watir).to receive(tag).with(id: tag).and_return(element)
|
42
|
-
expect(element).to receive(:set).with('value')
|
43
|
-
accessor(tag, 6, 'value')
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'sends keys if element cannot be set' do
|
47
|
-
expect(watir).to receive(tag).with(no_args).and_return(element)
|
48
|
-
allow(element).to receive(:respond_to?).with(:set).and_return(false)
|
49
|
-
expect(element).to receive(:send_keys).with('value')
|
50
|
-
accessor(tag, 1, 'value')
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
end
|