spec/shoes/swt/text_block/fitter_spec.rb in shoes-swt-4.0.0.pre3 vs spec/shoes/swt/text_block/fitter_spec.rb in shoes-swt-4.0.0.pre4

- old
+ new

@@ -142,22 +142,23 @@ end context "to empty first segment" do before(:each) do allow(dsl).to receive_messages(containing_width: 100) + expect(segment).to receive(:fill_background=).with(true) end it "rolls to second segment when 0 remaining width" do allow(dsl).to receive_messages(desired_width: 0) segments = when_fit_at(x: 0, y: 75, next_line_start: 95) - expect_segments(segments, [26, 76], [1, 97]) + expect_segments(segments, [26, 76], [1, 96]) end it "rolls to second segment when negative remaining width" do allow(dsl).to receive_messages(desired_width: -1) segments = when_fit_at(x: 0, y: 75, next_line_start: 95) - expect_segments(segments, [26, 76], [1, 97]) + expect_segments(segments, [26, 76], [1, 96]) end end context "to center segment" do before do @@ -172,16 +173,30 @@ end it "bumps down a line if not at start" do allow(dsl).to receive_messages(element_left: 20, left: 20) segments = when_fit_at(x: 20, y: 75, next_line_start: 95) - expect_segments(segments, [20, 76], [1, 96]) + expect_segments(segments, [20, 76], [1, 95]) end it "if unbounded height, still bumps down properly" do allow(dsl).to receive_messages(absolute_top: 95, element_left: 20, left: 20, margin_left: 1) segments = when_fit_at(x: 20, y: 75, next_line_start: 95) - expect_segments(segments, [20, 76], [1, 96]) + expect_segments(segments, [20, 76], [1, 95]) + end + end + + context "doesn't fit" do + it "with no width and unbounded height" do + allow(dsl).to receive_messages(desired_width: 0) + segments = when_fit_at(x: 0, y: 0, next_line_start: 0) + expect(segments).to be_empty + end + + it "with no width and 0 height" do + allow(dsl).to receive_messages(desired_width: 0, containing_width: 0) + segments = when_fit_at(x: 0, y: 0, next_line_start: 1) + expect(segments).to be_empty end end end def with_text_split(first, second)