spec/lib/sqed/boundary_finder_spec.rb in sqed-0.1.5 vs spec/lib/sqed/boundary_finder_spec.rb in sqed-0.1.6

- old
+ new

@@ -1,11 +1,11 @@ require 'spec_helper' describe Sqed::BoundaryFinder do specify 'when no image provided, #new raises' do - expect { Sqed::BoundaryFinder.new() }.to raise_error + expect { Sqed::BoundaryFinder.new() }.to raise_error('No layout provided.') end context 'when initiated with an image' do let(:b) {Sqed::BoundaryFinder.new(image: ImageHelpers.cross_green, layout: :vertical_offset_cross)} @@ -101,12 +101,18 @@ let(:i) { {1 => 1, 2 => 3, 3 => 15, 4 => 14, 5 => 13 }} specify 'returns the median position (rounds up)' do expect( Sqed::BoundaryFinder.frequency_stats(i, 12)).to eq([3, 4, 5]) end + specify 'returns estimated borders if only one hit greater than samples taken' do + expect( Sqed::BoundaryFinder.frequency_stats(i, 15)).to eq([2,3,4]) + end + specify 'returns nil if no count is greater than samples taken' do - expect( Sqed::BoundaryFinder.frequency_stats(i, 15)).to eq(nil) + expect( Sqed::BoundaryFinder.frequency_stats(i, 20)).to eq(nil) end + + end context 'offset boundaries from crossy_black_line_specimen image ' do before(:all) { @s = Sqed.new(image: ImageHelpers.crossy_black_line_specimen, pattern: :vertical_offset_cross, boundary_color: :black)