Sha256: 217056f45f64cc3fcd581ab9af21d69a1ae2162b475862e666fac2ce8bfb6c10

Contents?: true

Size: 1.51 KB

Versions: 10

Compression:

Stored size: 1.51 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
    inspect_source(<<~RUBY)
      RSpec.describe "test" do
      end

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

    expect(cop.offenses.first.message).to match(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 match(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

10 entries across 10 versions & 1 rubygems

Version Path
rubocop-discourse-3.8.1 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.7.1 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.7.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.6.1 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.6.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.5.1 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.5.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.4.1 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.4.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb
rubocop-discourse-3.3.0 spec/lib/rubocop/cop/no_mixing_multisite_and_standard_specs_spec.rb