File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -345,6 +345,16 @@ def annotate_one_file options = {}
345
345
Annotate ::PATH_OPTIONS . each { |key | ENV [ key . to_s ] = '' }
346
346
end
347
347
348
+ def encoding_comments_list_each
349
+ [
350
+ '# encoding: UTF-8' ,
351
+ '# coding: UTF-8' ,
352
+ '# -*- coding: UTF-8 -*-' ,
353
+ '#encoding: utf-8' ,
354
+ '# -*- encoding : utf-8 -*-'
355
+ ] . each { |encoding_comment | yield encoding_comment }
356
+ end
357
+
348
358
it "should annotate the file before the model if position == 'before'" do
349
359
annotate_one_file :position => "before"
350
360
File . read ( @model_file_name ) . should == "#{ @schema_info } #{ @file_content } "
@@ -387,6 +397,20 @@ class Foo::User < ActiveRecord::Base
387
397
File . read ( model_file_name ) . should == "#{ schema_info } #{ file_content } "
388
398
end
389
399
400
+ it "should not touch encoding comments" do
401
+ encoding_comments_list_each do |encoding_comment |
402
+ write_model "user.rb" , <<-EOS
403
+ #{ encoding_comment }
404
+ class User < ActiveRecord::Base
405
+ end
406
+ EOS
407
+
408
+ annotate_one_file :position => :before
409
+
410
+ File . read ( @model_file_name ) . should == "#{ encoding_comment } \n #{ @schema_info } #{ @file_content } "
411
+ end
412
+ end
413
+
390
414
describe "if a file can't be annotated" do
391
415
before do
392
416
write_model ( 'user.rb' , <<-EOS )
You can’t perform that action at this time.
0 commit comments