Sha256: e8438d86113333f5fea686ab911e144220938f9b550b841ff08bbbcc551f874a

Contents?: true

Size: 1.29 KB

Versions: 4

Compression:

Stored size: 1.29 KB

Contents

# frozen_string_literal: true

RSpec.describe RuboCop::Cop::RSpec::MissingExampleGroupArgument do
  subject(:cop) { described_class.new }

  it 'accepts describe with an argument' do
    expect_no_offenses(<<-RUBY)
      describe FooClass do
      end

      RSpec.describe FooClass do
      end
    RUBY
  end

  it 'accepts methods with a name like an example block' do
    expect_no_offenses(<<-RUBY)
      Scenario.context do
        'static'
      end
    RUBY
  end

  it 'checks first argument of describe' do
    expect_offense(<<-RUBY)
      describe do
      ^^^^^^^^^^^ The first argument to `describe` should not be empty.
      end

      RSpec.describe do
      ^^^^^^^^^^^^^^^^^ The first argument to `describe` should not be empty.
      end
    RUBY
  end

  it 'checks first argument of nested describe' do
    expect_offense(<<-RUBY)
      describe FooClass do
        describe do
        ^^^^^^^^^^^ The first argument to `describe` should not be empty.
        end

        RSpec.describe do
        ^^^^^^^^^^^^^^^^^ The first argument to `describe` should not be empty.
        end
      end
    RUBY
  end

  it 'checks first argument of context' do
    expect_offense(<<-RUBY)
      context do
      ^^^^^^^^^^ The first argument to `context` should not be empty.
      end
    RUBY
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rubocop-rspec-1.35.0 spec/rubocop/cop/rspec/missing_example_group_argument_spec.rb
rubocop-rspec-1.34.1 spec/rubocop/cop/rspec/missing_example_group_argument_spec.rb
rubocop-rspec-1.34.0 spec/rubocop/cop/rspec/missing_example_group_argument_spec.rb
rubocop-rspec-1.33.0 spec/rubocop/cop/rspec/missing_example_group_argument_spec.rb