spec/shoes/swt/text_block_spec.rb in shoes-swt-4.0.0.pre4 vs spec/shoes/swt/text_block_spec.rb in shoes-swt-4.0.0.pre5
- old
+ new
@@ -1,17 +1,17 @@
-require 'shoes/swt/spec_helper'
+require 'spec_helper'
describe Shoes::Swt::TextBlock do
include_context "swt app"
let(:height) { 100 }
let(:width) { 200 }
let(:margin) { 10 }
let(:dsl) { double("dsl", app: shoes_app, text: "text",
- margin_left: 0, margin_right: 0,
- margin_top: 0, margin_bottom: 0,
- pass_coordinates?: nil).as_null_object }
+ margin_left: 0, margin_right: 0,
+ margin_top: 0, margin_bottom: 0,
+ pass_coordinates?: nil).as_null_object }
subject { Shoes::Swt::TextBlock.new(dsl, swt_app) }
it_behaves_like "paintable"
it_behaves_like "updating visibility"
@@ -54,10 +54,11 @@
describe "with single segment" do
before(:each) do
allow(dsl).to receive(:absolute_left) { 50 }
allow(dsl).to receive(:absolute_top) { 0 }
allow(dsl).to receive(:absolute_bottom) { layout_height }
+ allow(dsl).to receive(:element_width) { nil }
end
it "positions single line of text" do
expect(dsl).to receive(:absolute_right=).with(layout_width + 50 - 1)
expect(dsl).to receive(:absolute_bottom=).with(layout_height - 1)
@@ -67,11 +68,11 @@
expect(current_position.y).to eq(layout_height - line_height + 1)
end
it "positions single line with margin" do
allow(dsl).to receive_messages(margin_left: margin, margin_right: margin,
- margin_top: margin, margin_bottom: margin)
+ margin_top: margin, margin_bottom: margin)
expect(dsl).to receive(:absolute_right=).with(layout_width + 50 + margin - 1)
expect(dsl).to receive(:absolute_bottom=).with(layout_height + 2 * margin - 1)
when_aligns_and_positions
@@ -141,10 +142,11 @@
describe "with two segments" do
before(:each) do
allow(dsl).to receive(:parent) { double("dsl parent", absolute_left: 0) }
allow(dsl).to receive(:absolute_bottom) { layout_height }
+ allow(dsl).to receive(:element_width) { nil }
current_position.next_line_start = 0
allow(fitter).to receive(:fit_it_in) {
[create_segment("unused segment"),
@@ -161,11 +163,11 @@
expect(current_position.y).to eq(layout_height - line_height + 1)
end
it "positions in two segments with margins" do
allow(dsl).to receive_messages(margin_left: margin, margin_right: margin,
- margin_top: margin, margin_bottom: margin)
+ margin_top: margin, margin_bottom: margin)
expect(dsl).to receive(:absolute_right=).with(layout_width + margin - 1)
expect(dsl).to receive(:absolute_bottom=).with(layout_height + 2 * margin - 1)
when_aligns_and_positions
@@ -191,16 +193,16 @@
expect(link).to receive(:remove)
subject.replace("text")
end
end
- def create_segment(name="segment", width=layout_width,
- height=layout_height, line_height=line_height)
+ def create_segment(name = "segment", width = layout_width,
+ height = layout_height, line_height = line_height)
bounds = double("bounds", width: width, height: height)
double(name, disposed?: false, style_from: nil,
- width: width, height: height,
- last_line_width: width, last_line_height: line_height,
- bounds: bounds)
+ width: width, height: height,
+ last_line_width: width, last_line_height: line_height,
+ bounds: bounds)
end
def when_aligns_and_positions
subject.contents_alignment(current_position)
subject.adjust_current_position(current_position)