Sha256: cf67c6ca76fa29000788998440b2f68e02d6172d57615e9cc52414a988f01cb8
Contents?: true
Size: 1.39 KB
Versions: 2
Compression:
Stored size: 1.39 KB
Contents
# encoding: utf-8 require 'spec_helper' module Rubocop module Cop module Style describe Lambda do subject(: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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rubocop-0.13.1 | spec/rubocop/cop/style/lambda_spec.rb |
rubocop-0.13.0 | spec/rubocop/cop/style/lambda_spec.rb |