Sha256: 096d260e38943aa5d462ec636bbbaca45997f7e81da46340a95e358c9f895ac8

Contents?: true

Size: 1.87 KB

Versions: 8

Compression:

Stored size: 1.87 KB

Contents

# encoding: utf-8

require 'spec_helper'

describe RuboCop::Cop::Lint::Debugger do
  subject(:cop) { described_class.new  }

  it 'reports an offense for a debugger call' do
    src = ['debugger']
    inspect_source(cop, src)
    expect(cop.offenses.size).to eq(1)
    expect(cop.messages).to eq(['Remove debugger entry point `debugger`.'])
    expect(cop.highlights).to eq(['debugger'])
  end

  it 'reports an offense for a byebug call' do
    src = ['byebug']
    inspect_source(cop, src)
    expect(cop.offenses.size).to eq(1)
    expect(cop.messages).to eq(['Remove debugger entry point `byebug`.'])
    expect(cop.highlights).to eq(['byebug'])
  end

  it 'reports an offense for pry bindings' do
    src = ['binding.pry',
           'binding.remote_pry',
           'binding.pry_remote']
    inspect_source(cop, src)
    expect(cop.offenses.size).to eq(3)
    expect(cop.messages)
      .to eq(['Remove debugger entry point `binding.pry`.',
              'Remove debugger entry point `binding.remote_pry`.',
              'Remove debugger entry point `binding.pry_remote`.'])
    expect(cop.highlights).to eq(['binding.pry',
                                  'binding.remote_pry',
                                  'binding.pry_remote'])
  end

  it 'does not report an offense for non-pry binding' do
    src = ['binding.pirate']
    inspect_source(cop, src)
    expect(cop.offenses).to be_empty
  end

  %w(debugger byebug pry remote_pry pry_remote).each do |comment|
    it "does not report an offense for #{comment} in comments" do
      src = ["# #{comment}"]
      inspect_source(cop, src)
      expect(cop.offenses).to be_empty
    end
  end

  %w(debugger byebug pry remote_pry pry_remote).each do |method_name|
    it "does not report an offense for a #{method_name} method" do
      src = ["code.#{method_name}"]
      inspect_source(cop, src)
      expect(cop.offenses).to be_empty
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
rubyjobbuilderdsl-0.0.2 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/lint/debugger_spec.rb
rubyjobbuilderdsl-0.0.1 vendor/bundle/ruby/2.1.0/gems/rubocop-0.26.0/spec/rubocop/cop/lint/debugger_spec.rb
rubocop-0.28.0 spec/rubocop/cop/lint/debugger_spec.rb
rubocop-0.27.1 spec/rubocop/cop/lint/debugger_spec.rb
rubocop-0.27.0 spec/rubocop/cop/lint/debugger_spec.rb
rubocop-0.26.1 spec/rubocop/cop/lint/debugger_spec.rb
rubocop-0.26.0 spec/rubocop/cop/lint/debugger_spec.rb
rubocop-0.25.0 spec/rubocop/cop/lint/debugger_spec.rb