Sha256: 12397209cd6f499bbbd65d4caef6bf12b08b6a06b5ae05f9c41f0c171bd7891c

Contents?: true

Size: 668 Bytes

Versions: 2

Compression:

Stored size: 668 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe ClassVars do
        subject(:cop) { described_class.new }

        it 'registers an offence for class variable declaration' do
          inspect_source(cop, ['class TestClass; @@test = 10; end'])
          expect(cop.offences.size).to eq(1)
          expect(cop.messages)
            .to eq(['Replace class var @@test with a class instance var.'])
        end

        it 'does not register an offence for class variable usage' do
          inspect_source(cop, ['@@test.test(20)'])
          expect(cop.offences).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/class_vars_spec.rb
rubocop-0.13.0 spec/rubocop/cop/style/class_vars_spec.rb