page_magic 2.0.0.alpha1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -2
- data/.zsh_config +5 -5
- data/Dockerfile +2 -1
- data/Gemfile +2 -1
- data/Gemfile.lock +9 -5
- data/Makefile +7 -3
- data/README.md +16 -4
- data/VERSION +1 -1
- data/lib/active_support/core_ext/object/to_query.rb +6 -6
- data/lib/page_magic.rb +15 -16
- data/lib/page_magic/class_methods.rb +1 -1
- data/lib/page_magic/comparator.rb +37 -0
- data/lib/page_magic/comparator/fuzzy.rb +23 -0
- data/lib/page_magic/comparator/literal.rb +22 -0
- data/lib/page_magic/comparator/null.rb +26 -0
- data/lib/page_magic/comparator/parameter_map.rb +52 -0
- data/lib/page_magic/drivers.rb +2 -2
- data/lib/page_magic/element.rb +19 -8
- data/lib/page_magic/element/locators.rb +4 -4
- data/lib/page_magic/element/not_found.rb +38 -0
- data/lib/page_magic/element/query.rb +19 -27
- data/lib/page_magic/element/query/multiple_results.rb +21 -0
- data/lib/page_magic/element/query/prefetched_result.rb +26 -0
- data/lib/page_magic/element/query/single_result.rb +20 -0
- data/lib/page_magic/element/selector.rb +38 -16
- data/lib/page_magic/element/selector/methods.rb +18 -0
- data/lib/page_magic/element/selector/model.rb +21 -0
- data/lib/page_magic/element_context.rb +5 -21
- data/lib/page_magic/element_definition_builder.rb +17 -24
- data/lib/page_magic/elements.rb +62 -102
- data/lib/page_magic/elements/config.rb +103 -0
- data/lib/page_magic/elements/inheritance_hooks.rb +15 -0
- data/lib/page_magic/elements/types.rb +25 -0
- data/lib/page_magic/exceptions.rb +3 -0
- data/lib/page_magic/instance_methods.rb +2 -2
- data/lib/page_magic/mapping.rb +79 -0
- data/lib/page_magic/session.rb +10 -32
- data/lib/page_magic/session_methods.rb +1 -1
- data/lib/page_magic/transitions.rb +49 -0
- data/lib/page_magic/utils/string.rb +4 -0
- data/lib/page_magic/utils/url.rb +20 -0
- data/lib/page_magic/watcher.rb +10 -17
- data/lib/page_magic/watchers.rb +28 -15
- data/spec/page_magic/class_methods_spec.rb +64 -37
- data/spec/page_magic/comparator/fuzzy_spec.rb +44 -0
- data/spec/page_magic/comparator/literal_spec.rb +41 -0
- data/spec/page_magic/comparator/null_spec.rb +35 -0
- data/spec/page_magic/comparator/parameter_map_spec.rb +75 -0
- data/spec/page_magic/driver_spec.rb +25 -29
- data/spec/page_magic/drivers/poltergeist_spec.rb +4 -7
- data/spec/page_magic/drivers/rack_test_spec.rb +4 -9
- data/spec/page_magic/drivers/selenium_spec.rb +9 -12
- data/spec/page_magic/drivers_spec.rb +36 -29
- data/spec/page_magic/element/locators_spec.rb +26 -25
- data/spec/page_magic/element/not_found_spec.rb +24 -0
- data/spec/page_magic/element/query/multiple_results_spec.rb +14 -0
- data/spec/page_magic/element/query/single_result_spec.rb +21 -0
- data/spec/page_magic/element/query_spec.rb +26 -47
- data/spec/page_magic/element/selector_spec.rb +118 -110
- data/spec/page_magic/element_context_spec.rb +46 -88
- data/spec/page_magic/element_definition_builder_spec.rb +12 -71
- data/spec/page_magic/element_spec.rb +256 -0
- data/spec/page_magic/elements/config_spec.rb +200 -0
- data/spec/page_magic/elements_spec.rb +87 -138
- data/spec/page_magic/instance_methods_spec.rb +63 -63
- data/spec/page_magic/mapping_spec.rb +181 -0
- data/spec/page_magic/session_methods_spec.rb +27 -25
- data/spec/page_magic/session_spec.rb +109 -198
- data/spec/page_magic/transitions_spec.rb +43 -0
- data/spec/page_magic/utils/string_spec.rb +20 -27
- data/spec/page_magic/utils/url_spec.rb +9 -0
- data/spec/page_magic/wait_methods_spec.rb +14 -22
- data/spec/page_magic/watcher_spec.rb +22 -0
- data/spec/page_magic/watchers_spec.rb +56 -62
- data/spec/page_magic_spec.rb +27 -24
- data/spec/spec_helper.rb +7 -3
- data/spec/support/shared_examples.rb +15 -17
- metadata +48 -15
- data/lib/page_magic/element/query_builder.rb +0 -61
- data/lib/page_magic/element/selector_methods.rb +0 -16
- data/lib/page_magic/matcher.rb +0 -130
- data/spec/element_spec.rb +0 -251
- data/spec/page_magic/element/query_builder_spec.rb +0 -110
- data/spec/page_magic/matcher_spec.rb +0 -338
- data/spec/support/shared_contexts/files_context.rb +0 -9
- data/spec/support/shared_contexts/nested_elements_html_context.rb +0 -18
- data/spec/support/shared_contexts/rack_application_context.rb +0 -11
- data/spec/support/shared_contexts/webapp_fixture_context.rb +0 -41
- data/spec/watcher_spec.rb +0 -64
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
shared_context :nested_elements_html do
|
4
|
-
require 'sinatra/base'
|
5
|
-
|
6
|
-
let(:nested_elements_html) do
|
7
|
-
<<-HTML
|
8
|
-
<div id="parent">
|
9
|
-
<div id="child">
|
10
|
-
</div>
|
11
|
-
</div>
|
12
|
-
HTML
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:nested_elements_node) do
|
16
|
-
Capybara::Node::Simple.new(nested_elements_html)
|
17
|
-
end
|
18
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
shared_context :webapp_fixture do
|
4
|
-
require 'sinatra/base'
|
5
|
-
|
6
|
-
let(:rack_app) do
|
7
|
-
Class.new(Sinatra::Base) do
|
8
|
-
get '/page1' do
|
9
|
-
"<html><head><title>page1</title></head><body><a href='/page2'>next page</a></body></html>"
|
10
|
-
end
|
11
|
-
|
12
|
-
get '/page2' do
|
13
|
-
'page 2 content'
|
14
|
-
end
|
15
|
-
|
16
|
-
get '/elements' do
|
17
|
-
<<-ELEMENTS
|
18
|
-
<a href='#'>a link</a>
|
19
|
-
|
20
|
-
|
21
|
-
<div id='form' class="form">
|
22
|
-
<a id='form_link' href='/page2'>link in a form</a>
|
23
|
-
<label>enter text
|
24
|
-
<input id='field_id' name='field_name' class='input_class' type='text' value='filled in'/>
|
25
|
-
</label>
|
26
|
-
<button id='form_button' type='submit' value='a button'/>
|
27
|
-
</form>
|
28
|
-
|
29
|
-
ELEMENTS
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
before :each do
|
35
|
-
Capybara.app = rack_app
|
36
|
-
end
|
37
|
-
|
38
|
-
after do
|
39
|
-
Capybara.reset!
|
40
|
-
end
|
41
|
-
end
|
data/spec/watcher_spec.rb
DELETED
@@ -1,64 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module PageMagic
|
4
|
-
describe Watcher do
|
5
|
-
describe '#initialize' do
|
6
|
-
context 'check has not been called yet' do
|
7
|
-
subject do
|
8
|
-
described_class.new(:custom_watcher)
|
9
|
-
end
|
10
|
-
it 'it sets last to nil' do
|
11
|
-
expect(subject.last).to be_nil
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#check' do
|
17
|
-
context 'method supplied to constructor' do
|
18
|
-
subject do
|
19
|
-
described_class.new(:object_id)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'assigns last to be the result of calling the method' do
|
23
|
-
subject.check(self)
|
24
|
-
expect(subject.last).to eq(object_id)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
context 'name and attribute supplied to constructor' do
|
28
|
-
subject do
|
29
|
-
described_class.new(:my_button, :text)
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'assigns last to the value of attribute definined in the constructor' do
|
33
|
-
browser_element = double(text: :hello)
|
34
|
-
page_element = double(my_button: browser_element)
|
35
|
-
expect(subject.check(page_element).last).to eq(:hello)
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
context 'block supplied to constructor' do
|
40
|
-
def method_on_self(value = nil)
|
41
|
-
return @value unless value
|
42
|
-
|
43
|
-
@value = value
|
44
|
-
end
|
45
|
-
|
46
|
-
subject do
|
47
|
-
described_class.new(:custom_watcher) do
|
48
|
-
method_on_self(:called)
|
49
|
-
:result
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
it 'is called on self' do
|
54
|
-
subject.check(self)
|
55
|
-
expect(method_on_self).to be(:called)
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'assigns last to the resut of the block' do
|
59
|
-
expect(subject.check(self).last).to eq(:result)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
64
|
-
end
|