rest-api-generator 0.1.3 → 0.1.4
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/Gemfile.lock +1 -1
- data/lib/generators/rest_api_generator/helpers.rb +9 -7
- data/lib/generators/rest_api_generator/spec/rspec_generator.rb +2 -2
- data/lib/generators/rest_api_generator/spec/rswag_generator.rb +1 -1
- data/lib/generators/rest_api_generator/spec/templates/rspec/resource_controller_spec.rb.tt +1 -1
- data/lib/rest_api_generator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4873b5f52ba8ca76abbc7449e0c0398ee1d38fbfb47ebec80dabb293b3ca0cea
|
4
|
+
data.tar.gz: bd96d06619b7a14eb9e6b953d60bc6a2f84bb7d48b0cca5181c0a588bb066cba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cd7f1d823c9b0abba38301024eefb393eb460b10a0ff92e41b7f377b401f09f37771afd039701539fd697a4612e0b0a46ef99b6eccf81d118a23e5fff63bfbb
|
7
|
+
data.tar.gz: dbb337a4c098fdc2b04e71456b5664be8ca670fdd277436cf05111897a7f72ac0559bd47bacf840c6248406aae0e931506e00ad6f3715d9f22da4a9a30984b90
|
data/Gemfile.lock
CHANGED
@@ -71,22 +71,24 @@ module RestApiGenerator
|
|
71
71
|
def nested_routes
|
72
72
|
return "" if options["father"].blank?
|
73
73
|
|
74
|
-
"#{options["father"].downcase.pluralize}/\#{#{options["father"].singularize.downcase}.id}
|
74
|
+
"#{options["father"].downcase.pluralize}/\#{#{options["father"].singularize.downcase}.id}"
|
75
75
|
end
|
76
76
|
|
77
77
|
def initial_route
|
78
|
-
|
79
|
-
|
80
|
-
|
78
|
+
route = ""
|
79
|
+
route += scope_route_path if options["scope"].present?
|
80
|
+
route += options["father"].present? && route.present? ? "/#{nested_routes}" : nested_routes
|
81
|
+
route += "/#{plural_name}"
|
82
|
+
route[0] == "/" ? route : "/#{route}"
|
81
83
|
end
|
82
84
|
|
83
85
|
def spec_routes
|
84
86
|
{
|
85
87
|
index: initial_route,
|
86
|
-
show: initial_route + "
|
88
|
+
show: initial_route + "/\#{#{singular_name}.id}",
|
87
89
|
create: initial_route,
|
88
|
-
update: initial_route + "
|
89
|
-
delete: initial_route + "
|
90
|
+
update: initial_route + "/\#{#{singular_name}.id}",
|
91
|
+
delete: initial_route + "/\#{#{singular_name}.id}",
|
90
92
|
}
|
91
93
|
end
|
92
94
|
end
|
@@ -25,7 +25,7 @@ module RestApiGenerator
|
|
25
25
|
def nested_routes
|
26
26
|
return "" if options["father"].blank?
|
27
27
|
|
28
|
-
"#{options["father"].downcase.pluralize}/{#{options["father"].singularize.downcase}_id}
|
28
|
+
"#{options["father"].downcase.pluralize}/{#{options["father"].singularize.downcase}_id}"
|
29
29
|
end
|
30
30
|
|
31
31
|
def spec_routes
|
@@ -38,7 +38,7 @@ RSpec.describe "<%= class_name %>", type: :request do
|
|
38
38
|
|
39
39
|
describe "DELETE /<%= plural_name %>/:id" do
|
40
40
|
it "deletes an <%= plural_name %>" do
|
41
|
-
|
41
|
+
<%= singular_name %> = create(:<%= singular_name %>)
|
42
42
|
expect do
|
43
43
|
delete "<%= spec_routes[:delete] %>"
|
44
44
|
end.to change(<%= class_name %>, :count).by(-1)
|