Commit c4ecc117 by Alexander Belozerov Committed by Cuong Tran

Additional new line between magic comment and annotation (AnnotateRoutes) (#524)

parent 4db90efe
......@@ -39,11 +39,13 @@ module AnnotateRoutes
routes_map = app_routes_map(options)
magic_comments_map, routes_map = extract_magic_comments_from_array(routes_map)
out = []
magic_comments_map.each do |magic_comment|
out << magic_comment
end
out << '' if magic_comments_map.any?
out += ["# #{options[:wrapper_open]}"] if options[:wrapper_open]
......@@ -174,6 +176,7 @@ module AnnotateRoutes
magic_comments_map, content = extract_magic_comments_from_array(content)
if %w(before top).include?(options[:position_in_routes])
header = header << '' if content.first != ''
magic_comments_map << '' if magic_comments_map.any?
new_content = magic_comments_map + header + content
else
# Ensure we have adequate trailing newlines at the end of the file to
......
......@@ -106,6 +106,7 @@ describe AnnotateRoutes do
expect(File).to receive(:open).with(ROUTE_FILE, 'wb').and_yield(mock_file)
expect(@mock_file).to receive(:puts).with("
#{magic_comment}
# == Route Map
#
# Prefix Verb URI Pattern Controller#Action
......@@ -125,6 +126,7 @@ describe AnnotateRoutes do
expect(File).to receive(:open).with(ROUTE_FILE, 'wb').and_yield(mock_file)
expect(@mock_file).to receive(:puts).with("
#{magic_comment}
# ## Route Map
#
# Prefix | Verb | URI Pattern | Controller#Action
......@@ -144,6 +146,7 @@ describe AnnotateRoutes do
expect(File).to receive(:open).with(ROUTE_FILE, 'wb').and_yield(mock_file)
expect(@mock_file).to receive(:puts).with("
#{magic_comment}
# START
# == Route Map
#
......@@ -208,7 +211,7 @@ describe AnnotateRoutes do
magic_comments_list_each do |magic_comment|
expect(File).to receive(:read).with(ROUTE_FILE).and_return("#{magic_comment}\nSomething")
expect(@mock_file).to receive(:puts).with("#{magic_comment}\n# == Route Map\n#\n\nSomething\n")
expect(@mock_file).to receive(:puts).with("#{magic_comment}\n\n# == Route Map\n#\n\nSomething\n")
expect(AnnotateRoutes).to receive(:puts).with(ANNOTATION_ADDED)
AnnotateRoutes.do_annotations(position_in_routes: 'top')
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment