Sha256: aecc7df5c50f5351ac27461740f16c025f82f99c9f8a2a7d415eaef820406969

Contents?: true

Size: 1.52 KB

Versions: 7

Compression:

Stored size: 1.52 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

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

  let(:config) do
    RuboCop::Config.new
  end

  it "raises an offense if there are multisite and standard top-level describes" do
    inspect_source(<<~RUBY)
      RSpec.describe "test" do
      end

      describe "test2", type: :multisite do
      end
    RUBY

    expect(cop.offenses.first.message).to eq(described_class::MSG)
  end

  it "raises an offense if there are multiple multisite and standard top-level describes" do
    inspect_source(<<~RUBY)
      describe "test", type: :multisite do
      end

      describe "test2", type: :multisite do
      end

      describe "test2" do
      end
    RUBY

    expect(cop.offenses.first.message).to eq(described_class::MSG)
  end

  it "does not raise an offense if there are only multisite describes" do
    inspect_source(<<~RUBY)
      require "foo"

      describe "test", type: :multisite do
        describe "inner-test" do
          it "test" do
          end
        end
      end

      RSpec.describe "test2", type: :multisite do
      end
    RUBY

    expect(cop.offenses).to eq([])
  end

  it "does not raise an offense if there are only standard describes" do
    inspect_source(<<~RUBY)
      require "rails_helper"

      describe "test" do
      end

      describe "test2" do
        RSpec.describe "inner-test" do
        end
      end
    RUBY

    expect(cop.offenses).to eq([])
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubocop-discourse-3.1.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.0.3 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.0.2 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.0.1 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-2.6.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-2.5.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb