ae_page_objects 0.5.2.mw2 → 0.5.2
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.
data/lib/ae_page_objects.rb
CHANGED
@@ -26,8 +26,6 @@ module AePageObjects
|
|
26
26
|
autoload :Window, 'ae_page_objects/window'
|
27
27
|
autoload :Node, 'ae_page_objects/node'
|
28
28
|
autoload :Document, 'ae_page_objects/document'
|
29
|
-
autoload :DocumentFinder, 'ae_page_objects/document_finder'
|
30
|
-
autoload :VariableDocument, 'ae_page_objects/variable_document'
|
31
29
|
autoload :Element, 'ae_page_objects/element'
|
32
30
|
autoload :ElementProxy, 'ae_page_objects/element_proxy'
|
33
31
|
|
@@ -2,18 +2,6 @@ module AePageObjects
|
|
2
2
|
class Document < Node
|
3
3
|
include Concerns::Visitable
|
4
4
|
|
5
|
-
class << self
|
6
|
-
def find(*args, &block)
|
7
|
-
DocumentFinder.new(self).find(*args, &block)
|
8
|
-
end
|
9
|
-
|
10
|
-
private
|
11
|
-
|
12
|
-
def site
|
13
|
-
@site ||= AePageObjects::Site.from(self)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
5
|
attr_reader :window
|
18
6
|
|
19
7
|
def initialize
|
@@ -26,5 +14,12 @@ module AePageObjects
|
|
26
14
|
def document
|
27
15
|
self
|
28
16
|
end
|
17
|
+
|
18
|
+
class << self
|
19
|
+
private
|
20
|
+
def site
|
21
|
+
@site ||= AePageObjects::Site.from(self)
|
22
|
+
end
|
23
|
+
end
|
29
24
|
end
|
30
|
-
end
|
25
|
+
end
|
@@ -1,19 +1,10 @@
|
|
1
1
|
module AePageObjects
|
2
|
-
class
|
3
|
-
|
4
|
-
class StalePageObject < Error
|
5
|
-
end
|
6
|
-
|
7
|
-
class LoadingFailed < Error
|
2
|
+
class StalePageObject < StandardError
|
8
3
|
end
|
9
4
|
|
10
|
-
class
|
5
|
+
class LoadingFailed < StandardError
|
11
6
|
end
|
12
7
|
|
13
|
-
class
|
8
|
+
class PathNotResolvable < StandardError
|
14
9
|
end
|
15
|
-
|
16
|
-
class CastError < Error; end
|
17
|
-
class InvalidCast < CastError; end
|
18
|
-
class IncorrectCast < CastError; end
|
19
10
|
end
|
metadata
CHANGED
@@ -1,49 +1,39 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae_page_objects
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 5
|
9
|
-
- 2
|
10
|
-
- mw
|
11
|
-
- 2
|
12
|
-
version: 0.5.2.mw2
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.5.2
|
5
|
+
prerelease:
|
13
6
|
platform: ruby
|
14
|
-
authors:
|
7
|
+
authors:
|
15
8
|
- Donnie Tognazzini
|
16
9
|
autorequire:
|
17
10
|
bindir: bin
|
18
11
|
cert_chain: []
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-10-29 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
23
15
|
name: capybara
|
24
|
-
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
25
17
|
none: false
|
26
|
-
requirements:
|
18
|
+
requirements:
|
27
19
|
- - ~>
|
28
|
-
- !ruby/object:Gem::Version
|
29
|
-
|
30
|
-
segments:
|
31
|
-
- 1
|
32
|
-
- 1
|
33
|
-
version: "1.1"
|
34
|
-
prerelease: false
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.1'
|
35
22
|
type: :runtime
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.1'
|
37
30
|
description: Capybara Page Objects pattern
|
38
|
-
email:
|
31
|
+
email:
|
39
32
|
- engineering@appfolio.com
|
40
33
|
executables: []
|
41
|
-
|
42
34
|
extensions: []
|
43
|
-
|
44
35
|
extra_rdoc_files: []
|
45
|
-
|
46
|
-
files:
|
36
|
+
files:
|
47
37
|
- lib/ae_page_objects.rb
|
48
38
|
- lib/ae_page_objects/concerns/load_ensuring.rb
|
49
39
|
- lib/ae_page_objects/concerns/staleable.rb
|
@@ -56,7 +46,6 @@ files:
|
|
56
46
|
- lib/ae_page_objects/core/universe.rb
|
57
47
|
- lib/ae_page_objects/core_ext/module.rb
|
58
48
|
- lib/ae_page_objects/document.rb
|
59
|
-
- lib/ae_page_objects/document_finder.rb
|
60
49
|
- lib/ae_page_objects/element.rb
|
61
50
|
- lib/ae_page_objects/element_proxy.rb
|
62
51
|
- lib/ae_page_objects/elements/checkbox.rb
|
@@ -69,41 +58,34 @@ files:
|
|
69
58
|
- lib/ae_page_objects/util/inflector.rb
|
70
59
|
- lib/ae_page_objects/util/internal_helpers.rb
|
71
60
|
- lib/ae_page_objects/util/singleton.rb
|
72
|
-
- lib/ae_page_objects/variable_document.rb
|
73
61
|
- lib/ae_page_objects/version.rb
|
74
62
|
- lib/ae_page_objects/window.rb
|
75
63
|
homepage: http://github.com/appfolio/ae_page_objects
|
76
|
-
licenses:
|
64
|
+
licenses:
|
77
65
|
- MIT
|
78
66
|
post_install_message:
|
79
67
|
rdoc_options: []
|
80
|
-
|
81
|
-
require_paths:
|
68
|
+
require_paths:
|
82
69
|
- lib
|
83
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
84
71
|
none: false
|
85
|
-
requirements:
|
86
|
-
- -
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
|
89
|
-
segments:
|
72
|
+
requirements:
|
73
|
+
- - ! '>='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
segments:
|
90
77
|
- 0
|
91
|
-
|
92
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
hash: 947206196524353569
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
80
|
none: false
|
94
|
-
requirements:
|
95
|
-
- -
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
|
98
|
-
segments:
|
99
|
-
- 0
|
100
|
-
version: "0"
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
101
85
|
requirements: []
|
102
|
-
|
103
86
|
rubyforge_project:
|
104
87
|
rubygems_version: 1.8.25
|
105
88
|
signing_key:
|
106
89
|
specification_version: 3
|
107
90
|
summary: Capybara Page Objects pattern
|
108
91
|
test_files: []
|
109
|
-
|
@@ -1,77 +0,0 @@
|
|
1
|
-
module AePageObjects
|
2
|
-
class DocumentFinder
|
3
|
-
|
4
|
-
def initialize(document_class)
|
5
|
-
@document_class = document_class
|
6
|
-
end
|
7
|
-
|
8
|
-
class Conditions
|
9
|
-
def initialize(conditions, block_condition)
|
10
|
-
@conditions = conditions || {}
|
11
|
-
@conditions[:block] = block_condition if block_condition
|
12
|
-
end
|
13
|
-
|
14
|
-
def match?(page)
|
15
|
-
@conditions.each do |type, value|
|
16
|
-
case type
|
17
|
-
when :title then
|
18
|
-
return false unless browser.title.include?(value)
|
19
|
-
when :url then
|
20
|
-
return false unless page.current_url.include?(value)
|
21
|
-
when :block then
|
22
|
-
return false unless value.call(page)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
true
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
def find(conditions = {}, &extra_condition)
|
31
|
-
original_window = AePageObjects::Window.current
|
32
|
-
|
33
|
-
# Loop through all the windows and attempt to instantiate the Document. Continue to loop around
|
34
|
-
# until finding a Document that can be instantiated or timing out.
|
35
|
-
Capybara.wait_until do
|
36
|
-
find_window(Conditions.new(conditions, extra_condition))
|
37
|
-
end
|
38
|
-
|
39
|
-
rescue Capybara::TimeoutError
|
40
|
-
original_window.switch_to
|
41
|
-
|
42
|
-
all_windows = AePageObjects::Window.all.map do |window|
|
43
|
-
name = window.current_document && window.current_document.to_s || "<none>"
|
44
|
-
{:window_handle => window.handle, :document => name }
|
45
|
-
end
|
46
|
-
|
47
|
-
raise PageNotFound, "Couldn't find page #{@document_class.name} in any of the open windows: #{all_windows.inspect}"
|
48
|
-
end
|
49
|
-
|
50
|
-
private
|
51
|
-
|
52
|
-
def find_window(conditions)
|
53
|
-
AePageObjects::Window.all.each do |window|
|
54
|
-
window.switch_to
|
55
|
-
|
56
|
-
if inst = attempt_to_load(conditions)
|
57
|
-
return inst
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
nil
|
62
|
-
end
|
63
|
-
|
64
|
-
def attempt_to_load(conditions)
|
65
|
-
inst = @document_class.new
|
66
|
-
|
67
|
-
if conditions.match?(inst)
|
68
|
-
return inst
|
69
|
-
end
|
70
|
-
|
71
|
-
nil
|
72
|
-
rescue AePageObjects::LoadingFailed
|
73
|
-
# These will happen from the new() call above.
|
74
|
-
nil
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,50 +0,0 @@
|
|
1
|
-
module AePageObjects
|
2
|
-
class VariableDocument
|
3
|
-
|
4
|
-
# Remove all instance methods so even things like class()
|
5
|
-
# get handled by method_missing(). <lifted from activerecord>
|
6
|
-
instance_methods.each do |m|
|
7
|
-
unless m.to_s =~ /^(?:nil\?|send|object_id|to_a|tap)$|^__|^respond_to|is_a?/
|
8
|
-
undef_method m
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def initialize(*documents)
|
13
|
-
@documents = documents
|
14
|
-
end
|
15
|
-
|
16
|
-
def is_a?(document_class)
|
17
|
-
super || !! as_a(document_class)
|
18
|
-
rescue AePageObjects::Error
|
19
|
-
false
|
20
|
-
end
|
21
|
-
|
22
|
-
def as_a(document_class)
|
23
|
-
unless @documents.include?(document_class)
|
24
|
-
raise InvalidCast, "Cannot cast as #{document_class.name} from #{@documents.map(&:name).inspect}"
|
25
|
-
end
|
26
|
-
|
27
|
-
document_class.new
|
28
|
-
rescue AePageObjects::LoadingFailed => e
|
29
|
-
raise IncorrectCast, "Failed instantiating a #{document_class}: #{e.message}\nDocuments: #{@documents.map(&:name).inspect}"
|
30
|
-
end
|
31
|
-
|
32
|
-
private
|
33
|
-
|
34
|
-
def implicit_document_class
|
35
|
-
@implicit_document_class ||= @documents.first
|
36
|
-
end
|
37
|
-
|
38
|
-
def implicit_document
|
39
|
-
@implicit_document ||= as_a(implicit_document_class)
|
40
|
-
end
|
41
|
-
|
42
|
-
def method_missing(name, *args, &block)
|
43
|
-
implicit_document.__send__(name, *args, &block)
|
44
|
-
end
|
45
|
-
|
46
|
-
def respond_to?(*args)
|
47
|
-
super || implicit_document_class.allocate.respond_to?(*args)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|