Sha256: 0d937accc90b96bd3d8acd0a8ec9c9055c6d3df59d4fa46e735aa79b2436ca67
Contents?: true
Size: 1.67 KB
Versions: 7
Compression:
Stored size: 1.67 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe NumericLiterals do let(:num) { NumericLiterals.new } it 'registers an offence for a long integer without underscores' do inspect_source(num, ['a = 123456']) expect(num.offences.map(&:message)).to eq( ['Add underscores to large numeric literals to improve their ' + 'readability.']) end it 'registers an offence for an integer with not enough underscores' do inspect_source(num, ['a = 123456_789000']) expect(num.offences.map(&:message)).to eq( ['Add underscores to large numeric literals to improve their ' + 'readability.']) end # it 'registers an offence for a long float without underscores' do # inspect_source(num, ['a = 1.234567']) # expect(num.offences.map(&:message)).to eq( # ['Add underscores to large numeric literals to improve their ' + # 'readability.']) # end it 'accepts long numbers with underscore' do inspect_source(num, ['a = 123_456', 'b = 1.234_56']) expect(num.offences.map(&:message)).to be_empty end it 'accepts a short integer without underscore' do inspect_source(num, ['a = 123']) expect(num.offences.map(&:message)).to be_empty end it 'accepts short numbers without underscore' do inspect_source(num, ['a = 123', 'b = 123.456']) expect(num.offences.map(&:message)).to be_empty end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems