|
9 | 9 | let(:constant_name) { '::TestPackage::TestClass' } |
10 | 10 | let(:package) { instance_double('Packwerk::Package', name: 'packs/test_package') } |
11 | 11 | let(:violations) { instance_double('QueryPackwerk::Violations') } |
12 | | - let(:anonymous_sources_with_locations) { { '::TestPackage::TestClass' => { 'example usage' => ['app/models/test.rb'] } } } |
| 12 | + let(:anonymous_sources_with_locations) { { '::TestPackage::TestClass' => { 'example usage' => ['app/models/test.rb:1'] } } } |
13 | 13 |
|
14 | 14 | before do |
15 | 15 | allow(Chatwerk::Helpers).to receive(:chdir) |
|
23 | 23 | end |
24 | 24 |
|
25 | 25 | it 'returns the packages view' do |
26 | | - expect(described_class.packages).to eq('packs/test_package') |
| 26 | + expect(described_class.packages).to eq("packs/test_package\n") |
27 | 27 | end |
28 | 28 |
|
29 | 29 | it 'accepts an optional package path filter' do |
|
40 | 40 | end |
41 | 41 |
|
42 | 42 | it 'returns the no packages view' do |
43 | | - expect(described_class.packages.chomp).to eq(<<~STRING.chomp) |
| 43 | + expect(described_class.packages).to eq(<<~STRING) |
44 | 44 | 0 packages found. |
45 | 45 | `packwerk.yml` file exists in project root: /test/workspace |
46 | 46 |
|
|
98 | 98 |
|
99 | 99 | it 'returns the violations list view' do |
100 | 100 | expect(described_class.package_todos(package_path: package_path)).to eq(<<~STRING) |
101 | | - The following code violates package boundaries: |
102 | | -
|
103 | | - # Constant `::TestPackage::TestClass` |
104 | | - example usage |
105 | | - - app/models/test.rb |
| 101 | + app/models/test.rb |
| 102 | + 1: example usage |
106 | 103 | STRING |
107 | 104 | end |
108 | 105 | end |
109 | 106 |
|
110 | 107 | context 'with constant name' do |
111 | 108 | it 'returns the violations details view' do |
112 | 109 | expect(described_class.package_todos(package_path: package_path, constant_name: constant_name)).to eq(<<~STRING) |
113 | | - The following code violates package boundaries: |
114 | | -
|
115 | | - # Constant `::TestPackage::TestClass` |
116 | | - example usage |
117 | | - - app/models/test.rb |
| 110 | + app/models/test.rb |
| 111 | + 1: example usage |
118 | 112 | STRING |
119 | 113 | end |
120 | 114 |
|
|
123 | 117 |
|
124 | 118 | it 'returns the no violations view' do |
125 | 119 | expect(described_class.package_todos(package_path: package_path, constant_name: constant_name).strip).to eq(<<~STRING.strip) |
126 | | - The following code violates package boundaries: |
127 | | -
|
128 | 120 | No violations found in "packs/test_package" for "::TestPackage::TestClass". |
129 | 121 | Ensure that constant_name is given in the format of "::ConstantName" or "::ConstantName::NestedConstant". |
130 | 122 | STRING |
|
157 | 149 |
|
158 | 150 | it 'returns the violations list view' do |
159 | 151 | expect(described_class.package_violations(package_path: package_path)).to eq(<<~STRING) |
160 | | - The following code violates package boundaries: |
161 | | -
|
162 | | - # Constant `::TestPackage::TestClass` |
163 | | - example usage |
164 | | - - app/models/test.rb |
| 152 | + app/models/test.rb |
| 153 | + 1: example usage |
165 | 154 | STRING |
166 | 155 | end |
167 | 156 | end |
168 | 157 |
|
169 | 158 | context 'with constant name' do |
170 | 159 | it 'returns the violations details view' do |
171 | 160 | expect(described_class.package_violations(package_path: package_path, constant_name: constant_name)).to eq(<<~STRING) |
172 | | - The following code violates package boundaries: |
173 | | -
|
174 | | - # Constant `::TestPackage::TestClass` |
175 | | - example usage |
176 | | - - app/models/test.rb |
| 161 | + app/models/test.rb |
| 162 | + 1: example usage |
177 | 163 | STRING |
178 | 164 | end |
179 | 165 |
|
180 | 166 | context 'when no violations found' do |
181 | 167 | let(:anonymous_sources_with_locations) { {} } |
182 | 168 |
|
183 | 169 | it 'returns the no violations view' do |
184 | | - expect(described_class.package_violations(package_path: package_path, constant_name: constant_name).strip).to eq(<<~STRING.strip) |
185 | | - The following code violates package boundaries: |
186 | | -
|
| 170 | + expect(described_class.package_violations(package_path: package_path, constant_name: constant_name)).to eq(<<~STRING) |
187 | 171 | No violations found in "packs/test_package" for "::TestPackage::TestClass". |
188 | 172 | Ensure that constant_name is given in the format of "::ConstantName" or "::ConstantName::NestedConstant". |
189 | 173 | STRING |
|
0 commit comments