Sha256: 0023cf3bb8103632082add85ec501a6f29e0bbd8abc6017c0e09f534fa0bae76

Contents?: true

Size: 892 Bytes

Versions: 3

Compression:

Stored size: 892 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe DefWithParentheses do
      let (:def_par) { DefWithParentheses.new }

      it 'reports an offence for def with empty parens' do
        src = ['def func()',
               'end']
        inspect_source(def_par, '', src)
        def_par.offences.map(&:message).should ==
          ["Omit the parentheses in defs when the method doesn't accept any " +
           'arguments.']
      end

      it 'accepts def with arg and parens' do
        src = ['def func(a)',
               'end']
        inspect_source(def_par, '', src)
        def_par.offences.map(&:message).should == []
      end

      it 'accepts empty parentheses in one liners' do
        src = ["def to_s() join '/' end"]
        inspect_source(def_par, '', src)
        def_par.offences.map(&:message).should == []
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rubocop-0.3.2 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.3.1 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.3.0 spec/rubocop/cops/def_with_parentheses_spec.rb