-
Notifications
You must be signed in to change notification settings - Fork 244
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
param validators for encode processor
- Loading branch information
Showing
2 changed files
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
require "spec_helper" | ||
|
||
describe Dragonfly::ImageMagick::Processors::Encode do | ||
let (:app) { test_imagemagick_app } | ||
let (:image) { Dragonfly::Content.new(app, SAMPLES_DIR.join("beach.png")) } # 280x355 | ||
let (:processor) { Dragonfly::ImageMagick::Processors::Encode.new } | ||
|
||
it "encodes to a different format" do | ||
processor.call(image, "jpeg") | ||
image.should have_format("jpeg") | ||
end | ||
|
||
describe "param validations" do | ||
it "validates the format param" do | ||
expect { | ||
processor.call(image, "jpeg -write bad.png") | ||
}.to raise_error(Dragonfly::ParamValidators::InvalidParameter) | ||
end | ||
|
||
it "allows good args" do | ||
processor.call(image, "jpeg", "-quality 10") | ||
end | ||
|
||
it "disallows bad args" do | ||
expect { | ||
processor.call(image, "jpeg", "-write bad.png") | ||
}.to raise_error(Dragonfly::ParamValidators::InvalidParameter) | ||
end | ||
end | ||
end |