routes2spec 0.2.0 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +1 -1
- data/Gemfile +2 -0
- data/README.md +2 -0
- data/lib/routes2spec/command.rb +11 -3
- data/lib/routes2spec/request_spec_formatter.rb +8 -2
- data/lib/routes2spec/version.rb +1 -1
- data/routes2spec.gemspec +2 -2
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79e4e2150811b3cc919d8db511042cc8a733e141f3c1d4e04891accbf364f922
|
4
|
+
data.tar.gz: '07904d17f0923955560f427586158be17578697bbf75e45eac0dae7728ccec63'
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fe56ba68c66c4115fab4940447ac7641e439656f2ba7bd7819ba9f14324ef610a2be1df81efab02913bfe17854587718bc3557f4f47c0f081c5cf1a4f20864ac
|
7
|
+
data.tar.gz: c4887452c2fdc0c26216ff590be8b4fa8c24eb5844fb03ae10000ef67fec8807882918147286cbd8998516bf0f1500da45e862bdc4510fa3018696e4cef379d0
|
data/.rubocop.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/lib/routes2spec/command.rb
CHANGED
@@ -6,6 +6,8 @@ require_relative "./request_spec_formatter"
|
|
6
6
|
module Routes2spec
|
7
7
|
# Routes2spec::Command class
|
8
8
|
class Command < Rails::Command::Base
|
9
|
+
SUPPORTED_VERBS = Routes2spec::RequestSpecFormatter::SUPPORTED_VERBS
|
10
|
+
|
9
11
|
class_option :help, aliases: "-h", banner: "", desc: "Show this message."
|
10
12
|
class_option :version, aliases: "-V", banner: "", desc: "Show version."
|
11
13
|
|
@@ -15,10 +17,11 @@ module Routes2spec
|
|
15
17
|
desc: "Filter by a specific controller, e.g. PostsController or Admin::PostsController."
|
16
18
|
class_option :grep, aliases: "-g", desc: "Grep routes by a specific pattern."
|
17
19
|
class_option :symbol_status, banner: "", desc: "Use symbols for http status."
|
18
|
-
class_option :overwrite, banner: "", desc: "
|
19
|
-
class_option :force_overwrite, banner: "", desc: "
|
20
|
+
class_option :overwrite, banner: "", desc: "Prompts for confirmation to overwrite each file if it already exists."
|
21
|
+
class_option :force_overwrite, banner: "", desc: "Forcibly overwrites existing files without confirmation."
|
20
22
|
class_option :pending, banner: "", desc: "Mark examples as pending."
|
21
23
|
class_option :routing, type: :boolean, defalut: false, desc: "Generate routing specs."
|
24
|
+
class_option :verb, desc: "Generate only specific verb. Supported verbs: [#{SUPPORTED_VERBS.join(", ")}]"
|
22
25
|
|
23
26
|
class << self
|
24
27
|
def executable
|
@@ -37,6 +40,11 @@ module Routes2spec
|
|
37
40
|
exit 0
|
38
41
|
end
|
39
42
|
|
43
|
+
if options.verb? && !SUPPORTED_VERBS.include?(options.verb&.downcase)
|
44
|
+
say "Specified verb(#{options.verb}) is not supported! Supported verbs: [#{SUPPORTED_VERBS.join(", ")}]"
|
45
|
+
exit 1
|
46
|
+
end
|
47
|
+
|
40
48
|
require_application_and_environment!
|
41
49
|
require "action_dispatch/routing/inspector"
|
42
50
|
|
@@ -107,7 +115,7 @@ module Routes2spec
|
|
107
115
|
end
|
108
116
|
|
109
117
|
def formatter_opts
|
110
|
-
options.symbolize_keys.slice(:symbol_status, :pending)
|
118
|
+
options.symbolize_keys.slice(:symbol_status, :pending, :verb)
|
111
119
|
end
|
112
120
|
end
|
113
121
|
end
|
@@ -3,6 +3,8 @@
|
|
3
3
|
module Routes2spec
|
4
4
|
# Routes2spec::RequestSpecFormatter class
|
5
5
|
class RequestSpecFormatter
|
6
|
+
SUPPORTED_VERBS = %w[get post patch put delete].freeze
|
7
|
+
|
6
8
|
STATUS = {
|
7
9
|
get: 200,
|
8
10
|
post: 201,
|
@@ -57,15 +59,19 @@ module Routes2spec
|
|
57
59
|
params_str = param_names.map{|name| "#{name}: \"#{name}\"" }.join(", ")
|
58
60
|
path_name = r[:name] || ""
|
59
61
|
path_name = grouped_routes.find{ _1[:path] == r[:path] && !_1[:name].empty? }&.fetch(:name) || "" if path_name.empty?
|
60
|
-
Routes2spec.log_debug "verb: #{verb}, path: #{path}, path_name: #{path_name}"
|
62
|
+
Routes2spec.log_debug "verb: #{verb}, path: #{path}, path_name: #{path_name}, @opts: #{@opts}"
|
61
63
|
if path_name.empty?
|
62
64
|
Routes2spec.log "Skip. No path name! `#{verb&.upcase} #{path}`"
|
63
65
|
next
|
64
66
|
end
|
65
|
-
unless
|
67
|
+
unless SUPPORTED_VERBS.include?(verb)
|
66
68
|
Routes2spec.log "Skip. Unsupported verb! `#{verb&.upcase} #{path}`"
|
67
69
|
next
|
68
70
|
end
|
71
|
+
if !@opts[:verb].nil? && @opts[:verb].downcase != verb
|
72
|
+
Routes2spec.log "Skip. Not matched specified verb(#{@opts[:verb].upcase})! `#{verb&.upcase} #{path}`"
|
73
|
+
next
|
74
|
+
end
|
69
75
|
endpoint, constraints = r[:reqs].split(" ")
|
70
76
|
Routes2spec.log_debug "endpoint: #{endpoint}, constraints: #{constraints}"
|
71
77
|
# TODO: insert constraints to routing spec
|
data/lib/routes2spec/version.rb
CHANGED
data/routes2spec.gemspec
CHANGED
@@ -12,7 +12,7 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.description = "Generate Request specs and Routing specs of RSpec, from your Rails routes config. It is useful as a test scaffolding."
|
13
13
|
spec.homepage = "https://github.com/shuuuuun/routes2spec"
|
14
14
|
spec.license = "MIT"
|
15
|
-
spec.required_ruby_version = ">=
|
15
|
+
spec.required_ruby_version = ">= 3.1.0"
|
16
16
|
|
17
17
|
spec.metadata["homepage_uri"] = spec.homepage
|
18
18
|
spec.metadata["source_code_uri"] = "https://github.com/shuuuuun/routes2spec"
|
@@ -30,7 +30,7 @@ Gem::Specification.new do |spec|
|
|
30
30
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
31
31
|
spec.require_paths = ["lib"]
|
32
32
|
|
33
|
-
spec.add_dependency "rails", "
|
33
|
+
spec.add_dependency "rails", "~> 6.1"
|
34
34
|
# spec.add_dependency "rspec", ">= 3.9"
|
35
35
|
|
36
36
|
# For more information and examples about making a new gem, check out our
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routes2spec
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- shuuuuuny
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-06-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '6.
|
19
|
+
version: '6.1'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '6.
|
26
|
+
version: '6.1'
|
27
27
|
description: Generate Request specs and Routing specs of RSpec, from your Rails routes
|
28
28
|
config. It is useful as a test scaffolding.
|
29
29
|
email: []
|
@@ -66,14 +66,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
66
66
|
requirements:
|
67
67
|
- - ">="
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 3.1.0
|
70
70
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
71
|
requirements:
|
72
72
|
- - ">="
|
73
73
|
- !ruby/object:Gem::Version
|
74
74
|
version: '0'
|
75
75
|
requirements: []
|
76
|
-
rubygems_version: 3.
|
76
|
+
rubygems_version: 3.5.3
|
77
77
|
signing_key:
|
78
78
|
specification_version: 4
|
79
79
|
summary: Generate Request specs and Routing specs of RSpec, from your Rails routes
|