Sha256: 2da0d7299a51e3ae6b50b828251df3cc27f3af58b64da1755bef53fc20dcbbc8

Contents?: true

Size: 698 Bytes

Versions: 1

Compression:

Stored size: 698 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 }'])
        lambda_literal.offences.map(&:message).should ==
          ['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)'])
        lambda_literal.offences.map(&:message).should == []
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubocop-0.3.2 spec/rubocop/cops/new_lambda_literal_spec.rb