Sha256: a943e73d9cc694ab04c4688f2eb82d9b3fcfe8b86c80b1363e851ab7d1cee987

Contents?: true

Size: 861 Bytes

Versions: 4

Compression:

Stored size: 861 Bytes

Contents

# frozen_string_literal: true

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

  it 'ignores describes with only a class' do
    expect_no_offenses('describe Some::Class do; end')
  end

  it 'enforces non-method names' do
    expect_offense(<<-RUBY)
      describe Some::Class, 'nope', '.incorrect_usage' do
                            ^^^^^^ The second argument to describe should be the method being tested. '#instance' or '.class'.
      end
    RUBY
  end

  it 'skips methods starting with a . or #' do
    expect_no_offenses(<<-RUBY)
      describe Some::Class, '.asdf' do
      end

      describe Some::Class, '#fdsa' do
      end
    RUBY
  end

  it 'skips specs not having a string second argument' do
    expect_no_offenses(<<-RUBY)
      describe Some::Class, :config do
      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/describe_method_spec.rb
rubocop-rspec-1.34.1 spec/rubocop/cop/rspec/describe_method_spec.rb
rubocop-rspec-1.34.0 spec/rubocop/cop/rspec/describe_method_spec.rb
rubocop-rspec-1.33.0 spec/rubocop/cop/rspec/describe_method_spec.rb