diff --git a/spec/tooling/lib/tooling/test_file_finder_spec.rb b/spec/tooling/lib/tooling/test_file_finder_spec.rb index 3025c21d858f00b957aafb2c5a98db591da0977c..64b55b9b1d6221421d4d6d0c251edd1f791cd9ae 100644 --- a/spec/tooling/lib/tooling/test_file_finder_spec.rb +++ b/spec/tooling/lib/tooling/test_file_finder_spec.rb @@ -120,6 +120,22 @@ end end + context 'when given a haml view' do + let(:file) { 'app/views/admin/users/_user.html.haml' } + + it 'returns the matching view spec' do + expect(subject.test_files).to contain_exactly('spec/views/admin/users/_user.html.haml_spec.rb') + end + end + + context 'when given a haml view in ee/' do + let(:file) { 'ee/app/views/admin/users/_user.html.haml' } + + it 'returns the matching view spec' do + expect(subject.test_files).to contain_exactly('ee/spec/views/admin/users/_user.html.haml_spec.rb') + end + end + context 'when given a migration file' do let(:file) { 'db/migrate/20191023152913_add_default_and_free_plans.rb' } diff --git a/tooling/lib/tooling/test_file_finder.rb b/tooling/lib/tooling/test_file_finder.rb index 36ace67caa30a6cb2dc7386b90a0d7f699be044c..cf5de190c4aa61071b42bb538f6743b5bb9125bf 100644 --- a/tooling/lib/tooling/test_file_finder.rb +++ b/tooling/lib/tooling/test_file_finder.rb @@ -72,9 +72,9 @@ def non_ee_impact ImpactedTestFile.new do |impact| impact.associate(%r{app/(.+)\.rb$}) { |match| "spec/#{match[1]}_spec.rb" } impact.associate(%r{(tooling/)?lib/(.+)\.rb$}) { |match| "spec/#{match[1]}lib/#{match[2]}_spec.rb" } - impact.associate(%r{config/initializers/(.+).rb$}) { |match| "spec/initializers/#{match[1]}_spec.rb" } + impact.associate(%r{config/initializers/(.+)\.rb$}) { |match| "spec/initializers/#{match[1]}_spec.rb" } impact.associate('db/structure.sql') { 'spec/db/schema_spec.rb' } - impact.associate(%r{db/(?:post_)?migrate/([0-9]+)_(.+).rb$}) do |match| + impact.associate(%r{db/(?:post_)?migrate/([0-9]+)_(.+)\.rb$}) do |match| [ "spec/migrations/#{match[2]}_spec.rb", "spec/migrations/#{match[1]}_#{match[2]}_spec.rb" @@ -84,8 +84,9 @@ def non_ee_impact end def either_impact - ImpactedTestFile.new(prefix: %r{^(#{EE_PREFIX})?}) do |impact| - impact.associate(%r{spec/(.+)_spec.rb$}) { |match| match[0] } + ImpactedTestFile.new(prefix: %r{^(?<prefix>#{EE_PREFIX})?}) do |impact| + impact.associate(%r{app/views/(?<view>.+)\.haml$}) { |match| "#{match[:prefix]}spec/views/#{match[:view]}.haml_spec.rb" } + impact.associate(%r{spec/(.+)_spec\.rb$}) { |match| match[0] } impact.associate(%r{spec/factories/.+\.rb$}) { 'spec/factories_spec.rb' } end end