Sha256: 570ad4860191d6b7a54c88141392310d1ebafed2b540d5782076108f37ed065d
Contents?: true
Size: 1.9 KB
Versions: 2
Compression:
Stored size: 1.9 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe Encoding do subject(:encoding) { Encoding.new } it 'registers an offence when no encoding present', ruby: 1.9 do inspect_source(encoding, ['def foo() end']) expect(encoding.messages).to eq( ['Missing utf-8 encoding comment.']) end it 'accepts encoding on first line', ruby: 1.9 do inspect_source(encoding, ['# encoding: utf-8', 'def foo() end']) expect(encoding.offences).to be_empty end it 'accepts encoding on second line when shebang present', ruby: 1.9 do inspect_source(encoding, ['#!/usr/bin/env ruby', '# encoding: utf-8', 'def foo() end']) expect(encoding.messages).to be_empty end it 'books an offence when encoding is in the wrong place', ruby: 1.9 do inspect_source(encoding, ['def foo() end', '# encoding: utf-8']) expect(encoding.messages).to eq( ['Missing utf-8 encoding comment.']) end it 'does not register an offence on Ruby 2.0', ruby: 2.0 do inspect_source(encoding, ['def foo() end']) expect(encoding.offences).to be_empty end it 'accepts encoding inserted by magic_encoding gem', ruby: 1.9 do inspect_source(encoding, ['# -*- encoding : utf-8 -*-', 'def foo() end']) expect(encoding.messages).to be_empty end it 'accepts vim-style encoding comments', ruby: 1.9 do inspect_source(encoding, ['# vim:fileencoding=utf-8', 'def foo() end']) expect(encoding.messages).to be_empty end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.13.1 | spec/rubocop/cop/style/encoding_spec.rb |
rubocop-0.13.0 | spec/rubocop/cop/style/encoding_spec.rb |