Sha256: f123cc08ecfd430e2f302a56a1c4b9ac036a9cdc33483c675085a84540e5eca7
Contents?: true
Size: 1.46 KB
Versions: 2
Compression:
Stored size: 1.46 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe SpecialGlobalVars do subject(:cop) { described_class.new } it 'registers an offence for $:' do inspect_source(cop, ['puts $:']) expect(cop.offences.size).to eq(1) expect(cop.messages) .to eq(['Prefer $LOAD_PATH over $:.']) end it 'registers an offence for $"' do inspect_source(cop, ['puts $"']) expect(cop.offences.size).to eq(1) expect(cop.messages) .to eq(['Prefer $LOADED_FEATURES over $".']) end it 'registers an offence for $0' do inspect_source(cop, ['puts $0']) expect(cop.offences.size).to eq(1) expect(cop.messages) .to eq(['Prefer $PROGRAM_NAME over $0.']) end it 'registers an offence for $$' do inspect_source(cop, ['puts $$']) expect(cop.offences.size).to eq(1) expect(cop.messages) .to eq(['Prefer $PID or $PROCESS_ID from English library' + ' over $$.']) end it 'does not register an offence for backrefs like $1' do inspect_source(cop, ['puts $1']) expect(cop.offences).to be_empty end it 'auto-corrects $: to $LOAD_PATH' do new_source = autocorrect_source(cop, '$:') expect(new_source).to eq('$LOAD_PATH') 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/special_global_vars_spec.rb |
rubocop-0.13.0 | spec/rubocop/cop/style/special_global_vars_spec.rb |