Skip to content

Commit

Permalink
feat: add support for nested identifiers for reference images
Browse files Browse the repository at this point in the history
Vips will soon be introduced with its own set of expected render outputs for the same operations, so some mechanism for
scoping reference images is needed
  • Loading branch information
knarewski committed Nov 18, 2024
1 parent e5751a5 commit 37c20e6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
7 changes: 5 additions & 2 deletions spec/morandi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@
FileUtils.remove_dir('sample/')
end

shared_examples 'an image processor' do
shared_examples 'an image processor' do |processor_name|
let(:reference_image_prefix) { processor_name == 'pixbuf' ? '' : processor_name }
subject(:process_image) { Morandi.process(file_arg, options, file_out, { 'processor' => processor_name }) }

describe 'when given an input without any options' do
it 'creates output' do
process_image
Expand Down Expand Up @@ -487,7 +490,7 @@
end

context 'pixbuf processor' do
it_behaves_like 'an image processor'
it_behaves_like 'an image processor', 'pixbuf'

describe 'when given a pixbuf as an input' do
subject(:process_image) do
Expand Down
5 changes: 3 additions & 2 deletions spec/support/match_reference_image.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,9 @@ def expose_from(file_type:, tested_path: nil, reference_path: nil, diff_path: ni
end
end

RSpec::Matchers.define :match_reference_image do |reference_name, file_type: 'jpg', tolerance: 0|
reference_path = File.join('spec/fixtures/reference_images', "#{reference_name}.#{file_type}")
RSpec::Matchers.define :match_reference_image do |*reference_id, file_type: 'jpg', tolerance: 0|
*reference_scope, reference_name = reference_id
reference_path = File.join('spec/fixtures/reference_images', *reference_scope, "#{reference_name}.#{file_type}")

def debug_data
metadata = RSpec.current_example.metadata
Expand Down

0 comments on commit 37c20e6

Please sign in to comment.