Improve the api:resource generator
This commit is contained in:
parent
c7d39c5669
commit
d2f04ec426
2 changed files with 13 additions and 1 deletions
|
@ -4,7 +4,11 @@ class Api::ResourceGenerator < Rails::Generators::NamedBase
|
||||||
template 'resource.rb.erb', File.join("app/api/houdini/v1", "#{name.underscore}.rb")
|
template 'resource.rb.erb', File.join("app/api/houdini/v1", "#{name.underscore}.rb")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def copy_to_spec
|
||||||
|
template 'spec.rb.erb', File.join("spec/api/houdini/", "#{name.underscore}_spec.rb")
|
||||||
|
end
|
||||||
|
|
||||||
def add_to_root_api
|
def add_to_root_api
|
||||||
inject_into_file "app/api/houdini/v1/api.rb", "\tmount Houdini::V1::#{ name.camelcase}\n", after: "class Houdini::V1::API < Grape::API\n"
|
inject_into_file "app/api/houdini/v1/api.rb", "mount Houdini::V1::#{ name.camelcase} => \"/#{name.underscore}\"\n ", before:"# Additional mounts are added via generators above this line"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
8
lib/generators/api/resource/templates/spec.rb.erb
Normal file
8
lib/generators/api/resource/templates/spec.rb.erb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
describe Houdini::V1::<%= name.camelcase %>, :type => :request do
|
||||||
|
describe :get do
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in a new issue