rubocop-rspec 1.35.0 → 1.36.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (116) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +12 -0
  3. data/config/default.yml +11 -0
  4. data/lib/rubocop/cop/rspec/capybara/current_path_expectation.rb +16 -0
  5. data/lib/rubocop/cop/rspec/context_method.rb +53 -0
  6. data/lib/rubocop/cop/rspec/describe_class.rb +7 -10
  7. data/lib/rubocop/cop/rspec/described_class.rb +29 -1
  8. data/lib/rubocop/cop/rspec/empty_line_after_example.rb +87 -0
  9. data/lib/rubocop/cop/rspec/example_wording.rb +28 -12
  10. data/lib/rubocop/cop/rspec/expect_change.rb +8 -8
  11. data/lib/rubocop/cop/rspec/factory_bot/attribute_defined_statically.rb +2 -9
  12. data/lib/rubocop/cop/rspec/focus.rb +5 -10
  13. data/lib/rubocop/cop/rspec/instance_variable.rb +2 -1
  14. data/lib/rubocop/cop/rspec/multiple_expectations.rb +13 -21
  15. data/lib/rubocop/cop/rspec/pending.rb +19 -25
  16. data/lib/rubocop/cop/rspec_cops.rb +2 -0
  17. data/lib/rubocop/rspec/version.rb +1 -1
  18. metadata +7 -198
  19. data/Gemfile +0 -11
  20. data/Rakefile +0 -87
  21. data/rubocop-rspec.gemspec +0 -49
  22. data/spec/project/changelog_spec.rb +0 -76
  23. data/spec/project/default_config_spec.rb +0 -76
  24. data/spec/project/project_requires_spec.rb +0 -20
  25. data/spec/rubocop/cop/rspec/align_left_let_brace_spec.rb +0 -51
  26. data/spec/rubocop/cop/rspec/align_right_let_brace_spec.rb +0 -51
  27. data/spec/rubocop/cop/rspec/any_instance_spec.rb +0 -32
  28. data/spec/rubocop/cop/rspec/around_block_spec.rb +0 -121
  29. data/spec/rubocop/cop/rspec/be_eql_spec.rb +0 -81
  30. data/spec/rubocop/cop/rspec/be_spec.rb +0 -35
  31. data/spec/rubocop/cop/rspec/before_after_all_spec.rb +0 -52
  32. data/spec/rubocop/cop/rspec/capybara/current_path_expectation_spec.rb +0 -65
  33. data/spec/rubocop/cop/rspec/capybara/feature_methods_spec.rb +0 -130
  34. data/spec/rubocop/cop/rspec/context_wording_spec.rb +0 -94
  35. data/spec/rubocop/cop/rspec/cop_spec.rb +0 -95
  36. data/spec/rubocop/cop/rspec/describe_class_spec.rb +0 -168
  37. data/spec/rubocop/cop/rspec/describe_method_spec.rb +0 -34
  38. data/spec/rubocop/cop/rspec/describe_symbol_spec.rb +0 -44
  39. data/spec/rubocop/cop/rspec/described_class_spec.rb +0 -352
  40. data/spec/rubocop/cop/rspec/dialect_spec.rb +0 -78
  41. data/spec/rubocop/cop/rspec/empty_example_group_spec.rb +0 -93
  42. data/spec/rubocop/cop/rspec/empty_line_after_example_group_spec.rb +0 -121
  43. data/spec/rubocop/cop/rspec/empty_line_after_final_let_spec.rb +0 -239
  44. data/spec/rubocop/cop/rspec/empty_line_after_hook_spec.rb +0 -133
  45. data/spec/rubocop/cop/rspec/empty_line_after_subject_spec.rb +0 -94
  46. data/spec/rubocop/cop/rspec/example_length_spec.rb +0 -78
  47. data/spec/rubocop/cop/rspec/example_without_description_spec.rb +0 -92
  48. data/spec/rubocop/cop/rspec/example_wording_spec.rb +0 -173
  49. data/spec/rubocop/cop/rspec/expect_actual_spec.rb +0 -150
  50. data/spec/rubocop/cop/rspec/expect_change_spec.rb +0 -86
  51. data/spec/rubocop/cop/rspec/expect_in_hook_spec.rb +0 -79
  52. data/spec/rubocop/cop/rspec/expect_output_spec.rb +0 -62
  53. data/spec/rubocop/cop/rspec/factory_bot/attribute_defined_statically_spec.rb +0 -208
  54. data/spec/rubocop/cop/rspec/factory_bot/create_list_spec.rb +0 -171
  55. data/spec/rubocop/cop/rspec/file_path_spec.rb +0 -200
  56. data/spec/rubocop/cop/rspec/focus_spec.rb +0 -139
  57. data/spec/rubocop/cop/rspec/hook_argument_spec.rb +0 -173
  58. data/spec/rubocop/cop/rspec/hooks_before_examples_spec.rb +0 -150
  59. data/spec/rubocop/cop/rspec/implicit_block_expectation_spec.rb +0 -135
  60. data/spec/rubocop/cop/rspec/implicit_expect_spec.rb +0 -102
  61. data/spec/rubocop/cop/rspec/implicit_subject_spec.rb +0 -188
  62. data/spec/rubocop/cop/rspec/instance_spy_spec.rb +0 -61
  63. data/spec/rubocop/cop/rspec/instance_variable_spec.rb +0 -95
  64. data/spec/rubocop/cop/rspec/invalid_predicate_matcher_spec.rb +0 -39
  65. data/spec/rubocop/cop/rspec/it_behaves_like_spec.rb +0 -47
  66. data/spec/rubocop/cop/rspec/iterated_expectation_spec.rb +0 -82
  67. data/spec/rubocop/cop/rspec/leading_subject_spec.rb +0 -119
  68. data/spec/rubocop/cop/rspec/leaky_constant_declaration_spec.rb +0 -91
  69. data/spec/rubocop/cop/rspec/let_before_examples_spec.rb +0 -137
  70. data/spec/rubocop/cop/rspec/let_setup_spec.rb +0 -66
  71. data/spec/rubocop/cop/rspec/message_chain_spec.rb +0 -23
  72. data/spec/rubocop/cop/rspec/message_expectation_spec.rb +0 -45
  73. data/spec/rubocop/cop/rspec/message_spies_spec.rb +0 -151
  74. data/spec/rubocop/cop/rspec/missing_example_group_argument_spec.rb +0 -57
  75. data/spec/rubocop/cop/rspec/multiple_describes_spec.rb +0 -30
  76. data/spec/rubocop/cop/rspec/multiple_expectations_spec.rb +0 -261
  77. data/spec/rubocop/cop/rspec/multiple_subjects_spec.rb +0 -83
  78. data/spec/rubocop/cop/rspec/named_subject_spec.rb +0 -123
  79. data/spec/rubocop/cop/rspec/nested_groups_spec.rb +0 -81
  80. data/spec/rubocop/cop/rspec/not_to_not_spec.rb +0 -77
  81. data/spec/rubocop/cop/rspec/overwriting_setup_spec.rb +0 -91
  82. data/spec/rubocop/cop/rspec/pending_spec.rb +0 -186
  83. data/spec/rubocop/cop/rspec/predicate_matcher_spec.rb +0 -354
  84. data/spec/rubocop/cop/rspec/rails/http_status_spec.rb +0 -90
  85. data/spec/rubocop/cop/rspec/receive_counts_spec.rb +0 -138
  86. data/spec/rubocop/cop/rspec/receive_never_spec.rb +0 -57
  87. data/spec/rubocop/cop/rspec/repeated_description_spec.rb +0 -76
  88. data/spec/rubocop/cop/rspec/repeated_example_spec.rb +0 -74
  89. data/spec/rubocop/cop/rspec/return_from_stub_spec.rb +0 -289
  90. data/spec/rubocop/cop/rspec/scattered_let_spec.rb +0 -28
  91. data/spec/rubocop/cop/rspec/scattered_setup_spec.rb +0 -98
  92. data/spec/rubocop/cop/rspec/shared_context_spec.rb +0 -137
  93. data/spec/rubocop/cop/rspec/shared_examples_spec.rb +0 -75
  94. data/spec/rubocop/cop/rspec/single_argument_message_chain_spec.rb +0 -178
  95. data/spec/rubocop/cop/rspec/subject_stub_spec.rb +0 -293
  96. data/spec/rubocop/cop/rspec/unspecified_exception_spec.rb +0 -177
  97. data/spec/rubocop/cop/rspec/verified_doubles_spec.rb +0 -86
  98. data/spec/rubocop/cop/rspec/void_expect_spec.rb +0 -49
  99. data/spec/rubocop/cop/rspec/yield_spec.rb +0 -81
  100. data/spec/rubocop/rspec/config_formatter_spec.rb +0 -52
  101. data/spec/rubocop/rspec/description_extractor_spec.rb +0 -63
  102. data/spec/rubocop/rspec/example_group_spec.rb +0 -44
  103. data/spec/rubocop/rspec/example_spec.rb +0 -62
  104. data/spec/rubocop/rspec/hook_spec.rb +0 -53
  105. data/spec/rubocop/rspec/language/selector_set_spec.rb +0 -53
  106. data/spec/rubocop/rspec/util/one_spec.rb +0 -23
  107. data/spec/rubocop/rspec/wording_spec.rb +0 -52
  108. data/spec/shared/autocorrect_behavior.rb +0 -9
  109. data/spec/shared/detects_style_behavior.rb +0 -9
  110. data/spec/shared/smoke_test_examples.rb +0 -27
  111. data/spec/smoke_tests/empty_spec.rb +0 -0
  112. data/spec/smoke_tests/factory_bot_spec.rb +0 -11
  113. data/spec/smoke_tests/no_tests_spec.rb +0 -4
  114. data/spec/smoke_tests/weird_rspec_spec.rb +0 -233
  115. data/spec/spec_helper.rb +0 -42
  116. data/spec/support/expect_offense.rb +0 -19
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- $LOAD_PATH.unshift File.expand_path('lib', __dir__)
4
- require 'rubocop/rspec/version'
5
-
6
- Gem::Specification.new do |spec|
7
- spec.name = 'rubocop-rspec'
8
- spec.summary = 'Code style checking for RSpec files'
9
- spec.description = <<-DESCRIPTION
10
- Code style checking for RSpec files.
11
- A plugin for the RuboCop code style enforcing & linting tool.
12
- DESCRIPTION
13
- spec.homepage = 'https://github.com/rubocop-hq/rubocop-rspec'
14
- spec.authors = ['John Backus', 'Ian MacLeod', 'Nils Gemeinhardt']
15
- spec.email = [
16
- 'johncbackus@gmail.com',
17
- 'ian@nevir.net',
18
- 'git@nilsgemeinhardt.de'
19
- ]
20
- spec.licenses = ['MIT']
21
-
22
- spec.version = RuboCop::RSpec::Version::STRING
23
- spec.platform = Gem::Platform::RUBY
24
- spec.required_ruby_version = '>= 2.3.0'
25
-
26
- spec.require_paths = ['lib']
27
- spec.files = Dir[
28
- '{config,lib,spec}/**/*',
29
- '*.md',
30
- '*.gemspec',
31
- 'Gemfile',
32
- 'Rakefile'
33
- ]
34
- spec.test_files = spec.files.grep(%r{^spec/})
35
- spec.extra_rdoc_files = ['MIT-LICENSE.md', 'README.md']
36
-
37
- spec.metadata = {
38
- 'changelog_uri' => 'https://github.com/rubocop-hq/rubocop-rspec/blob/master/CHANGELOG.md',
39
- 'documentation_uri' => 'https://rubocop-rspec.readthedocs.io/'
40
- }
41
-
42
- spec.add_runtime_dependency 'rubocop', '>= 0.60.0'
43
-
44
- spec.add_development_dependency 'rack'
45
- spec.add_development_dependency 'rake'
46
- spec.add_development_dependency 'rspec', '>= 3.4'
47
- spec.add_development_dependency 'simplecov'
48
- spec.add_development_dependency 'yard'
49
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe 'CHANGELOG.md' do
4
- subject(:changelog) { SpecHelper::ROOT.join('CHANGELOG.md').read }
5
-
6
- it 'has link definitions for all implicit links' do
7
- implicit_link_names = changelog.scan(/\[([^\]]+)\]\[\]/).flatten.uniq
8
- implicit_link_names.each do |name|
9
- expect(changelog).to include("[#{name}]: http")
10
- end
11
- end
12
-
13
- describe 'entry' do
14
- subject(:entries) { lines.grep(/^\*/).map(&:chomp) }
15
-
16
- let(:lines) { changelog.each_line }
17
-
18
- it 'has a whitespace between the * and the body' do
19
- expect(entries).to all(match(/^\* \S/))
20
- end
21
-
22
- it 'has a link to the contributors at the end' do
23
- expect(entries).to all(match(/\(\[@\S+\]\[\](?:, \[@\S+\]\[\])*\)$/))
24
- end
25
-
26
- describe 'link to related issue on github' do
27
- let(:issues) do
28
- entries.map do |entry|
29
- entry.match(/\[(?<number>[#\d]+)\]\((?<url>[^\)]+)\)/)
30
- end.compact
31
- end
32
-
33
- it 'has an issue number prefixed with #' do
34
- issues.each do |issue|
35
- expect(issue[:number]).to match(/^#\d+$/)
36
- end
37
- end
38
-
39
- it 'has a valid URL' do
40
- issues.each do |issue|
41
- number = issue[:number].gsub(/\D/, '')
42
- pattern = %r{^https://github\.com/.+/.+/(?:issues|pull)/#{number}$} # rubocop:disable LineLength
43
- expect(issue[:url]).to match(pattern)
44
- end
45
- end
46
-
47
- it 'has a colon and a whitespace at the end' do
48
- entries_including_issue_link = entries.select do |entry|
49
- entry.match(/^\*\s*\[/)
50
- end
51
-
52
- expect(entries_including_issue_link).to all(include('): '))
53
- end
54
- end
55
-
56
- describe 'body' do
57
- let(:bodies) do
58
- entries.map do |entry|
59
- entry
60
- .sub(/^\*\s*(?:\[.+?\):\s*)?/, '')
61
- .sub(/\s*\([^\)]+\)$/, '')
62
- end
63
- end
64
-
65
- it 'does not start with a lower case' do
66
- bodies.each do |body|
67
- expect(body).not_to match(/^[a-z]/)
68
- end
69
- end
70
-
71
- it 'ends with a punctuation' do
72
- expect(bodies).to all(match(/[\.\!]$/))
73
- end
74
- end
75
- end
76
- end
@@ -1,76 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe 'config/default.yml' do
4
- subject(:default_config) do
5
- RuboCop::ConfigLoader.load_file('config/default.yml')
6
- end
7
-
8
- let(:namespaces) do
9
- {
10
- 'rspec' => 'RSpec',
11
- 'capybara' => 'Capybara',
12
- 'factory_bot' => 'FactoryBot',
13
- 'rails' => 'Rails'
14
- }
15
- end
16
-
17
- let(:cop_names) do
18
- glob = SpecHelper::ROOT.join('lib', 'rubocop', 'cop', 'rspec',
19
- '{,capybara,factory_bot,rails}', '*.rb')
20
- cop_names =
21
- Pathname.glob(glob).map do |file|
22
- file_name = file.basename('.rb').to_s
23
- cop_name = file_name.gsub(/(^|_)(.)/) { Regexp.last_match(2).upcase }
24
- namespace = namespaces[file.dirname.basename.to_s]
25
- "#{namespace}/#{cop_name}"
26
- end
27
-
28
- cop_names - %w[RSpec/Cop]
29
- end
30
-
31
- let(:config_keys) do
32
- cop_names + %w[AllCops]
33
- end
34
-
35
- def cop_configuration(config_key)
36
- cop_names.map do |cop_name|
37
- cop_config = default_config[cop_name]
38
-
39
- cop_config.fetch(config_key) do
40
- raise "Expected #{cop_name} to have #{config_key} configuration key"
41
- end
42
- end
43
- end
44
-
45
- it 'has configuration for all cops' do
46
- expect(default_config.keys).to match_array(config_keys)
47
- end
48
-
49
- it 'sorts configuration keys alphabetically' do
50
- namespaces.each do |_path, prefix|
51
- expected = config_keys.select { |key| key.start_with?(prefix) }.sort
52
- actual = default_config.keys.select { |key| key.start_with?(prefix) }
53
- actual.each_with_index do |key, idx|
54
- expect(key).to eq expected[idx]
55
- end
56
- end
57
- end
58
-
59
- it 'has descriptions for all cops' do
60
- expect(cop_configuration('Description')).to all(be_a(String))
61
- end
62
-
63
- it 'does not have newlines in cop descriptions' do
64
- cop_configuration('Description').each do |value|
65
- expect(value).not_to include("\n")
66
- end
67
- end
68
-
69
- it 'ends every description with a period' do
70
- expect(cop_configuration('Description')).to all(end_with('.'))
71
- end
72
-
73
- it 'includes Enabled: true for every cop' do
74
- expect(cop_configuration('Enabled')).to all(be(true).or(be(false)))
75
- end
76
- end
@@ -1,20 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe 'Project requires' do
4
- it 'alphabetizes cop requires' do
5
- source = SpecHelper::ROOT.join('lib', 'rubocop', 'cop', 'rspec_cops.rb')
6
- captures = source.read.scan(%r{^(require_relative 'rspec/(.*?/)?(.*?)')$})
7
-
8
- require_statements = captures.map(&:first)
9
- sorted_require_statements =
10
- captures.sort_by do |_require_statement, cop_category, name|
11
- [cop_category || 'rspec', name]
12
- end.map(&:first)
13
-
14
- aggregate_failures do
15
- # Sanity check that we actually discovered require statements.
16
- expect(captures).not_to be_empty
17
- expect(require_statements).to eql(sorted_require_statements)
18
- end
19
- end
20
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::AlignLeftLetBrace do
4
- subject(:cop) { described_class.new }
5
-
6
- # rubocop:disable RSpec/ExampleLength
7
- it 'registers offense for unaligned braces' do
8
- expect_offense(<<-RUBY)
9
- let(:foo) { bar }
10
- ^ Align left let brace
11
- let(:hi) { baz }
12
- ^ Align left let brace
13
- let(:blahblah) { baz }
14
-
15
- let(:thing) { ignore_this }
16
- let(:other) {
17
- ignore_this_too
18
- }
19
-
20
- describe 'blah' do
21
- let(:long_name) { thing }
22
- let(:blah) { thing }
23
- ^ Align left let brace
24
- let(:a) { thing }
25
- ^ Align left let brace
26
- end
27
- RUBY
28
-
29
- expect_correction(<<-RUBY)
30
- let(:foo) { bar }
31
- let(:hi) { baz }
32
- let(:blahblah) { baz }
33
-
34
- let(:thing) { ignore_this }
35
- let(:other) {
36
- ignore_this_too
37
- }
38
-
39
- describe 'blah' do
40
- let(:long_name) { thing }
41
- let(:blah) { thing }
42
- let(:a) { thing }
43
- end
44
- RUBY
45
- end
46
- # rubocop:enable RSpec/ExampleLength
47
-
48
- it 'works with empty file' do
49
- expect_no_offenses('')
50
- end
51
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::AlignRightLetBrace do
4
- subject(:cop) { described_class.new }
5
-
6
- # rubocop:disable RSpec/ExampleLength
7
- it 'registers offense for unaligned braces' do
8
- expect_offense(<<-RUBY)
9
- let(:foo) { a }
10
- ^ Align right let brace
11
- let(:hi) { ab }
12
- ^ Align right let brace
13
- let(:blahblah) { abcd }
14
-
15
- let(:thing) { ignore_this }
16
- let(:other) {
17
- ignore_this_too
18
- }
19
-
20
- describe 'blah' do
21
- let(:blahblah) { a }
22
- ^ Align right let brace
23
- let(:blah) { bc }
24
- ^ Align right let brace
25
- let(:a) { abc }
26
- end
27
- RUBY
28
-
29
- expect_correction(<<-RUBY)
30
- let(:foo) { a }
31
- let(:hi) { ab }
32
- let(:blahblah) { abcd }
33
-
34
- let(:thing) { ignore_this }
35
- let(:other) {
36
- ignore_this_too
37
- }
38
-
39
- describe 'blah' do
40
- let(:blahblah) { a }
41
- let(:blah) { bc }
42
- let(:a) { abc }
43
- end
44
- RUBY
45
- end
46
- # rubocop:enable RSpec/ExampleLength
47
-
48
- it 'works with empty file' do
49
- expect_no_offenses('')
50
- end
51
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::AnyInstance do
4
- subject(:cop) { described_class.new }
5
-
6
- it 'finds `allow_any_instance_of` instead of an instance double' do
7
- expect_offense(<<-RUBY)
8
- before do
9
- allow_any_instance_of(Object).to receive(:foo)
10
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid stubbing using `allow_any_instance_of`.
11
- end
12
- RUBY
13
- end
14
-
15
- it 'finds `expect_any_instance_of` instead of an instance double' do
16
- expect_offense(<<-RUBY)
17
- before do
18
- expect_any_instance_of(Object).to receive(:foo)
19
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Avoid stubbing using `expect_any_instance_of`.
20
- end
21
- RUBY
22
- end
23
-
24
- it 'finds old `any_instance` syntax instead of an instance double' do
25
- expect_offense(<<-RUBY)
26
- before do
27
- Object.any_instance.should_receive(:foo)
28
- ^^^^^^^^^^^^^^^^^^^ Avoid stubbing using `any_instance`.
29
- end
30
- RUBY
31
- end
32
- end
@@ -1,121 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::AroundBlock do
4
- subject(:cop) { described_class.new }
5
-
6
- context 'when no value is yielded' do
7
- it 'registers an offense' do
8
- expect_offense(<<-RUBY)
9
- around do
10
- ^^^^^^^^^ Test object should be passed to around block.
11
- do_something
12
- end
13
- RUBY
14
- end
15
- end
16
-
17
- context 'when the hook is scoped with a symbol' do
18
- it 'registers an offense' do
19
- expect_offense(<<-RUBY)
20
- around(:each) do
21
- ^^^^^^^^^^^^^^^^ Test object should be passed to around block.
22
- do_something
23
- end
24
- RUBY
25
- end
26
- end
27
-
28
- context 'when the yielded value is unused' do
29
- it 'registers an offense' do
30
- expect_offense(<<-RUBY)
31
- around do |test|
32
- ^^^^ You should call `test.call` or `test.run`.
33
- do_something
34
- end
35
- RUBY
36
- end
37
- end
38
-
39
- context 'when two values are yielded and the first is unused' do
40
- it 'registers an offense for the first argument' do
41
- expect_offense(<<-RUBY)
42
- around do |test, unused|
43
- ^^^^ You should call `test.call` or `test.run`.
44
- unused.run
45
- end
46
- RUBY
47
- end
48
- end
49
-
50
- context 'when the yielded value is referenced but not used' do
51
- it 'registers an offense' do
52
- expect_offense(<<-RUBY)
53
- around do |test|
54
- ^^^^ You should call `test.call` or `test.run`.
55
- test
56
- end
57
- RUBY
58
- end
59
- end
60
-
61
- context 'when a method other than #run or #call is called' do
62
- it 'registers an offense' do
63
- expect_offense(<<-RUBY)
64
- around do |test|
65
- ^^^^ You should call `test.call` or `test.run`.
66
- test.inspect
67
- end
68
- RUBY
69
- end
70
- end
71
-
72
- context 'when #run is called' do
73
- it 'does not register an offense' do
74
- expect_no_offenses(<<-RUBY)
75
- around do |test|
76
- test.run
77
- end
78
- RUBY
79
- end
80
- end
81
-
82
- context 'when #call is called' do
83
- it 'does not register an offense' do
84
- expect_no_offenses(<<-RUBY)
85
- around do |test|
86
- test.call
87
- end
88
- RUBY
89
- end
90
- end
91
-
92
- context 'when used as a block arg' do
93
- it 'does not register an offense' do
94
- expect_no_offenses(<<-RUBY)
95
- around do |test|
96
- 1.times(&test)
97
- end
98
- RUBY
99
- end
100
- end
101
-
102
- context 'when passed to another method' do
103
- it 'does not register an offense' do
104
- expect_no_offenses(<<-RUBY)
105
- around do |test|
106
- something_that_might_run_test(test, another_arg)
107
- end
108
- RUBY
109
- end
110
- end
111
-
112
- context 'when yielded to another block' do
113
- it 'does not register an offense' do
114
- expect_no_offenses(<<-RUBY)
115
- around do |test|
116
- foo { yield(some_arg, test) }
117
- end
118
- RUBY
119
- end
120
- end
121
- end