Skip to content

Commit

Permalink
Use subject in specs
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaier committed Dec 30, 2012
1 parent 6a93868 commit 84769fb
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 21 deletions.
22 changes: 13 additions & 9 deletions spec/image_sorcery_examples_spec.rb
Original file line number Diff line number Diff line change
@@ -1,37 +1,41 @@
require 'fileutils'
require 'image_sorcery'

shared_examples_for Sorcery do
shared_examples_for Sorcery do |new_instance_method|
subject(:image) do
FileUtils.copy "./spec/fixtures/dog.jpeg", "./spec/fixtures/dog-2.jpeg"
Sorcery.send(new_instance_method, "./spec/fixtures/dog-2.jpeg") # Who doesn't love dogs?
end

describe "getting the dimensions of an image" do
it "returns a hash of dimensions" do
@image.dimensions.should == {:x => 160, :y => 120}
image.dimensions.should == {:x => 160, :y => 120}
end
end

describe "manipulating an image" do
it "resizes an image" do
original_dimensions = @image.dimensions
@image.manipulate!(:resize => "50%")
@image.dimensions.map {|k,v| v.to_i}.should == original_dimensions.map {|k,v| v.to_i/2}
original_dimensions = image.dimensions
image.manipulate!(:resize => "50%")
image.dimensions.map {|k,v| v.to_i}.should == original_dimensions.map {|k,v| v.to_i/2}
end

it "exposes width and height as integers" do
@image.width.should == 160
@image.height.should == 120
image.width.should == 160
image.height.should == 120
end
end

describe "converting an image" do
it "writes the new image out to a file" do
@image.convert("new_image.png")
image.convert("new_image.png")
File.exists?("new_image.png").should be_true
end
end

describe "identifying an image" do
it "returns a list of layers" do
@image.identify.should include "JPEG 160x120"
image.identify.should include "JPEG 160x120"
end
end

Expand Down
7 changes: 1 addition & 6 deletions spec/image_sorcery_gm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
require 'image_sorcery'

describe "Image Sorcery with GraphicsMagick" do
before :each do
FileUtils.copy "./spec/fixtures/dog.jpeg", "./spec/fixtures/dog-2.jpeg"
@image = Sorcery.gm("./spec/fixtures/dog-2.jpeg") # Who doesn't love dogs?
end

it_behaves_like Sorcery
it_behaves_like Sorcery, "gm"
end
7 changes: 1 addition & 6 deletions spec/image_sorcery_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,5 @@
require 'image_sorcery'

describe "Image Sorcery with ImageMagick" do
before :each do
FileUtils.copy "./spec/fixtures/dog.jpeg", "./spec/fixtures/dog-2.jpeg"
@image = Sorcery.new("./spec/fixtures/dog-2.jpeg") # Who doesn't love dogs?
end

it_behaves_like Sorcery
it_behaves_like Sorcery, "new"
end

0 comments on commit 84769fb

Please sign in to comment.