regressor 0.3.0 → 0.3.1

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: 795f3adddccc068387b7f54e11669723c4bb73c2
4
- data.tar.gz: bc3e3f93a3c4675658eebdb1208712b907fe1fbc
3
+ metadata.gz: ef0984425573a1e4cd428276b17ae736cf570008
4
+ data.tar.gz: e5e4e56f8a4c0336f2b76c10ddef6947712981a8
5
5
  SHA512:
6
- metadata.gz: 920e3277925ef020cd0b3f9bbe34b987ea51d4759bcdeb3d5618191361dedf6b8ce7f3e73f737baf1daeaa220da0fc08950437c26dce892344f2661737a096bc
7
- data.tar.gz: c57c7d37d2ba882633d1774d9440da1a630b6f4d21d2bcd00a198a541ab765bf7591462b56880cbb6400c743da44ca95ad8ed43b53f45bd9bd76691b78a31160
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
- journey_route = Rails.application.routes.routes.routes.select do |route|
10
- if route.defaults.present?
11
- route.defaults[:controller].to_sym == controller_path.to_sym && route.defaults[:action].to_sym == action_method.to_sym
12
- else
13
- false
14
- end
15
- end.first
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
- required_parts = journey_route.required_parts.inject({}) do |required_part_hash, required_part|
18
- required_part_hash.merge!({
19
- required_part => 1
20
- })
21
- end
22
- url = url_for({controller: controller_path, action: action_method, only_path: true}.merge(required_parts))
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
- if journey_route.constraints[:request_method].match('GET')
25
- "it { should route(:get, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
26
- elsif journey_route.constraints[:request_method].match('POST')
27
- "it { should route(:post, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
28
- elsif journey_route.constraints[:request_method].match('PUT')
29
- "it { should route(:put, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
30
- elsif journey_route.constraints[:request_method].match('PATCH')
31
- "it { should route(:patch, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
32
- elsif journey_route.constraints[:request_method].match('DELETE')
33
- "it { should route(:delete, '#{url}').to(#{{controller: controller_path, action: action_method}.merge(required_parts).to_s}) } "
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
@@ -1,3 +1,3 @@
1
1
  module Regressor
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: regressor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Erwin Schens