spec/rubocop/cop/rspec/hook_argument_spec.rb in rubocop-rspec-1.7.0 vs spec/rubocop/cop/rspec/hook_argument_spec.rb in rubocop-rspec-1.8.0
- old
+ new
@@ -30,46 +30,20 @@
setup(:each) { true }
RUBY
end
end
- shared_examples 'generated config' do |source, detected_style|
- it 'generates a todo based on the detected style' do
- inspect_source(cop, source, 'foo_spec.rb')
-
- expect(cop.config_to_allow_offenses)
- .to eq('EnforcedStyle' => detected_style)
- end
- end
-
shared_examples 'hook autocorrect' do |output|
- it 'autocorrects :each to EnforcedStyle' do
- corrected =
- autocorrect_source(cop, 'before(:each) { }', 'spec/foo_spec.rb')
-
- expect(corrected).to eql(output)
- end
-
- it 'autocorrects :example to EnforcedStyle' do
- corrected =
- autocorrect_source(cop, 'before(:example) { }', 'spec/foo_spec.rb')
-
- expect(corrected).to eql(output)
- end
-
- it 'autocorrects :implicit to EnforcedStyle' do
- corrected =
- autocorrect_source(cop, 'before { }', 'spec/foo_spec.rb')
-
- expect(corrected).to eql(output)
- end
+ include_examples 'autocorrect', 'before(:each) { }', output
+ include_examples 'autocorrect', 'before(:example) { }', output
+ include_examples 'autocorrect', 'before { }', output
end
shared_examples 'an example hook' do
include_examples 'ignored hooks'
- include_examples 'generated config', 'before(:each) { foo }', 'each'
- include_examples 'generated config', 'before(:example) { foo }', 'example'
- include_examples 'generated config', 'before { foo }', 'implicit'
+ include_examples 'detects style', 'before(:each) { foo }', 'each'
+ include_examples 'detects style', 'before(:example) { foo }', 'example'
+ include_examples 'detects style', 'before { foo }', 'implicit'
end
context 'when EnforcedStyle is :implicit' do
let(:enforced_style) { :implicit }