Sha256: 3e3a136e885e0a3b7a91f4900f8b8a9a2caa0c7eb75983e94050cf671b0ef603

Contents?: true

Size: 860 Bytes

Versions: 5

Compression:

Stored size: 860 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

module Rubocop
  module Cop
    describe PercentR do
      let(:apr) { PercentR.new }

      it 'registers an offence for %r with zero or one slash in regexp' do
        inspect_source(apr, 'file.rb', ['x =~ %r(/home)',
                                        'y =~ %r(etc)'])
        expect(apr.offences.map(&:message))
          .to eq([PercentR::ERROR_MESSAGE] * 2)
      end

      it 'accepts %r with at least two slashes in regexp' do
        inspect_source(apr, 'file.rb', ['x =~ %r(/home/)',
                                        'y =~ %r(/////)'])
        expect(apr.offences.map(&:message)).to be_empty
      end

      it 'accepts slash delimiters for regexp' do
        inspect_source(apr, 'file.rb', ['x =~ /\/home/'])
        expect(apr.offences.map(&:message)).to be_empty
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rubocop-0.7.2 spec/rubocop/cops/percent_r_spec.rb
rubocop-0.7.1 spec/rubocop/cops/percent_r_spec.rb
rubocop-0.7.0 spec/rubocop/cops/percent_r_spec.rb
rubocop-0.6.1 spec/rubocop/cops/percent_r_spec.rb
rubocop-0.6.0 spec/rubocop/cops/percent_r_spec.rb