Skip to content

Commit

Permalink
Merge branch 'master' into blending
Browse files Browse the repository at this point in the history
  • Loading branch information
mtgrosser authored Mar 29, 2022
2 parents bef9a4f + 118e4dc commit c208557
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
timeout-minutes: 5
strategy:
matrix:
ruby-version: ['2.6', '2.7', '3.0']
ruby-version: ['2.6', '2.7', '3.0', '3.1']

steps:
- uses: actions/checkout@v2
Expand Down
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ image.save('resized.jpg')

# save it as PNG
image.save('resized.png')

# save without extension in given format
image.save('resized', format: 'png')
```

### Image info
Expand Down
20 changes: 20 additions & 0 deletions spec/rszr_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,26 @@
end
end

it 'saves with given format when saving without extension' do
Dir.mktmpdir do |dir|
resized_file = Pathname.new(File.join(dir, 'resized'))
resized_file.unlink if resized_file.exist?
expect(resized_file.exist?).to be(false)
expect(@image.save(resized_file.to_s, format: :png)).to be(true)
expect(resized_file).to have_format('png')
end
end

it 'saves using specified format, overriding extension' do
Dir.mktmpdir do |dir|
resized_file = Pathname.new(File.join(dir, 'resized.jpg'))
resized_file.unlink if resized_file.exist?
expect(resized_file.exist?).to be(false)
expect(@image.save(resized_file.to_s, format: :png)).to be(true)
expect(resized_file).to have_format('png')
end
end

it 'raises save errors' do
Dir.mktmpdir do |dir|
resized_file = Pathname.new(File.join(dir, 'foo', 'bar', 'resized.jpg'))
Expand Down

0 comments on commit c208557

Please sign in to comment.