Sha256: 56b8f07c430e3dec4eac5abfb999fc62721c369ea00564137ce4e6ce4dfc4793
Contents?: true
Size: 1.44 KB
Versions: 3
Compression:
Stored size: 1.44 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop describe VariableInterpolation do let(:vi) { VariableInterpolation.new } it 'registers an offence for interpolated global variables' do inspect_source(vi, 'file.rb', ['puts "this is a #$test"']) expect(vi.offences.size).to eq(1) expect(vi.offences.map(&:message)) .to eq(['Replace interpolated var $test with expression #{$test}.']) end it 'registers an offence for interpolated instance variables' do inspect_source(vi, 'file.rb', ['puts "this is a #@test"']) expect(vi.offences.size).to eq(1) expect(vi.offences.map(&:message)) .to eq(['Replace interpolated var @test with expression #{@test}.']) end it 'registers an offence for interpolated class variables' do inspect_source(vi, 'file.rb', ['puts "this is a #@@t"']) expect(vi.offences.size).to eq(1) expect(vi.offences.map(&:message)) .to eq(['Replace interpolated var @@t with expression #{@@t}.']) end it 'does not register an offence for variables in expressions' do inspect_source(vi, 'file.rb', ['puts "this is a #{@test}"']) expect(vi.offences).to be_empty end end end end
Version data entries
3 entries across 3 versions & 1 rubygems