Sha256: be2e347345dc83a4ac3f69e311f5bdd683edbc5ff3eeb6f863af0b1ee3b83dad

Contents?: true

Size: 1.02 KB

Versions: 5

Compression:

Stored size: 1.02 KB

Contents

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
  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 }
      its(:color_info) { should == :rgb }
      its(:rgb?) { should be_true }
      its(:gray?) { should be_false }
    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

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
jpeg-0.4.0 spec/jpeg_spec.rb
jpeg-0.3.3 spec/jpeg_spec.rb
jpeg-0.3.2 spec/jpeg_spec.rb
jpeg-0.3.1 spec/jpeg_spec.rb
jpeg-0.3.0 spec/jpeg_spec.rb