diff --git a/lib/annotate/annotate_routes.rb b/lib/annotate/annotate_routes.rb index 7f8435ee2..3931fc6dc 100644 --- a/lib/annotate/annotate_routes.rb +++ b/lib/annotate/annotate_routes.rb @@ -77,7 +77,7 @@ def remove_annotations(options={}) end def self.app_routes_map(options) - routes_map = `rake routes`.split(/\n/, -1) + routes_map = `rake routes`.chomp("\n").split(/\n/, -1) # In old versions of Rake, the first line of output was the cwd. Not so # much in newer ones. We ditch that line if it exists, and if not, we diff --git a/spec/annotate/annotate_routes_spec.rb b/spec/annotate/annotate_routes_spec.rb index 037a4a2bf..f53dc108c 100644 --- a/spec/annotate/annotate_routes_spec.rb +++ b/spec/annotate/annotate_routes_spec.rb @@ -22,10 +22,10 @@ def mock_file(stubs = {}) expect(File).to receive(:exists?).with(ROUTE_FILE).and_return(true) expect(File).to receive(:read).with(ROUTE_FILE).and_return("") - expect(AnnotateRoutes).to receive(:`).with('rake routes').and_return(' Prefix Verb URI Pattern Controller#Action + expect(AnnotateRoutes).to receive(:`).with('rake routes').and_return(" Prefix Verb URI Pattern Controller#Action myaction1 GET /url1(.:format) mycontroller1#action myaction2 POST /url2(.:format) mycontroller2#action - myaction3 DELETE|GET /url3(.:format) mycontroller3#action') + myaction3 DELETE|GET /url3(.:format) mycontroller3#action\n") expect(AnnotateRoutes).to receive(:puts).with(ANNOTATION_ADDED) end