Sha256: 85dca9d7c602db665de94f182ecabf18e47550849976c0762a2d4b8d55527f78

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 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")) }
      it { expect(subject).to be_a Jpeg::Image }
      it { expect(subject.size).to eq [112, 112] }
      it { expect(subject.width).to eq 112 }
      it { expect(subject.height).to eq 112 }
      it { expect(subject.color_info).to eq :rgb }
      it { expect(subject).to be_rgb }
      it { expect(subject).not_to be_gray }
    end

    context "non-exists file" do
      it { expect { Jpeg.open(sample_file_path("nonexists.jpg")) }.to raise_error(Jpeg::Error) }
    end

    context "not a correct jpeg file" do
      it { expect { Jpeg.open(sample_file_path("sample.png")) }.to raise_error(Jpeg::Error) }
    end
  end
  describe :from_string do
    before { @jpeg = Jpeg.open_buffer(File.open(sample_file_path("sample.jpg")).read) }
    it { expect(subject.size).to eq [112, 112] }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jpeg-0.5.1 spec/jpeg_spec.rb
jpeg-0.5.0 spec/jpeg_spec.rb