Sha256: 11ec92065e0635b5e0ebd0fda522c9c7d45faafaad306f1e33232c2d5d5e3386
Contents?: true
Size: 1.42 KB
Versions: 7
Compression:
Stored size: 1.42 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe Lambda do let(:lambda) { Lambda.new } it 'registers an offence for an old single-line lambda call' do inspect_source(lambda, ['f = lambda { |x| x }']) expect(lambda.offences.size).to eq(1) expect(lambda.messages).to eq([Lambda::SINGLE_MSG]) end it 'accepts the new lambda literal with single-line body' do inspect_source(lambda, ['lambda = ->(x) { x }', 'lambda.(1)']) expect(lambda.offences).to be_empty end it 'registers an offence for a new multi-line lambda call' do inspect_source(lambda, ['f = ->(x) do', ' x', 'end']) expect(lambda.offences.size).to eq(1) expect(lambda.messages).to eq([Lambda::MULTI_MSG]) end it 'accepts the old lambda syntax with multi-line body' do inspect_source(lambda, ['l = lambda do |x|', ' x', 'end']) expect(lambda.offences).to be_empty end it 'accepts the lambda call outside of block' do inspect_source(lambda, ['l = lambda.test']) expect(lambda.offences).to be_empty end end end end end
Version data entries
7 entries across 7 versions & 2 rubygems