Sha256: 97d0aa3abbe0dc9a01bc35e675fc75e9fee0d55fd6eb23cd58ac66cea5243e36

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe DefWithoutParentheses do
        subject(:cop) { described_class.new }

        it 'reports an offence for def with parameters but no parens' do
          src = ['def func a, b',
                 'end']
          inspect_source(cop, src)
          expect(cop.offences.size).to eq(1)
        end

        it 'reports an offence for class def with parameters but no parens' do
          src = ['def Test.func a, b',
                 'end']
          inspect_source(cop, src)
          expect(cop.offences.size).to eq(1)
        end

        it 'accepts def with no args and no parens' do
          src = ['def func',
                 'end']
          inspect_source(cop, src)
          expect(cop.offences).to be_empty
        end

        it 'auto-adds required parens' do
          new_source = autocorrect_source(cop, 'def test param; end')
          expect(new_source).to eq('def test (param); end')
        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/def_without_parentheses_spec.rb
rubocop-0.13.0 spec/rubocop/cop/style/def_without_parentheses_spec.rb