Sha256: 1f8024d1f4d38aaf5e62c8cd8662b03086413f2a7e213c74864392b3d95123de

Contents?: true

Size: 911 Bytes

Versions: 13

Compression:

Stored size: 911 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)
        expect(def_par.offences.map(&:message)).to eq(
          ["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)
        expect(def_par.offences.map(&:message)).to be_empty
      end

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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rubocop-0.7.2 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.7.1 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.7.0 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.6.1 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.6.0 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.5.0 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.4.6 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.4.5 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.4.4 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.4.3 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.4.2 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.4.1 spec/rubocop/cops/def_with_parentheses_spec.rb
rubocop-0.4.0 spec/rubocop/cops/def_with_parentheses_spec.rb