Sha256: 15a612b5b1e4bc65e7128d30d446303f679168201462f7cba179a5341d2fead1

Contents?: true

Size: 1.42 KB

Versions: 2

Compression:

Stored size: 1.42 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe Rubocop::Cop::Style::SpaceAfterMethodName do
  subject(:cop) { described_class.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

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rubocop-0.14.1 spec/rubocop/cop/style/space_after_method_name_spec.rb
rubocop-0.14.0 spec/rubocop/cop/style/space_after_method_name_spec.rb