Sha256: 9179132c234af269f7e639357580d8af0410f7617c0efaf98f65ceb187258584

Contents?: true

Size: 1.54 KB

Versions: 7

Compression:

Stored size: 1.54 KB

Contents

# frozen_string_literal: true

require "spec_helper"

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

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

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

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

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

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

      describe "test2", type: :multisite do
      end

      describe "test2" do
      end
    RUBY

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

  it "does not raise an offense if there are only multisite describes" do
    offenses = 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(offenses).to eq([])
  end

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

      describe "test" do
      end

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rubocop-discourse-3.9.1 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.9.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.8.6 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.8.5 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.8.4 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.8.3 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.8.2 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb