33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/routes2spec/command.rb', line 33
def perform(*)
if options.version?
say "Routes2spec: #{Routes2spec::VERSION}"
exit 0
end
if options.binstubs?
make_binstubs
exit 0
end
if options.verb? && !SUPPORTED_VERBS.include?(options.verb&.downcase)
say "Specified verb(#{options.verb}) is not supported! Supported verbs: [#{SUPPORTED_VERBS.join(", ")}]"
exit 1
end
require_application_and_environment!
require "action_dispatch/routing/inspector"
results = inspector.format(formatter, routes_filter)
results.each do |result|
relative_path = File.join("spec/requests", *result[:namespaces], "#{result[:name].underscore}_spec.rb")
writing_file(relative_path, result[:content])
relative_path = File.join("spec/routing", *result[:namespaces], "#{result[:name].underscore}_spec.rb")
writing_file(relative_path, result[:routing_content]) if options.routing?
end
end
|