Sha256: aca951c46ef66f17e574f36dc5bb541a52ab9e0c6f46b544cbf77b0554ab15d0
Contents?: true
Size: 957 Bytes
Versions: 3
Compression:
Stored size: 957 Bytes
Contents
require 'spec_helper' RSpec.describe NewspaperWorks::TextExtraction::WordCoordsBuilder do let(:words) do [ { word: "foo", coordinates: [1, 2, 3, 4] }, { word: "bar", coordinates: [5, 6, 7, 8] }, { word: "baz", coordinates: [9, 10, 11, 12] }, { word: "foo", coordinates: [13, 14, 15, 16] } ] end let(:image_width) { 1_234 } let(:image_height) { 5_678 } let(:wcb) { described_class.new(words, image_width, image_height) } describe '#to_json' do let(:wcb_to_json) { JSON.parse(wcb.to_json) } it 'has the correct structure' do expect(wcb_to_json['height']).to eq image_height expect(wcb_to_json['width']).to eq image_width expect(wcb_to_json['coords'].length).to eq 3 expect(wcb_to_json['coords']['foo']).not_to be_falsey end it 'combines coordinates for the same word' do expect(wcb_to_json['coords']['foo']).to eq [[1, 2, 3, 4], [13, 14, 15, 16]] end end end
Version data entries
3 entries across 3 versions & 1 rubygems