diff --git a/CHANGELOG.md b/CHANGELOG.md index 23043c32..3d44ea18 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master (unrealeased) +- Add support for RSpec aliases detection when linting specs using `let_it_be`/`before_all` with `rubocop-rspec` 2.0 ([@pirj][]) + ## 0.12.2 (2020-09-03) - Execute Minitest `before_all` in the context of the current test object. ([@palkan][]) diff --git a/config/rubocop-rspec.yml b/config/rubocop-rspec.yml new file mode 100644 index 00000000..f054f16d --- /dev/null +++ b/config/rubocop-rspec.yml @@ -0,0 +1,6 @@ +RSpec: + Language: + Helpers: + - let_it_be + Hooks: + - before_all diff --git a/docs/README.md b/docs/README.md index c9f51a3d..2d546f3a 100644 --- a/docs/README.md +++ b/docs/README.md @@ -88,6 +88,16 @@ Supported Ruby versions: Supported RSpec version (for RSpec features only): >= 3.5.0 (for older RSpec version use TestProf < 0.8.0). +### Linting with RuboCop RSpec + +When you lint your RSpec spec files with `rubocop-rspec`, it will fail to properly detect RSpec constructs that TestProf defines, `let_it_be` and `before_all`. +Make sure to use `rubocop-rspec` 2.0 or newer and add the following to your `.rubocop.yml`: + +```yaml +inherit_gem: + test-prof: config/rubocop-rspec.yml +``` + ## Profilers - [RubyProf Integration](./profilers/ruby_prof.md) diff --git a/test-prof.gemspec b/test-prof.gemspec index b751f152..d711e1f5 100644 --- a/test-prof.gemspec +++ b/test-prof.gemspec @@ -26,7 +26,7 @@ Gem::Specification.new do |spec| "source_code_uri" => "http://github.com/test-prof/test-prof" } - spec.files = Dir.glob("lib/**/*") + Dir.glob("config/**/*") + Dir.glob("assets/**/*") + %w[README.md LICENSE.txt CHANGELOG.md] + spec.files = Dir.glob("lib/**/*") + Dir.glob("config/**/*") + Dir.glob("assets/**/*") + %w[README.md LICENSE.txt CHANGELOG.md] + %w[config/rubocop-rspec.yml] spec.require_paths = ["lib"]