summaryrefslogtreecommitdiff
path: root/spec/rubocop/cop/project_path_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubocop/cop/project_path_helper_spec.rb')
-rw-r--r--spec/rubocop/cop/project_path_helper_spec.rb29
1 files changed, 9 insertions, 20 deletions
diff --git a/spec/rubocop/cop/project_path_helper_spec.rb b/spec/rubocop/cop/project_path_helper_spec.rb
index 78a590b89f6..16782802a27 100644
--- a/spec/rubocop/cop/project_path_helper_spec.rb
+++ b/spec/rubocop/cop/project_path_helper_spec.rb
@@ -3,41 +3,30 @@
require 'fast_spec_helper'
require 'rubocop'
-require 'rubocop/rspec/support'
-
require_relative '../../../rubocop/cop/project_path_helper'
RSpec.describe RuboCop::Cop::ProjectPathHelper do
- include CopHelper
-
subject(:cop) { described_class.new }
context "when using namespace_project with the project's namespace" do
let(:source) { 'edit_namespace_project_issue_path(@issue.project.namespace, @issue.project, @issue)' }
let(:correct_source) { 'edit_project_issue_path(@issue.project, @issue)' }
- it 'registers an offense' do
- inspect_source(source)
-
- aggregate_failures do
- expect(cop.offenses.size).to eq(1)
- expect(cop.offenses.map(&:line)).to eq([1])
- expect(cop.highlights).to eq(['edit_namespace_project_issue_path'])
- end
- end
-
- it 'autocorrects to the right version' do
- autocorrected = autocorrect_source(source)
+ it 'registers an offense and corrects', :aggregate_failures do
+ expect_offense(<<~CODE)
+ #{source}
+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use short project path helpers without explicitly passing the namespace[...]
+ CODE
- expect(autocorrected).to eq(correct_source)
+ expect_correction(<<~CODE)
+ #{correct_source}
+ CODE
end
end
context 'when using namespace_project with a different namespace' do
it 'registers no offense' do
- inspect_source('edit_namespace_project_issue_path(namespace, project)')
-
- expect(cop.offenses.size).to eq(0)
+ expect_no_offenses('edit_namespace_project_issue_path(namespace, project)')
end
end
end