regressor 0.3.0 → 0.3.1
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/lib/generators/regressor/controller/routing/rest/routes.rb +29 -24
- data/lib/regressor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ef0984425573a1e4cd428276b17ae736cf570008
|
4
|
+
data.tar.gz: e5e4e56f8a4c0336f2b76c10ddef6947712981a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd777bcfe7d77e595cf106a62b5f5fbbb7a47e112976f33438837c152b6ec97acf974a1319d39cbde745801c57836fd7ba70eb9768b541c80b7bc7e25f0ee3b6
|
7
|
+
data.tar.gz: 5c09d5d3ed4747f1144d66bca17633c0bc2aaa551de2e5a2648c9a98ca2d6d0c4782043c75605bf4e184d7375244500083db185a2d71440500c5360ba53a962e
|
@@ -4,35 +4,40 @@ module Regressor
|
|
4
4
|
module Rest
|
5
5
|
module Routes
|
6
6
|
def rest_routes
|
7
|
+
|
7
8
|
controller_path = @controller.constantize.controller_path
|
8
9
|
@controller.constantize.action_methods.map do |action_method|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
10
|
+
begin
|
11
|
+
journey_route = Rails.application.routes.routes.routes.select do |route|
|
12
|
+
if route.defaults.present?
|
13
|
+
route.defaults[:controller].to_sym == controller_path.to_sym && route.defaults[:action].to_sym == action_method.to_sym
|
14
|
+
else
|
15
|
+
false
|
16
|
+
end
|
17
|
+
end.first
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
19
|
+
required_parts = journey_route.required_parts.inject({}) do |required_part_hash, required_part|
|
20
|
+
required_part_hash.merge!({
|
21
|
+
required_part => 1
|
22
|
+
})
|
23
|
+
end
|
24
|
+
url = url_for({controller: controller_path, action: action_method, only_path: true}.merge(required_parts))
|
23
25
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
26
|
+
if journey_route.constraints[:request_method].match('GET')
|
27
|
+
"it { should route(:get, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
|
28
|
+
elsif journey_route.constraints[:request_method].match('POST')
|
29
|
+
"it { should route(:post, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
|
30
|
+
elsif journey_route.constraints[:request_method].match('PUT')
|
31
|
+
"it { should route(:put, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
|
32
|
+
elsif journey_route.constraints[:request_method].match('PATCH')
|
33
|
+
"it { should route(:patch, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
|
34
|
+
elsif journey_route.constraints[:request_method].match('DELETE')
|
35
|
+
"it { should route(:delete, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
|
36
|
+
end
|
37
|
+
rescue
|
38
|
+
puts "Could not generate regression spec for controller #{controller_path} with action: #{action_method}"
|
39
|
+
nil
|
34
40
|
end
|
35
|
-
|
36
41
|
end.uniq.compact.join("\n\t")
|
37
42
|
end
|
38
43
|
end
|
data/lib/regressor/version.rb
CHANGED