Sha256: 04aa6ef8773a27d6c479901aa74c9cf49a665c86a6093fbbefd76a325f68a476

Contents?: true

Size: 823 Bytes

Versions: 10

Compression:

Stored size: 823 Bytes

Contents

# frozen_string_literal: true

require "spec_helper"

RSpec.describe RuboCop::Cop::Discourse::Plugins::UseRequireRelative, :config do
  subject(:cop) { described_class.new(config) }

  let(:config) { RuboCop::Config.new }

  context "when using `load`" do
    it "registers an offense" do
      expect_offense(<<~RUBY)
        load File.expand_path("../app/jobs/onceoff/voting_ensure_consistency.rb", __FILE__)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Discourse/Plugins/UseRequireRelative: Use `require_relative` instead of `load`.
      RUBY
    end
  end

  context "when using `require_relative`" do
    it "does not register an offense" do
      expect_no_offenses(<<~RUBY)
        require_relative "app/controllers/encrypt_controller.rb"
      RUBY
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
rubocop-discourse-3.9.1 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb
rubocop-discourse-3.9.0 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb
rubocop-discourse-3.8.6 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb
rubocop-discourse-3.8.5 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb
rubocop-discourse-3.8.4 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb
rubocop-discourse-3.8.3 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb
rubocop-discourse-3.8.2 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb
rubocop-discourse-3.8.1 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb
rubocop-discourse-3.7.1 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb
rubocop-discourse-3.7.0 spec/lib/rubocop/cop/plugins/use_require_relative_spec.rb