Sha256: c74a1a6a534d5ab2a46aa447a1502c7e665869ebfbf7ff8460dc93592c94d8a7

Contents?: true

Size: 597 Bytes

Versions: 4

Compression:

Stored size: 597 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

  it 'registers an offense for an unless with else' do
    inspect_source(cop, ['unless x',
                         '  a = 1',
                         'else',
                         '  a = 0',
                         'end'])
    expect(cop.offenses.size).to eq(1)
  end

  it 'accepts an unless without else' do
    inspect_source(cop, ['unless x',
                         '  a = 1',
                         'end'])
    expect(cop.offenses).to be_empty
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.22.0 spec/rubocop/cop/style/unless_else_spec.rb
rubocop-0.21.0 spec/rubocop/cop/style/unless_else_spec.rb
rubocop-0.20.1 spec/rubocop/cop/style/unless_else_spec.rb
rubocop-0.20.0 spec/rubocop/cop/style/unless_else_spec.rb