Skip to content

Commit

Permalink
test: rename "describe" to "context" where appropriate
Browse files Browse the repository at this point in the history
"describe" feels more accurate when discussing the interface, while "context" fits well when we are talking
about particular scenario/setup"
  • Loading branch information
knarewski committed Dec 2, 2024
1 parent cd0797e commit f662387
Showing 1 changed file with 26 additions and 26 deletions.
52 changes: 26 additions & 26 deletions spec/morandi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,15 @@
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
context 'when given an input without any options' do
it 'creates output' do
process_image
expect(File).to exist(file_out)
expect(file_out).to match_reference_image(reference_image_prefix, 'plasma-no-op-output')
end
end

describe 'when given a blank file' do
context 'when given a blank file' do
it 'should fail' do
File.open(file_in, 'w') { |fp| fp << '' }
expect { process_image }.to raise_error(
Expand All @@ -68,15 +68,15 @@
end
end

describe 'when given a corrupt file' do
context 'when given a corrupt file' do
it 'should fail' do
File.open(file_in, 'ab') { |fp| fp.truncate(64) }
expect { process_image }.to raise_exception(Morandi::CorruptImageError)
expect(File).not_to exist(file_out)
end
end

describe 'when given a invalid file format' do
context 'when given a invalid file format' do
it 'should fail' do
File.open(file_in, 'wb') { |fp| fp << 'INVALID' }
expect { process_image }.to raise_error(
Expand All @@ -87,7 +87,7 @@
end
end

describe 'with a big image and a bigger cropped area to fill' do
context 'with a big image and a bigger cropped area to fill' do
let(:options) do
{
'crop' => '0,477,15839,18804',
Expand All @@ -108,7 +108,7 @@
end
end

describe 'when given an angle of rotation' do
context 'when given an angle of rotation' do
let(:options) { { 'angle' => angle } }

context '90 degress', vips_wip: processor_name == 'vips' do
Expand Down Expand Up @@ -152,7 +152,7 @@
let(:cropped_width) { 300 }
let(:cropped_height) { 300 }

describe 'when given an array of dimensions' do
context 'when given an array of dimensions' do
let(:options) { { 'crop' => [10, 10, cropped_width, cropped_height] } }

it 'should crop the image' do
Expand All @@ -166,7 +166,7 @@
end
end

describe 'when given a string of dimensions' do
context 'when given a string of dimensions' do
let(:options) { { 'crop' => "10,10,#{cropped_width},#{cropped_height}" } }

it 'should do cropping of images with a string' do
Expand All @@ -180,7 +180,7 @@
end
end

describe 'with negative initial coordinates' do
context 'with negative initial coordinates' do
let(:options) { { 'crop' => [-50, -50, cropped_width, cropped_height] } }

it 'crops the image to desired dimensions' do
Expand All @@ -194,7 +194,7 @@
end
end

describe 'with desired dimensions exceeding the size of original image' do
context 'with desired dimensions exceeding the size of original image' do
let(:options) { { 'crop' => [0, 0, original_image_width + 50, original_image_height + 50] } }

it 'crops the image to desired dimensions' do
Expand All @@ -208,7 +208,7 @@
end
end

describe 'with negative dimensions' do
context 'with negative dimensions' do
let(:options) { { 'crop' => [0, 0, -10, -10] } }

it 'crops the image to 1x1px' do
Expand All @@ -223,7 +223,7 @@
end
end

describe 'when given an output.max option' do
context 'when given an output.max option' do
let(:options) { { 'output.max' => max_size } }
let(:max_size) { 200 }

Expand All @@ -239,7 +239,7 @@
end
end

describe 'when given a straighten option', vips_wip: processor_name == 'vips' do
context 'when given a straighten option', vips_wip: processor_name == 'vips' do
let(:options) { { 'straighten' => 5 } }

it 'straightens images' do
Expand Down Expand Up @@ -279,7 +279,7 @@
end
end

describe 'when given a gamma option', vips_wip: processor_name == 'vips' do
context 'when given a gamma option', vips_wip: processor_name == 'vips' do
let(:options) { { 'gamma' => 2.0 } }

it 'should apply the gamma to the image' do
Expand All @@ -292,7 +292,7 @@
end
end

describe 'when given an fx option' do
context 'when given an fx option' do
let(:options) { { 'fx' => filter_name } }

context 'with sepia' do
Expand Down Expand Up @@ -332,7 +332,7 @@
end
end

describe 'when changing the dimensions and auto-cropping' do
context 'when changing the dimensions and auto-cropping' do
let(:max_width) { 300 }
let(:max_height) { 200 }

Expand All @@ -357,7 +357,7 @@
end
end

describe 'with limiting the output size without autocrop' do
context 'with limiting the output size without autocrop' do
let(:output_width) { 300 }
let(:output_height) { 200 }

Expand Down Expand Up @@ -494,7 +494,7 @@
context 'pixbuf processor' do
it_behaves_like 'an image processor', 'pixbuf'

describe 'when given a pixbuf as an input' do
context 'when given a pixbuf as an input' do
subject(:process_image) do
Morandi.process(pixbuf, options, file_out)
end
Expand All @@ -511,7 +511,7 @@
end
end

describe 'when the user supplies a path.icc in the "local_options" argument' do
context 'when the user supplies a path.icc in the "local_options" argument' do
subject(:process_image) do
Morandi.process(file_in, options, file_out, local_options)
end
Expand Down Expand Up @@ -545,7 +545,7 @@
end
end

describe 'when the user supplies a path.icc in the "options" argument' do
context 'when the user supplies a path.icc in the "options" argument' do
let(:icc_path) { 'sample/icc_insecure_test.jpg' }
let(:options) { { 'path.icc' => icc_path } }
let(:icc_width) { 900 }
Expand All @@ -564,7 +564,7 @@
end
end

describe 'when given a redeye option' do
context 'when given a redeye option' do
let(:file_in) { 'spec/fixtures/public-domain-redeye-image-from-wikipedia.jpg' }
let(:options) { { 'redeye' => [[540, 650]] } }

Expand Down Expand Up @@ -602,7 +602,7 @@
end
end

describe 'when given a negative sharpen option' do
context 'when given a negative sharpen option' do
let(:options) { { 'sharpen' => -3 } }

it 'should blur the image' do
Expand All @@ -614,7 +614,7 @@
end
end

describe 'when given a postive sharpen option' do
context 'when given a postive sharpen option' do
let(:options) { { 'sharpen' => 3 } }

it 'should sharpen the image' do
Expand All @@ -627,7 +627,7 @@
end
end

describe 'when applying a border and maintaining the original size' do
context 'when applying a border and maintaining the original size' do
let(:options) do
{
'border-style' => 'square',
Expand Down Expand Up @@ -684,7 +684,7 @@
end
end

describe 'when applying a retro border and maintaining the original size' do
context 'when applying a retro border and maintaining the original size' do
let(:options) do
{
'border-style' => 'retro',
Expand All @@ -707,7 +707,7 @@
end
end

describe 'when applying multiple transformations' do
context 'when applying multiple transformations' do
let(:desired_image_width) { 300 }
let(:desired_image_height) { 260 }

Expand Down

0 comments on commit f662387

Please sign in to comment.