Sha256: b6a5ae95d7a46c431693d9a57c8705b1a6147d9929eb77c99d2e44ffecb1fbf7

Contents?: true

Size: 710 Bytes

Versions: 10

Compression:

Stored size: 710 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe NewLambdaLiteral do
      let(:lambda_literal) { NewLambdaLiteral.new }

      it 'registers an offence for an old lambda call' do
        inspect_source(lambda_literal, 'file.rb', ['f = lambda { |x| x }'])
        expect(lambda_literal.offences.map(&:message)).to eq(
          ['The new lambda literal syntax is preferred in Ruby 1.9.'])
      end

      it 'accepts the new lambda literal' do
        inspect_source(lambda_literal, 'file.rb', ['lambda = ->(x) { x }',
                                              'lambda.(1)'])
        expect(lambda_literal.offences.map(&:message)).to be_empty
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rubocop-0.6.1 spec/rubocop/cops/new_lambda_literal_spec.rb
rubocop-0.6.0 spec/rubocop/cops/new_lambda_literal_spec.rb
rubocop-0.5.0 spec/rubocop/cops/new_lambda_literal_spec.rb
rubocop-0.4.6 spec/rubocop/cops/new_lambda_literal_spec.rb
rubocop-0.4.5 spec/rubocop/cops/new_lambda_literal_spec.rb
rubocop-0.4.4 spec/rubocop/cops/new_lambda_literal_spec.rb
rubocop-0.4.3 spec/rubocop/cops/new_lambda_literal_spec.rb
rubocop-0.4.2 spec/rubocop/cops/new_lambda_literal_spec.rb
rubocop-0.4.1 spec/rubocop/cops/new_lambda_literal_spec.rb
rubocop-0.4.0 spec/rubocop/cops/new_lambda_literal_spec.rb