Sha256: e2b28f3797eb70238fcf8e548639870b5c3e76b628af60008ba03309b1bc830f

Contents?: true

Size: 1.63 KB

Versions: 8

Compression:

Stored size: 1.63 KB

Contents

require 'spec_helper'
describe Sqed::Extractor do

  let(:metadata_map) { 
    {0 => :specimen, 1 => :identifier, 2 => :nothing, 3 => :image_registration }
  } 
 
  let(:image) { ImageHelpers.crossy_green_line_specimen }

  let(:boundaries) { 
    Sqed::BoundaryFinder::CrossFinder.new(
      image: image
    ).boundaries
  }

  let(:e) {
    Sqed::Extractor.new(
      boundaries: boundaries,
      image: image,
      metadata_map: metadata_map
    )
  }

  context 'attributes' do
    specify '#image' do
      expect(e).to respond_to(:image)
    end

    specify '#metadata_map' do
      expect(e).to respond_to(:metadata_map)
    end
 
    specify '#boundaries' do
      expect(e).to respond_to(:boundaries)
    end
  end

  context 'extracting to a #result' do
    let(:r) { e.result }
    
    specify '#result retuns a Sqed::Result' do
      expect(r.class.name).to eq('Sqed::Result')
    end

    specify '#result is populated with images' do
      expect(r.images.values.first.class.name).to eq('Magick::Image') 
    end

    specify '#result is populated with text' do
      expect(r.text_for(:identifier)).to match('PSUC')
      # expect(r.text_for(:identifier)).to match('000085067') # not catching this with default settings
    end

    specify '#sections is populated with section_types' do
      expect(r.sections).to eq( [ :identifier, :image_registration, :nothing, :specimen ] )
    end

    specify '#boundary_coordinates is populated with coordinates' do
      metadata_map.values.each do |section_type|
        (0..3).each do |i|
          expect(r.boundary_coordinates[section_type][i]).to be_truthy 
        end
      end
    end

  end

end 

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
sqed-0.4.4 spec/lib/sqed/extractor_spec.rb
sqed-0.4.3 spec/lib/sqed/extractor_spec.rb
sqed-0.4.2 spec/lib/sqed/extractor_spec.rb
sqed-0.4.1 spec/lib/sqed/extractor_spec.rb
sqed-0.4.0 spec/lib/sqed/extractor_spec.rb
sqed-0.1.9 spec/lib/sqed/extractor_spec.rb
sqed-0.1.8 spec/lib/sqed/extractor_spec.rb
sqed-0.1.7 spec/lib/sqed/extractor_spec.rb