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,86 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::VerifiedDoubles, :config do
4
- subject(:cop) { described_class.new(config) }
5
-
6
- it 'finds a `double` instead of an `instance_double`' do
7
- expect_offense(<<-RUBY)
8
- it do
9
- foo = double("Widget")
10
- ^^^^^^^^^^^^^^^^ Prefer using verifying doubles over normal doubles.
11
- end
12
- RUBY
13
- end
14
-
15
- context 'when configuration does not specify IgnoreSymbolicNames' do
16
- let(:cop_config) { {} }
17
-
18
- it 'find doubles whose name is a symbol' do
19
- expect_offense(<<-RUBY)
20
- it do
21
- foo = double(:widget)
22
- ^^^^^^^^^^^^^^^ Prefer using verifying doubles over normal doubles.
23
- end
24
- RUBY
25
- end
26
-
27
- it 'finds a `spy` instead of an `instance_spy`' do
28
- expect_offense(<<-RUBY)
29
- it do
30
- foo = spy("Widget")
31
- ^^^^^^^^^^^^^ Prefer using verifying doubles over normal doubles.
32
- end
33
- RUBY
34
- end
35
- end
36
-
37
- context 'when configured to ignore symbolic names' do
38
- let(:cop_config) { { 'IgnoreSymbolicNames' => true } }
39
-
40
- it 'ignores doubles whose name is a symbol' do
41
- expect_no_offenses(<<-RUBY)
42
- it do
43
- foo = double(:widget)
44
- end
45
- RUBY
46
- end
47
-
48
- it 'still flags doubles whose name is a string' do
49
- expect_offense(<<-RUBY)
50
- it do
51
- foo = double("widget")
52
- ^^^^^^^^^^^^^^^^ Prefer using verifying doubles over normal doubles.
53
- end
54
- RUBY
55
- end
56
- end
57
-
58
- it 'doubles that have no name specified' do
59
- expect_offense(<<-RUBY)
60
- it do
61
- foo = double
62
- ^^^^^^ Prefer using verifying doubles over normal doubles.
63
- end
64
- RUBY
65
- end
66
-
67
- context 'when configured to ignore nameless doubles' do
68
- let(:cop_config) { { 'IgnoreNameless' => true } }
69
-
70
- it 'ignores doubles that have no name specified' do
71
- expect_no_offenses(<<-RUBY)
72
- it do
73
- foo = double
74
- end
75
- RUBY
76
- end
77
- end
78
-
79
- it 'ignores instance_doubles' do
80
- expect_no_offenses(<<-RUBY)
81
- it do
82
- foo = instance_double("Foo")
83
- end
84
- RUBY
85
- end
86
- end
@@ -1,49 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::VoidExpect do
4
- subject(:cop) { described_class.new }
5
-
6
- it 'registers offenses to void `expect`' do
7
- expect_offense(<<-RUBY)
8
- it 'something' do
9
- something = 1
10
- expect(something)
11
- ^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
12
- end
13
- RUBY
14
- end
15
-
16
- it 'registers offenses to void `expect` when block has one expression' do
17
- expect_offense(<<-RUBY)
18
- it 'something' do
19
- expect(something)
20
- ^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
21
- end
22
- RUBY
23
- end
24
-
25
- it 'registers offenses to void `expect` with block' do
26
- expect_offense(<<-RUBY)
27
- it 'something' do
28
- expect{something}
29
- ^^^^^^^^^^^^^^^^^ Do not use `expect()` without `.to` or `.not_to`. Chain the methods or remove it.
30
- end
31
- RUBY
32
- end
33
-
34
- it 'accepts non-void `expect`' do
35
- expect_no_offenses(<<-RUBY)
36
- it 'something' do
37
- expect(something).to be 1
38
- end
39
- RUBY
40
- end
41
-
42
- it 'accepts non-void `expect` with block' do
43
- expect_no_offenses(<<-RUBY)
44
- it 'something' do
45
- expect{something}.to raise_error(StandardError)
46
- end
47
- RUBY
48
- end
49
- end
@@ -1,81 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::Cop::RSpec::Yield do
4
- subject(:cop) { described_class.new }
5
-
6
- it 'flags `block.call`' do
7
- expect_offense(<<-RUBY)
8
- allow(foo).to receive(:bar) { |&block| block.call }
9
- ^^^^^^^^^^^^^^^^^^^^^^^ Use `.and_yield`.
10
- RUBY
11
-
12
- expect_correction(<<-RUBY)
13
- allow(foo).to receive(:bar).and_yield
14
- RUBY
15
- end
16
-
17
- it 'flags multiple `block.call`' do
18
- expect_offense(<<-RUBY)
19
- allow(foo).to receive(:bar) do |&block|
20
- ^^^^^^^^^^^ Use `.and_yield`.
21
- block.call
22
- block.call
23
- end
24
- RUBY
25
-
26
- expect_correction(<<-RUBY)
27
- allow(foo).to receive(:bar).and_yield.and_yield
28
- RUBY
29
- end
30
-
31
- it 'flags `block.call` with arguments' do
32
- expect_offense(<<-RUBY)
33
- allow(foo).to receive(:bar) { |&block| block.call(1, 2) }
34
- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use `.and_yield`.
35
- RUBY
36
-
37
- expect_correction(<<-RUBY)
38
- allow(foo).to receive(:bar).and_yield(1, 2)
39
- RUBY
40
- end
41
-
42
- it 'flags multiple `block.call` with arguments' do
43
- expect_offense(<<-RUBY)
44
- allow(foo).to receive(:bar) do |&block|
45
- ^^^^^^^^^^^ Use `.and_yield`.
46
- block.call(1)
47
- block.call(2)
48
- end
49
- RUBY
50
-
51
- expect_correction(<<-RUBY)
52
- allow(foo).to receive(:bar).and_yield(1).and_yield(2)
53
- RUBY
54
- end
55
-
56
- it 'flags `block.call` when `receive` is chained' do
57
- expect_offense(<<-RUBY)
58
- allow(foo).to receive(:bar).with(anything) { |&block| block.call }
59
- ^^^^^^^^^^^^^^^^^^^^^^^ Use `.and_yield`.
60
- RUBY
61
-
62
- expect_correction(<<-RUBY)
63
- allow(foo).to receive(:bar).with(anything).and_yield
64
- RUBY
65
- end
66
-
67
- it 'ignores `receive` with no block arguments' do
68
- expect_no_offenses(<<-RUBY)
69
- allow(foo).to receive(:bar) { |block| block.call }
70
- RUBY
71
- end
72
-
73
- it 'ignores stub when `block.call` is not the only statement' do
74
- expect_no_offenses(<<-RUBY)
75
- allow(foo).to receive(:bar) do |&block|
76
- result = block.call
77
- transform(result)
78
- end
79
- RUBY
80
- end
81
- end
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rubocop/rspec/config_formatter'
4
-
5
- RSpec.describe RuboCop::RSpec::ConfigFormatter do
6
- let(:config) do
7
- {
8
- 'AllCops' => {
9
- 'Setting' => 'fourty two'
10
- },
11
- 'RSpec/Foo' => {
12
- 'Config' => 2,
13
- 'Enabled' => true
14
- },
15
- 'RSpec/Bar' => {
16
- 'Enabled' => true
17
- }
18
- }
19
- end
20
-
21
- let(:descriptions) do
22
- {
23
- 'RSpec/Foo' => {
24
- 'Description' => 'Blah'
25
- },
26
- 'RSpec/Bar' => {
27
- 'Description' => 'Wow'
28
- }
29
- }
30
- end
31
-
32
- it 'builds a YAML dump with spacing between cops' do
33
- formatter = described_class.new(config, descriptions)
34
-
35
- expect(formatter.dump).to eql(<<-YAML.gsub(/^\s+\|/, ''))
36
- |---
37
- |AllCops:
38
- | Setting: fourty two
39
- |
40
- |RSpec/Foo:
41
- | Config: 2
42
- | Enabled: true
43
- | Description: Blah
44
- | StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Foo
45
- |
46
- |RSpec/Bar:
47
- | Enabled: true
48
- | Description: Wow
49
- | StyleGuide: http://www.rubydoc.info/gems/rubocop-rspec/RuboCop/Cop/RSpec/Bar
50
- YAML
51
- end
52
- end
@@ -1,63 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'yard'
4
-
5
- require 'rubocop/rspec/description_extractor'
6
-
7
- RSpec.describe RuboCop::RSpec::DescriptionExtractor do
8
- let(:yardocs) do
9
- YARD.parse_string(<<-RUBY)
10
- # This is not a cop
11
- class RuboCop::Cop::Mixin::Sneaky
12
- end
13
-
14
- # This is not a concrete cop
15
- #
16
- # @abstract
17
- class RuboCop::Cop::RSpec::Cop
18
- end
19
-
20
- # Checks foo
21
- #
22
- # Some description
23
- #
24
- # @note only works with foo
25
- class RuboCop::Cop::RSpec::Foo < RuboCop::Cop::RSpec::Cop
26
- # Hello
27
- def bar
28
- end
29
-
30
- # :nodoc:
31
- class HelperClassForFoo
32
- end
33
- end
34
-
35
- class RuboCop::Cop::RSpec::Undocumented < RuboCop::Cop::RSpec::Cop
36
- # Hello
37
- def bar
38
- end
39
- end
40
- RUBY
41
-
42
- YARD::Registry.all
43
- end
44
-
45
- def stub_cop_const(name)
46
- stub_const(
47
- "RuboCop::Cop::RSpec::#{name}",
48
- Class.new(RuboCop::Cop.const_get(:WorkaroundCop))
49
- )
50
- end
51
-
52
- before do
53
- stub_cop_const('Foo')
54
- stub_cop_const('Undocumented')
55
- end
56
-
57
- it 'builds a hash of descriptions' do
58
- expect(described_class.new(yardocs).to_h).to eql(
59
- 'RSpec/Foo' => { 'Description' => 'Checks foo' },
60
- 'RSpec/Undocumented' => { 'Description' => '' }
61
- )
62
- end
63
- end
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::RSpec::ExampleGroup do
4
- include RuboCop::AST::Sexp
5
-
6
- subject(:group) { described_class.new(parse_source(source).ast) }
7
-
8
- let(:source) do
9
- <<-RUBY
10
- RSpec.describe Foo do
11
- it 'does x' do
12
- x
13
- end
14
-
15
- it 'does y' do
16
- y
17
- end
18
-
19
- context 'nested' do
20
- it 'does z' do
21
- z
22
- end
23
- end
24
- end
25
- RUBY
26
- end
27
-
28
- let(:example_nodes) do
29
- [
30
- s(:block,
31
- s(:send, nil, :it,
32
- s(:str, 'does x')),
33
- s(:args), s(:send, nil, :x)),
34
- s(:block,
35
- s(:send, nil, :it,
36
- s(:str, 'does y')),
37
- s(:args), s(:send, nil, :y))
38
- ].map { |node| RuboCop::RSpec::Example.new(node) }
39
- end
40
-
41
- it 'exposes examples in scope' do
42
- expect(group.examples).to eql(example_nodes)
43
- end
44
- end
@@ -1,62 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::RSpec::Example do
4
- include RuboCop::AST::Sexp
5
-
6
- def example(source)
7
- described_class.new(parse_source(source).ast)
8
- end
9
-
10
- it 'extracts doc string' do
11
- expect(example("it('does x') { foo }").doc_string)
12
- .to eq(s(:str, 'does x'))
13
- end
14
-
15
- it 'extracts doc string for unimplemented examples' do
16
- expect(example("it('does x')").doc_string)
17
- .to eq(s(:str, 'does x'))
18
- end
19
-
20
- it 'returns nil for examples without doc strings' do
21
- expect(example('it { foo }').doc_string).to be(nil)
22
- end
23
-
24
- it 'extracts keywords' do
25
- expect(example("it('foo', :bar, baz: :qux) { a }").metadata)
26
- .to eq([s(:sym, :bar), s(:hash, s(:pair, s(:sym, :baz), s(:sym, :qux)))])
27
- end
28
-
29
- it 'extracts implementation' do
30
- expect(example('it("foo") { bar; baz }').implementation)
31
- .to eq(s(:begin, s(:send, nil, :bar), s(:send, nil, :baz)))
32
- end
33
-
34
- it 'returns node' do
35
- node = s(:sym, :node)
36
- expect(described_class.new(node).to_node).to be(node)
37
- end
38
-
39
- describe 'value object semantics' do
40
- it 'compares by value' do
41
- aggregate_failures 'equality semantics' do
42
- expect(example('it("foo")')).to eq(example('it("foo")'))
43
- expect(example('it("foo")')).not_to eq(example('it("bar")'))
44
- end
45
- end
46
-
47
- it 'can be used as a key in a hash' do
48
- hash = {}
49
-
50
- hash[example('it("foo")')] = 123
51
-
52
- expect(hash[example('it("foo")')]).to be(123)
53
- end
54
-
55
- it 'computes #hash based on class and node' do
56
- node = s(:node)
57
-
58
- expect(described_class.new(node).hash)
59
- .to eql([described_class, node].hash)
60
- end
61
- end
62
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- RSpec.describe RuboCop::RSpec::Hook do
4
- include RuboCop::AST::Sexp
5
-
6
- def hook(source)
7
- described_class.new(parse_source(source).ast)
8
- end
9
-
10
- it 'extracts name' do
11
- expect(hook('around(:each) { }').name).to be(:around)
12
- end
13
-
14
- it 'does not break if a hook is not given a symbol literal' do
15
- expect(hook('before(scope) { example_setup }').knowable_scope?).to be(false)
16
- end
17
-
18
- it 'knows the scope of a hook with a symbol literal' do
19
- expect(hook('before { example_setup }').knowable_scope?).to be(true)
20
- end
21
-
22
- it 'ignores other arguments to hooks' do
23
- expect(hook('before(:each, :metadata) { example_setup }').scope)
24
- .to be(:each)
25
- end
26
-
27
- it 'classifies nonstandard hook arguments as invalid' do
28
- expect(hook('before(:nothing) { example_setup }').valid_scope?).to be(false)
29
- end
30
-
31
- it 'classifies :each as a valid hook argument' do
32
- expect(hook('before(:each) { example_setup }').valid_scope?).to be(true)
33
- end
34
-
35
- it 'classifies :each as an example hook' do
36
- expect(hook('before(:each) { }').example?).to be(true)
37
- end
38
-
39
- shared_examples 'standardizes scope' do |source, scope|
40
- it "interprets #{source} as having scope #{scope}" do
41
- expect(hook(source).scope).to equal(scope)
42
- end
43
- end
44
-
45
- include_examples 'standardizes scope', 'before(:each) { }', :each
46
- include_examples 'standardizes scope', 'around(:example) { }', :each
47
- include_examples 'standardizes scope', 'after { }', :each
48
-
49
- include_examples 'standardizes scope', 'before(:all) { }', :context
50
- include_examples 'standardizes scope', 'around(:context) { }', :context
51
-
52
- include_examples 'standardizes scope', 'after(:suite) { }', :suite
53
- end