rswag/rswag-specs/lib/generators/rspec/swagger/swagger_generator.rb
2019-10-16 21:12:36 +01:00

25 lines
568 B
Ruby

require 'rspec/rails/swagger/route_parser'
require 'rails/generators'
module Rspec
module Generators
class SwaggerGenerator < ::Rails::Generators::NamedBase
source_root File.expand_path('../templates', __FILE__)
def setup
@routes = RSpec::Rails::Swagger::RouteParser.new(controller_path).routes
end
def create_spec_file
template 'spec.rb', File.join('spec', 'requests', "#{controller_path}_spec.rb")
end
private
def controller_path
file_path.chomp('_controller')
end
end
end
end