Class: DevDocCopDriftTest

Inherits:
ActiveSupport::TestCase
  • Object
show all
Defined in:
lib/dev_doc/test/lints/cop_drift_test.rb

Overview

Suite-failing tripwire (see DevDoc::Test::Lints::CopDriftCheck for the doctrine): fails until every registered DevDoc cop is mentioned by full name in the project's .rubocop.yml.

Require from the project's test helper (Rails test env):

require 'dev_doc/test/lints/cop_drift_test'

The superclass reference is deliberately UNGUARDED: consumers are Rails projects, so if ActiveSupport isn't loaded yet the require fails loudly (fix the require order) instead of silently skipping the tripwire. Opt out of a single run with SKIP_COP_DRIFT=1.

Instance Method Summary collapse

Instance Method Details

#test_every_dev_doc_cop_is_mentioned_in_rubocop_ymlObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/dev_doc/test/lints/cop_drift_test.rb', line 16

def test_every_dev_doc_cop_is_mentioned_in_rubocop_yml
  skip 'opted out via SKIP_COP_DRIFT' if ENV['SKIP_COP_DRIFT'] == '1'

  output = `bundle exec rubocop --show-cops 2>/dev/null`
  assert output.match?(DevDoc::Test::Lints::CopDriftCheck::COP_NAME),
         'no DevDoc cops parsed from `rubocop --show-cops` — did the command fail, ' \
         'or is the rubocop-dev_doc plugin not loaded in .rubocop.yml?'

  unmentioned = DevDoc::Test::Lints::CopDriftCheck.unmentioned_cops(output, project_rubocop_config)
  assert_empty unmentioned, drift_message(unmentioned)
end