Sha256: ef738e9f8d952762ab24ef0b6f2bb4a44795edc2679f1912f6db0d9c4c414b0f

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

# encoding: utf-8

require 'spec_helper'

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

        it 'registers an offence for def with space before the parenthesis' do
          inspect_source(cop,
                         ['def func (x)',
                          '  a',
                          'end'])
          expect(cop.offences).to have(1).item
        end

        it 'registers an offence for defs with space before the parenthesis' do
          inspect_source(cop,
                         ['def self.func (x)',
                          '  a',
                          'end'])
          expect(cop.offences).to have(1).item
        end

        it 'accepts a def without arguments' do
          inspect_source(cop,
                         ['def func',
                          '  a',
                          'end'])
          expect(cop.offences).to be_empty
        end

        it 'accepts a defs without arguments' do
          inspect_source(cop,
                         ['def self.func',
                          '  a',
                          'end'])
          expect(cop.offences).to be_empty
        end

        it 'accepts a def with arguments but no parentheses' do
          inspect_source(cop,
                         ['def func x',
                          '  a',
                          'end'])
          expect(cop.offences).to be_empty
        end

        it 'accepts a defs with arguments but no parentheses' do
          inspect_source(cop,
                         ['def self.func x',
                          '  a',
                          'end'])
          expect(cop.offences).to be_empty
        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/space_after_method_name_spec.rb
rubocop-0.13.0 spec/rubocop/cop/style/space_after_method_name_spec.rb