ae_page_objects 1.3.0 → 1.4.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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20c13f38ceabdcf27ecc3f89d9de3553c5787945
|
4
|
+
data.tar.gz: dcd428213ed6c1424727b40e0cd1583d4b6d2cc2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b13c1d548b49b516dc2a8d71efb0676850fc04301044fe02118bd4f0ed899ad6d81850a3021181a104f5ba79cecba6af36fdbd0aa4d84400333bccb3ac1657ce
|
7
|
+
data.tar.gz: 5f390f9a20b9f5d459021cfb5bceef6c96c0dd08de671ba79baa9629329253e073ce8307482b37f96e87537bea86fe7b41f89d2dc3c22450a1d33375224d4b19
|
@@ -11,20 +11,55 @@ module AePageObjects
|
|
11
11
|
routes.send("#{named_route}_path", *args)
|
12
12
|
end
|
13
13
|
end
|
14
|
-
end
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
route.recognize(url, {:method => method})
|
15
|
+
def recognizes?(named_route, url)
|
16
|
+
url = normalize_url(url)
|
17
|
+
|
18
|
+
resolved_named_route = resolve_named_route(named_route)
|
21
19
|
|
22
|
-
|
20
|
+
[:get, :post, :put, :delete, :patch].each do |method|
|
21
|
+
resolved_route_from_url = resolve_url(url, method)
|
22
|
+
|
23
|
+
# The first resolved route matching named route is returned as
|
24
|
+
# Rails' routes are in priority order.
|
25
|
+
if resolved_named_route == resolved_route_from_url
|
26
|
+
return true
|
27
|
+
end
|
23
28
|
end
|
24
29
|
|
25
30
|
false
|
26
31
|
end
|
27
32
|
|
33
|
+
private
|
34
|
+
|
35
|
+
def routes
|
36
|
+
raise NotImplementedError, "You must implement routes"
|
37
|
+
end
|
38
|
+
|
39
|
+
def normalize_url(url)
|
40
|
+
raise NotImplementedError, "You must implement normalize_url"
|
41
|
+
end
|
42
|
+
|
43
|
+
def router
|
44
|
+
raise NotImplementedError, "You must implement router"
|
45
|
+
end
|
46
|
+
|
47
|
+
def resolve_named_route(named_route)
|
48
|
+
requirements = router.named_routes[named_route].requirements
|
49
|
+
ResolvedRoute.new(requirements[:controller], requirements[:action])
|
50
|
+
end
|
51
|
+
|
52
|
+
def resolve_url(url, method)
|
53
|
+
recognized_path = router.recognize_path(url, {:method => method})
|
54
|
+
ResolvedRoute.new(recognized_path[:controller], recognized_path[:action])
|
55
|
+
rescue ActionController::RoutingError, ActionController::MethodNotAllowed
|
56
|
+
end
|
57
|
+
|
58
|
+
ResolvedRoute = Struct.new(:controller, :action)
|
59
|
+
end
|
60
|
+
|
61
|
+
class Rails23 < Base
|
62
|
+
|
28
63
|
private
|
29
64
|
|
30
65
|
def routes
|
@@ -36,21 +71,17 @@ module AePageObjects
|
|
36
71
|
routes_class.new
|
37
72
|
end
|
38
73
|
end
|
39
|
-
end
|
40
74
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
["GET", "PUT", "POST", "DELETE", "PATCH"].each do |method|
|
46
|
-
router.recognize(request_for(url, method)) do |route, matches, params|
|
47
|
-
return true if route.name.to_s == path.to_s
|
48
|
-
end
|
49
|
-
end
|
75
|
+
def normalize_url(url)
|
76
|
+
url
|
77
|
+
end
|
50
78
|
|
51
|
-
|
79
|
+
def router
|
80
|
+
ActionController::Routing::Routes
|
52
81
|
end
|
82
|
+
end
|
53
83
|
|
84
|
+
class Rails3 < Base
|
54
85
|
|
55
86
|
private
|
56
87
|
|
@@ -66,11 +97,12 @@ module AePageObjects
|
|
66
97
|
end
|
67
98
|
end
|
68
99
|
|
69
|
-
def
|
70
|
-
|
71
|
-
|
100
|
+
def normalize_url(url)
|
101
|
+
Rack::Mount::Utils.normalize_path(url) unless url =~ %r{://}
|
102
|
+
end
|
72
103
|
|
73
|
-
|
104
|
+
def router
|
105
|
+
::Rails.application.routes
|
74
106
|
end
|
75
107
|
|
76
108
|
def routes
|
@@ -86,26 +118,21 @@ module AePageObjects
|
|
86
118
|
class Rails32 < Rails3
|
87
119
|
|
88
120
|
private
|
89
|
-
def url_and_router(url)
|
90
|
-
url = Journey::Router::Utils.normalize_path(url) unless url =~ %r{://}
|
91
|
-
router = ::Rails.application.routes.router
|
92
121
|
|
93
|
-
|
122
|
+
def normalize_url(url)
|
123
|
+
Journey::Router::Utils.normalize_path(url) unless url =~ %r{://}
|
94
124
|
end
|
95
125
|
end
|
96
126
|
|
97
127
|
class Rails4 < Rails32
|
98
128
|
|
99
|
-
|
100
|
-
def url_and_router(url)
|
101
|
-
require 'action_dispatch/journey'
|
102
|
-
url = ActionDispatch::Journey::Router::Utils.normalize_path(url) unless url =~ %r{://}
|
103
|
-
router = ::Rails.application.routes.router
|
129
|
+
private
|
104
130
|
|
105
|
-
|
131
|
+
def normalize_url(url)
|
132
|
+
require 'action_dispatch/journey'
|
133
|
+
ActionDispatch::Journey::Router::Utils.normalize_path(url) unless url =~ %r{://}
|
106
134
|
end
|
107
135
|
end
|
108
|
-
|
109
136
|
end
|
110
137
|
|
111
138
|
def path_recognizes_url?(path, url)
|
@@ -134,7 +161,7 @@ module AePageObjects
|
|
134
161
|
Recognizer::Rails3.new
|
135
162
|
elsif ::Rails.version =~ /\A3\.2/
|
136
163
|
Recognizer::Rails32.new
|
137
|
-
elsif ::Rails.version =~ /\A4\.[
|
164
|
+
elsif ::Rails.version =~ /\A4\.[012]/
|
138
165
|
Recognizer::Rails4.new
|
139
166
|
else
|
140
167
|
warn "[WARNING]: AePageObjects is not tested against Rails #{::Rails.version} and may behave in an undefined manner."
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ae_page_objects
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Donnie Tognazzini
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: capybara
|
@@ -95,7 +95,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
95
95
|
version: '0'
|
96
96
|
requirements: []
|
97
97
|
rubyforge_project:
|
98
|
-
rubygems_version: 2.
|
98
|
+
rubygems_version: 2.4.3
|
99
99
|
signing_key:
|
100
100
|
specification_version: 4
|
101
101
|
summary: Capybara Page Objects pattern
|