regressor 0.6.1 → 0.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: df13c3751652a5afee456c0c213a664be8a7bf0a
4
- data.tar.gz: dd57cf25d8b877bb24d7bcd4301e250cdd2b905e
3
+ metadata.gz: 60e563373a3472e4fc9719c69541aa1299aab91a
4
+ data.tar.gz: d19cf8542f7bb1691049dfc052365a2655b1d941
5
5
  SHA512:
6
- metadata.gz: e80c4c5ee6811bbbd2c988bc7e1b488c320582b846c102423a8deb08705810ee2618c9bf5eda3a4a8fccd6487f18e5064adf8f814e6c3532adc52ab7d4f32314
7
- data.tar.gz: 2c48b1c3971e9169e9ea05e587e7e96c0386c3ca0fcbcf472c0093f4bcdd1b814e5cbcecacad2a48104356bc06f95c7e53d03f861bf3d192a8e77d0fb852389f
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 "Could not generate regression spec for controller #{controller_path} with action: #{action_method}"
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
- def generate_example(journey_route, controller_path, action_method, required_parts, url)
25
- request_method = journey_route.constraints[:request_method]
26
- if request_method.match('GET')
27
- "it { should route(:get, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) }"
28
- elsif request_method.match('POST')
29
- "it { should route(:post, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
30
- elsif request_method.match('PUT')
31
- "it { should route(:put, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
32
- elsif request_method.match('PATCH')
33
- "it { should route(:patch, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
34
- elsif request_method.match('DELETE')
35
- "it { should route(:delete, '#{url}').to('#{controller_path}##{action_method}', #{required_parts}) } "
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
 
@@ -1,3 +1,3 @@
1
1
  module Regressor
2
- VERSION = "0.6.1"
2
+ VERSION = "0.6.2"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'rails_helper'
2
2
 
3
- RSpec.describe <%= @controller.controller %>, regressor: true do
3
+ RSpec.describe <%= @controller.controller %>, regressor: true, type: :routing do
4
4
  # === Routes (REST) ===
5
5
  <%= @controller.rest_routes %>
6
6
  # === Callbacks (Before) ===
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.1
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-04-09 00:00:00.000000000 Z
11
+ date: 2017-07-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: shoulda-matchers