diff --git a/lib/generators/api/resource/resource_generator.rb b/lib/generators/api/resource/resource_generator.rb index 5c2d514f..2e737da8 100644 --- a/lib/generators/api/resource/resource_generator.rb +++ b/lib/generators/api/resource/resource_generator.rb @@ -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 diff --git a/lib/generators/api/resource/templates/spec.rb.erb b/lib/generators/api/resource/templates/spec.rb.erb new file mode 100644 index 00000000..c47d73e6 --- /dev/null +++ b/lib/generators/api/resource/templates/spec.rb.erb @@ -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 \ No newline at end of file