Sha256: 62f850206c4d01f76d7948d289fa003cd2b79e7567676132f12aa93d19a8dde5

Contents?: true

Size: 1021 Bytes

Versions: 4

Compression:

Stored size: 1021 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    module Style
      describe Blocks do
        let(:blocks) { Blocks.new }

        it 'registers an offence for a multiline block with braces' do
          inspect_source(blocks, ['each { |x|',
                                  '}'])
          expect(blocks.messages).to eq([Blocks::MULTI_LINE_MSG])
        end

        it 'accepts a multiline block with do-end' do
          inspect_source(blocks, ['each do |x|',
                                  'end'])
          expect(blocks.offences.map(&:message)).to be_empty
        end

        it 'registers an offence for a single line block with do-end' do
          inspect_source(blocks, ['each do |x| end'])
          expect(blocks.messages).to eq([Blocks::SINGLE_LINE_MSG])
        end

        it 'accepts a single line block with braces' do
          inspect_source(blocks, ['each { |x| }'])
          expect(blocks.offences.map(&:message)).to be_empty
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
rubocop-0.10.0 spec/rubocop/cops/style/blocks_spec.rb
rubocop-0.9.1 spec/rubocop/cops/style/blocks_spec.rb
sabat-rubocop-0.9.0 spec/rubocop/cops/style/blocks_spec.rb
rubocop-0.9.0 spec/rubocop/cops/style/blocks_spec.rb