regressor 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 60e563373a3472e4fc9719c69541aa1299aab91a
|
4
|
+
data.tar.gz: d19cf8542f7bb1691049dfc052365a2655b1d941
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f22722aa1d52e528c03042150cb6e2ecfefc29db8654207007c0252481f8579a0b6fe8aefcf09a0639cdcbc4bca598b66dd2b2545e51266421ad51bca5586586
|
7
|
+
data.tar.gz: 231bb11c0a272b8e133288e9724dec890bf5a640a8a62d4193cf552ee6cc4cba91a0ecf68c75a6bac90d5da9bbd93af2b096de9c2248efd2d2dbd031e50b4c22
|
@@ -9,30 +9,53 @@ module Regressor
|
|
9
9
|
@controller.constantize.action_methods.map do |action_method|
|
10
10
|
begin
|
11
11
|
journey_route = extract_journey_route(controller_path, action_method)
|
12
|
+
unless journey_route
|
13
|
+
puts "Skip generating regression spec for controller #{controller_path} with action: #{action_method}" unless ENV['QUIET']
|
14
|
+
next
|
15
|
+
end
|
12
16
|
required_parts = extract_required_parts(journey_route)
|
13
17
|
url = url_for({controller: controller_path, action: action_method, only_path: true}.merge(required_parts))
|
14
18
|
generate_example(journey_route, controller_path, action_method, required_parts, url)
|
15
19
|
rescue
|
16
|
-
puts "
|
20
|
+
puts "Failed to generate regression spec for controller #{controller_path} with action: #{action_method}. #{$!.class}: #{$!.message}"
|
17
21
|
nil
|
18
22
|
end
|
19
23
|
end.uniq.compact.join("\n ")
|
20
24
|
end
|
21
25
|
|
22
26
|
private
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
27
|
+
|
28
|
+
if Rails::VERSION::MAJOR >= 5
|
29
|
+
def generate_example(journey_route, controller_path, action_method, required_parts, url)
|
30
|
+
case journey_route.verb
|
31
|
+
when 'GET'
|
32
|
+
"it { should route(:get, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) }"
|
33
|
+
when 'POST'
|
34
|
+
"it { should route(:post, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
|
35
|
+
when 'PUT'
|
36
|
+
"it { should route(:put, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
|
37
|
+
when 'PATCH'
|
38
|
+
"it { should route(:patch, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
|
39
|
+
when 'DELETE'
|
40
|
+
"it { should route(:delete, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
else
|
45
|
+
|
46
|
+
def generate_example(journey_route, controller_path, action_method, required_parts, url)
|
47
|
+
request_method = journey_route.constraints[:request_method]
|
48
|
+
if request_method.match('GET')
|
49
|
+
"it { should route(:get, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) }"
|
50
|
+
elsif request_method.match('POST')
|
51
|
+
"it { should route(:post, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
|
52
|
+
elsif request_method.match('PUT')
|
53
|
+
"it { should route(:put, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
|
54
|
+
elsif request_method.match('PATCH')
|
55
|
+
"it { should route(:patch, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
|
56
|
+
elsif request_method.match('DELETE')
|
57
|
+
"it { should route(:delete, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
|
58
|
+
end
|
36
59
|
end
|
37
60
|
end
|
38
61
|
|
data/lib/regressor/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: regressor
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Erwin Schens
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-07-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: shoulda-matchers
|