Improve the api:resource generator

This commit is contained in:
Eric Schultz 2018-08-25 15:59:03 -05:00
parent c7d39c5669
commit d2f04ec426
2 changed files with 13 additions and 1 deletions

View file

@ -4,7 +4,11 @@ class Api::ResourceGenerator < Rails::Generators::NamedBase
template 'resource.rb.erb', File.join("app/api/houdini/v1", "#{name.underscore}.rb")
end
def copy_to_spec
template 'spec.rb.erb', File.join("spec/api/houdini/", "#{name.underscore}_spec.rb")
end
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

View 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