Commit 8ed78d06 by Artūrs Mekšs

Tests for model annotating with encoding comments

parent c95ed52b
......@@ -345,6 +345,16 @@ end
Annotate::PATH_OPTIONS.each { |key| ENV[key.to_s] = '' }
end
def encoding_comments_list_each
[
'# encoding: UTF-8',
'# coding: UTF-8',
'# -*- coding: UTF-8 -*-',
'#encoding: utf-8',
'# -*- encoding : utf-8 -*-'
].each{|encoding_comment| yield encoding_comment }
end
it "should annotate the file before the model if position == 'before'" do
annotate_one_file :position => "before"
File.read(@model_file_name).should == "#{@schema_info}#{@file_content}"
......@@ -387,6 +397,20 @@ end
File.read(model_file_name).should == "#{schema_info}#{file_content}"
end
it "should not touch encoding comments" do
encoding_comments_list_each do |encoding_comment|
write_model "user.rb", <<-EOS
#{encoding_comment}
class User < ActiveRecord::Base
end
EOS
annotate_one_file :position => :before
File.read(@model_file_name).should == "#{encoding_comment}\n#{@schema_info}#{@file_content}"
end
end
describe "if a file can't be annotated" do
before do
write_model('user.rb', <<-EOS)
......
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