blob: b3c920f9d258adc660825328c0b125c19fee3d72 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# frozen_string_literal: true
require 'fast_spec_helper'
require_relative '../../../rubocop/cop/project_path_helper'
RSpec.describe RuboCop::Cop::ProjectPathHelper do
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 and corrects', :aggregate_failures do
expect_offense(<<~CODE)
#{source}
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Use short project path helpers without explicitly passing the namespace[...]
CODE
expect_correction(<<~CODE)
#{correct_source}
CODE
end
end
context 'when using namespace_project with a different namespace' do
it 'registers no offense' do
expect_no_offenses('edit_namespace_project_issue_path(namespace, project)')
end
end
end
|