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 = {}
345345 Annotate ::PATH_OPTIONS . each { |key | ENV [ key . to_s ] = '' }
346346 end
347347
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+
348358 it "should annotate the file before the model if position == 'before'" do
349359 annotate_one_file :position => "before"
350360 File . read ( @model_file_name ) . should == "#{ @schema_info } #{ @file_content } "
@@ -387,6 +397,20 @@ class Foo::User < ActiveRecord::Base
387397 File . read ( model_file_name ) . should == "#{ schema_info } #{ file_content } "
388398 end
389399
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+
390414 describe "if a file can't be annotated" do
391415 before do
392416 write_model ( 'user.rb' , <<-EOS )
You can’t perform that action at this time.
0 commit comments