Skip to content

Users should be able to globally configure example group and includes language #333

@backus

Description

@backus

As described in #321, if a user has some custom DSL in their specs then a handful of cops produce false positives. For example

RSpec.describe Authentication do
  role :user do
    it 'accepts the request' do
      expect(request).to be_accepted
    end
  end

  role :admin do
    it 'accepts the request' do
      expect(request).to be_accepted
    end
  end
end

In RSpec you can do something like this

RSpec.configure do |c|
  c.alias_example_group_to :detail, :detailed => true
end

and of course since it is plain old ruby you can do something like this (not sure if this would specifically work)

module AuthenticationSpecs
  def role(type)
    context "when user is a #{type}" do
      let(:user) { create(type) }

      yield
    end
  end
end

RSpec.configure do |config|
  config.extend(AuthenticationSpecs)
end

To handle stuff like this properly, we should support something like this

AllCops:
  RSpec:
    CustomExampleGroups:
    - detail
    - role

which all cops would respect.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions