Sha256: 8e334b4e56d04467c7f6aa0cb79067a188fbaa970cc6101a67427792244070e3

Contents?: true

Size: 795 Bytes

Versions: 4

Compression:

Stored size: 795 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, ['x =~ %r(/home)',
                             'y =~ %r(etc)'])
        expect(apr.offences.map(&:message))
          .to eq([PercentR::MSG] * 2)
      end

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-0.8.3 spec/rubocop/cops/percent_r_spec.rb
rubocop-0.8.2 spec/rubocop/cops/percent_r_spec.rb
rubocop-0.8.1 spec/rubocop/cops/percent_r_spec.rb
rubocop-0.8.0 spec/rubocop/cops/percent_r_spec.rb