Sha256: 657ac71e6bf977aa3767d934cffd7b8844f2d2f7815eb3bbb01fd1fa0222a425

Contents?: true

Size: 957 Bytes

Versions: 11

Compression:

Stored size: 957 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe RuboCop::Cop::Style::AsciiIdentifiers do
  subject(:cop) { described_class.new }

  it 'registers an offense for a variable name with non-ascii chars' do
    inspect_source(cop,
                   ['# encoding: utf-8',
                    'älg = 1'])
    expect(cop.offenses.size).to eq(1)
    expect(cop.messages)
      .to eq(['Use only ascii symbols in identifiers.'])
  end

  it 'accepts identifiers with only ascii chars' do
    inspect_source(cop,
                   ['x.empty?'])
    expect(cop.offenses).to be_empty
  end

  it 'does not get confused by a byte order mark' do
    bom = "\xef\xbb\xbf"
    inspect_source(cop,
                   [bom + '# encoding: utf-8',
                    "puts 'foo'"])
    expect(cop.offenses).to be_empty
  end

  it 'does not get confused by an empty file' do
    inspect_source(cop,
                   [''])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubocop-0.28.0 spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubocop-0.27.1 spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubocop-0.27.0 spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubocop-0.26.1 spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubocop-0.26.0 spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubocop-0.25.0 spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubocop-0.24.1 spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubocop-0.24.0 spec/rubocop/cop/style/ascii_identifiers_spec.rb
rubocop-0.23.0 spec/rubocop/cop/style/ascii_identifiers_spec.rb