Sha256: 98098e67cad36144742ceead181957a8efe5ca8098ff979482199656939365c8

Contents?: true

Size: 600 Bytes

Versions: 13

Compression:

Stored size: 600 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

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

      it 'registers an offence for a single line block with do-end' do
        inspect_source(blocks, '', ['each do |x| end'])
        expect(blocks.offences.map(&:message)).to eq(
          ['Prefer {...} over do...end for single-line blocks.'])
      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

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rubocop-0.7.2 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.7.1 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.7.0 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.6.1 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.6.0 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.5.0 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.4.6 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.4.5 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.4.4 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.4.3 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.4.2 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.4.1 spec/rubocop/cops/single_line_blocks_spec.rb
rubocop-0.4.0 spec/rubocop/cops/single_line_blocks_spec.rb