spec/jpeg_spec.rb in jpeg-0.0.2 vs spec/jpeg_spec.rb in jpeg-0.1.0
- old
+ new
@@ -1,7 +1,36 @@
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
+def sample_file_path(file)
+ File.join(File.dirname(__FILE__), 'samples', file)
+end
+
describe "Jpeg" do
- it "fails" do
- fail "hey buddy, you should probably rename this file and start specing for real"
+ subject { @jpeg }
+ describe :open do
+ context "valid jpeg" do
+ before { @jpeg = Jpeg.open(sample_file_path("sample.jpg")) }
+ its(:size) { should == [112, 112] }
+ its(:width) { should == 112 }
+ its(:height) { should == 112 }
+ end
+ context "non-exists file" do
+ it {
+ lambda {
+ Jpeg.open(sample_file_path("nonexists.jpg"))
+ }.should raise_error
+ }
+ end
+
+ context "not a correct jpeg file" do
+ it {
+ lambda {
+ Jpeg.open(sample_file_path("sample.png"))
+ }.should raise_error
+ }
+ end
+ end
+ describe :from_string do
+ before { @jpeg = Jpeg.open_buffer(File.open(sample_file_path("sample.jpg")).read) }
+ its(:size) { should == [112, 112] }
end
end