spec/shoes/swt/link_segment_spec.rb in shoes-swt-4.0.0.pre6 vs spec/shoes/swt/link_segment_spec.rb in shoes-swt-4.0.0.pre7

- old
+ new

@@ -3,17 +3,19 @@ describe Shoes::Swt::LinkSegment do let(:range) { (2..10) } let(:line_width) { 20 } let(:line_height) { 14 } let(:layout) { double('swt layout', width: line_width, line_count: 10) } - let(:text_segment) { double('text segment', layout: layout, - element_left: 0, element_top: 0) } + let(:text_segment) do + double('text segment', layout: layout, element_left: 0, element_top: 0) + end + subject { Shoes::Swt::LinkSegment.new(text_segment, range) } before(:each) do - 10.times {|i| stub_line_bounds(i)} + 10.times { |i| stub_line_bounds(i) } end # .................... context "empty link" do let(:range) { (0...0) } @@ -35,66 +37,66 @@ # xxxxx............... it "sets bounds wrapping to second line" do stub_start_and_end_locations([0, 0], [5, line_height]) expect_bounded_box(0, 0, line_width, line_height) - expect_bounded_box(0, line_height, 5, 2*line_height) + expect_bounded_box(0, line_height, 5, 2 * line_height) end # .....xxxxxxxxxxxxxxx # xxxxxxxxxxxxxxxxxxxx # xxxxx............... it "sets bounds wrapping over three lines" do - stub_start_and_end_locations([5, 0], [5, 2*line_height]) + stub_start_and_end_locations([5, 0], [5, 2 * line_height]) expect_bounded_box(5, 0, line_width, line_height) - expect_bounded_box(0, line_height, line_width, 2*line_height) - expect_bounded_box(0, 2*line_height, 5, 3*line_height) + expect_bounded_box(0, line_height, line_width, 2 * line_height) + expect_bounded_box(0, 2 * line_height, 5, 3 * line_height) end # .................... # .....xxxxxxxxxx..... it "sets bounds with single line beginning further down" do stub_start_and_end_locations([5, line_height], [15, line_height]) - expect_bounded_box(5, line_height, 15, 2*line_height) + expect_bounded_box(5, line_height, 15, 2 * line_height) end # .................... # ...............xxxxx # xxxxx............... it "sets bounds with two lines beginning further down" do - stub_start_and_end_locations([15, line_height], [5, 2*line_height]) + stub_start_and_end_locations([15, line_height], [5, 2 * line_height]) - expect_bounded_box(15, line_height, 15, 2*line_height) - expect_bounded_box(0, 2*line_height, 5, 3*line_height) + expect_bounded_box(15, line_height, 15, 2 * line_height) + expect_bounded_box(0, 2 * line_height, 5, 3 * line_height) end # .................... # ...............xxxxx # xxxxxxxxxxxxxxxxxxxx # xxxxx............... it "sets bounds with three lines beginning further down" do - stub_start_and_end_locations([15, line_height], [5, 3*line_height]) + stub_start_and_end_locations([15, line_height], [5, 3 * line_height]) - expect_bounded_box(15, line_height, 15, 2*line_height) - expect_bounded_box(0, 2*line_height, line_width, 3*line_height) - expect_bounded_box(0, 3*line_height, 5, 4*line_height) + expect_bounded_box(15, line_height, 15, 2 * line_height) + expect_bounded_box(0, 2 * line_height, line_width, 3 * line_height) + expect_bounded_box(0, 3 * line_height, 5, 4 * line_height) end def expect_bounded_box(left, top, right, bottom) expect_in_bounds([left, top], [right, top], - [left, bottom], [right,bottom]) + [left, bottom], [right, bottom]) end def expect_in_bounds(*points) - points.each do |(x,y)| + points.each do |(x, y)| expect(subject.in_bounds?(x, y)).to be_truthy, "with #{x}, #{y}" end end def expect_not_in_bounds(*points) - points.each do |(x,y)| + points.each do |(x, y)| expect(subject.in_bounds?(x, y)).to be_falsey, "with #{x}, #{y}" end end def stub_start_and_end_locations(first, last)