Commit 6f62d0e6 by Jon Frisby

Rename AnnotateRoutes.do_annotate to AnnotateRoutes.do_annotations for consistency.

parent d47092e7
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
module AnnotateRoutes module AnnotateRoutes
PREFIX = "# == Route Map" PREFIX = "# == Route Map"
def self.do_annotate(options={}) def self.do_annotations(options={})
return unless(routes_exists?) return unless(routes_exists?)
if options[:require] if options[:require]
......
...@@ -7,7 +7,7 @@ task :annotate_routes => :environment do ...@@ -7,7 +7,7 @@ task :annotate_routes => :environment do
ENV['position'] = options[:position] = Annotate.fallback(ENV['position'], 'before') ENV['position'] = options[:position] = Annotate.fallback(ENV['position'], 'before')
options[:position_in_routes] = Annotate.fallback(ENV['position_in_routes'], ENV['position']) options[:position_in_routes] = Annotate.fallback(ENV['position_in_routes'], ENV['position'])
options[:require] = ENV['require'] ? ENV['require'].split(',') : [] options[:require] = ENV['require'] ? ENV['require'].split(',') : []
AnnotateRoutes.do_annotate(options) AnnotateRoutes.do_annotations(options)
end end
desc "Removes the route map from routes.rb" desc "Removes the route map from routes.rb"
......
...@@ -10,7 +10,7 @@ describe AnnotateRoutes do ...@@ -10,7 +10,7 @@ describe AnnotateRoutes do
it "should check if routes.rb exists" do it "should check if routes.rb exists" do
File.should_receive(:exists?).with("config/routes.rb").and_return(false) File.should_receive(:exists?).with("config/routes.rb").and_return(false)
AnnotateRoutes.should_receive(:puts).with("Can`t find routes.rb") AnnotateRoutes.should_receive(:puts).with("Can`t find routes.rb")
AnnotateRoutes.do_annotate AnnotateRoutes.do_annotations
end end
describe "When Annotating, with older Rake Versions" do describe "When Annotating, with older Rake Versions" do
...@@ -25,13 +25,13 @@ describe AnnotateRoutes do ...@@ -25,13 +25,13 @@ describe AnnotateRoutes do
it "should annotate and add a newline!" do it "should annotate and add a newline!" do
File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo") File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo")
@mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# good line\n/) @mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# good line\n/)
AnnotateRoutes.do_annotate AnnotateRoutes.do_annotations
end end
it "should not add a newline if there are empty lines" do it "should not add a newline if there are empty lines" do
File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo\n") File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo\n")
@mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# good line\n/) @mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# good line\n/)
AnnotateRoutes.do_annotate AnnotateRoutes.do_annotations
end end
end end
...@@ -48,13 +48,13 @@ describe AnnotateRoutes do ...@@ -48,13 +48,13 @@ describe AnnotateRoutes do
it "should annotate and add a newline!" do it "should annotate and add a newline!" do
File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo") File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo")
@mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# another good line\n# good line\n/) @mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# another good line\n# good line\n/)
AnnotateRoutes.do_annotate AnnotateRoutes.do_annotations
end end
it "should not add a newline if there are empty lines" do it "should not add a newline if there are empty lines" do
File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo\n") File.should_receive(:read).with("config/routes.rb").and_return("ActionController::Routing...\nfoo\n")
@mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# another good line\n# good line\n/) @mock_file.should_receive(:puts).with(/ActionController::Routing...\nfoo\n\n# == Route Map \(Updated \d{4}-\d{2}-\d{2} \d{2}:\d{2}\)\n#\n# another good line\n# good line\n/)
AnnotateRoutes.do_annotate AnnotateRoutes.do_annotations
end end
end 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