shoes-core 4.0.0.pre7 → 4.0.0.pre8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shoes/arc.rb +10 -13
- data/lib/shoes/arrow.rb +1 -11
- data/lib/shoes/background.rb +0 -3
- data/lib/shoes/border.rb +0 -3
- data/lib/shoes/button.rb +4 -1
- data/lib/shoes/check_button.rb +0 -1
- data/lib/shoes/common/art_element.rb +21 -0
- data/lib/shoes/common/background_element.rb +10 -0
- data/lib/shoes/common/clickable.rb +2 -0
- data/lib/shoes/common/rotate.rb +1 -2
- data/lib/shoes/common/ui_element.rb +10 -1
- data/lib/shoes/core/version.rb +1 -1
- data/lib/shoes/download.rb +47 -29
- data/lib/shoes/dsl.rb +99 -40
- data/lib/shoes/font.rb +0 -4
- data/lib/shoes/http_request.rb +91 -0
- data/lib/shoes/image.rb +0 -1
- data/lib/shoes/input_box.rb +0 -1
- data/lib/shoes/internal_app.rb +1 -1
- data/lib/shoes/line.rb +25 -11
- data/lib/shoes/link.rb +10 -4
- data/lib/shoes/list_box.rb +0 -1
- data/lib/shoes/mock/app.rb +6 -0
- data/lib/shoes/mock/clickable.rb +3 -0
- data/lib/shoes/mock/font.rb +0 -4
- data/lib/shoes/oval.rb +3 -13
- data/lib/shoes/progress.rb +0 -1
- data/lib/shoes/rect.rb +1 -11
- data/lib/shoes/shape.rb +16 -8
- data/lib/shoes/slot.rb +2 -1
- data/lib/shoes/star.rb +8 -11
- data/lib/shoes/text_block.rb +0 -1
- data/lib/shoes/ui/picker.rb +29 -8
- data/lib/shoes/version.rb +1 -1
- metadata +8 -231
- data/Guardfile +0 -5
- data/Rakefile +0 -1
- data/bin/shoes-stub +0 -62
- data/ext/install/Rakefile +0 -39
- data/ext/install/shoes.bat +0 -17
- data/lib/rubygems_plugin.rb +0 -24
- data/shoes-core.gemspec +0 -22
- data/spec/shoes/animation_spec.rb +0 -71
- data/spec/shoes/app_spec.rb +0 -454
- data/spec/shoes/arc_spec.rb +0 -52
- data/spec/shoes/arrow_spec.rb +0 -28
- data/spec/shoes/background_spec.rb +0 -47
- data/spec/shoes/border_spec.rb +0 -46
- data/spec/shoes/builtin_methods_spec.rb +0 -122
- data/spec/shoes/button_spec.rb +0 -55
- data/spec/shoes/check_spec.rb +0 -36
- data/spec/shoes/color_spec.rb +0 -429
- data/spec/shoes/common/attachable_spec.rb +0 -32
- data/spec/shoes/common/inspect_spec.rb +0 -26
- data/spec/shoes/common/remove_spec.rb +0 -37
- data/spec/shoes/common/rotate_spec.rb +0 -13
- data/spec/shoes/common/style_normalizer_spec.rb +0 -28
- data/spec/shoes/common/style_spec.rb +0 -197
- data/spec/shoes/common/translate_spec.rb +0 -27
- data/spec/shoes/configuration_spec.rb +0 -51
- data/spec/shoes/constants_spec.rb +0 -39
- data/spec/shoes/dialog_spec.rb +0 -169
- data/spec/shoes/dimension_spec.rb +0 -451
- data/spec/shoes/dimensions_spec.rb +0 -868
- data/spec/shoes/download_spec.rb +0 -198
- data/spec/shoes/flow_spec.rb +0 -132
- data/spec/shoes/font_spec.rb +0 -36
- data/spec/shoes/framework_learning_spec.rb +0 -31
- data/spec/shoes/gradient_spec.rb +0 -31
- data/spec/shoes/helpers/fake_absolute_element.rb +0 -31
- data/spec/shoes/helpers/fake_element.rb +0 -25
- data/spec/shoes/helpers/inspect_helpers.rb +0 -5
- data/spec/shoes/helpers/sample17_helper.rb +0 -65
- data/spec/shoes/image_spec.rb +0 -69
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +0 -80
- data/spec/shoes/integration_spec.rb +0 -19
- data/spec/shoes/internal_app_spec.rb +0 -148
- data/spec/shoes/keypress_spec.rb +0 -11
- data/spec/shoes/keyrelease_spec.rb +0 -11
- data/spec/shoes/line_spec.rb +0 -120
- data/spec/shoes/link_spec.rb +0 -149
- data/spec/shoes/list_box_spec.rb +0 -87
- data/spec/shoes/logger/ruby_spec.rb +0 -8
- data/spec/shoes/logger_spec.rb +0 -45
- data/spec/shoes/oval_spec.rb +0 -25
- data/spec/shoes/packager_spec.rb +0 -25
- data/spec/shoes/point_spec.rb +0 -99
- data/spec/shoes/progress_spec.rb +0 -54
- data/spec/shoes/radio_spec.rb +0 -32
- data/spec/shoes/rect_spec.rb +0 -40
- data/spec/shoes/renamed_delegate_spec.rb +0 -69
- data/spec/shoes/shape_spec.rb +0 -119
- data/spec/shoes/shared_examples/button.rb +0 -6
- data/spec/shoes/shared_examples/changeable.rb +0 -26
- data/spec/shoes/shared_examples/clickable.rb +0 -5
- data/spec/shoes/shared_examples/common_methods.rb +0 -35
- data/spec/shoes/shared_examples/dimensions.rb +0 -32
- data/spec/shoes/shared_examples/dsl.rb +0 -44
- data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
- data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
- data/spec/shoes/shared_examples/dsl/background.rb +0 -26
- data/spec/shoes/shared_examples/dsl/border.rb +0 -10
- data/spec/shoes/shared_examples/dsl/button.rb +0 -5
- data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
- data/spec/shoes/shared_examples/dsl/check.rb +0 -11
- data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
- data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
- data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
- data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
- data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
- data/spec/shoes/shared_examples/dsl/gradient.rb +0 -62
- data/spec/shoes/shared_examples/dsl/image.rb +0 -21
- data/spec/shoes/shared_examples/dsl/line.rb +0 -9
- data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
- data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
- data/spec/shoes/shared_examples/dsl/oval.rb +0 -88
- data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
- data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
- data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
- data/spec/shoes/shared_examples/dsl/rgb.rb +0 -28
- data/spec/shoes/shared_examples/dsl/shape.rb +0 -61
- data/spec/shoes/shared_examples/dsl/star.rb +0 -110
- data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
- data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
- data/spec/shoes/shared_examples/dsl/style.rb +0 -32
- data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -84
- data/spec/shoes/shared_examples/dsl/video.rb +0 -5
- data/spec/shoes/shared_examples/dsl_app_context.rb +0 -11
- data/spec/shoes/shared_examples/hover.rb +0 -78
- data/spec/shoes/shared_examples/parent.rb +0 -6
- data/spec/shoes/shared_examples/scroll.rb +0 -41
- data/spec/shoes/shared_examples/shared_element_method.rb +0 -60
- data/spec/shoes/shared_examples/slot.rb +0 -441
- data/spec/shoes/shared_examples/state.rb +0 -26
- data/spec/shoes/shared_examples/style.rb +0 -77
- data/spec/shoes/slot_spec.rb +0 -176
- data/spec/shoes/sound_spec.rb +0 -16
- data/spec/shoes/span_spec.rb +0 -112
- data/spec/shoes/spec_helper.rb +0 -24
- data/spec/shoes/stack_spec.rb +0 -79
- data/spec/shoes/star_spec.rb +0 -49
- data/spec/shoes/text_block_dimensions_spec.rb +0 -77
- data/spec/shoes/text_block_spec.rb +0 -314
- data/spec/shoes/text_spec.rb +0 -22
- data/spec/shoes/ui/picker_spec.rb +0 -69
- data/spec/shoes/url_spec.rb +0 -67
- data/spec/shoes/widget_spec.rb +0 -78
- data/spec/shoes_spec.rb +0 -41
- data/spec/spec_helper.rb +0 -27
data/spec/shoes/star_spec.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for "basic star" do
|
4
|
-
it "retains app" do
|
5
|
-
expect(subject.app).to eq(app)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "creates gui object" do
|
9
|
-
expect(subject.gui).not_to be_nil
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe Shoes::Star do
|
14
|
-
include_context "dsl app"
|
15
|
-
|
16
|
-
let(:left) { 44 }
|
17
|
-
let(:top) { 66 }
|
18
|
-
let(:width) { 100 }
|
19
|
-
let(:height) { 100 }
|
20
|
-
|
21
|
-
subject { Shoes::Star.new(app, parent, left, top, 5, 50, 30) }
|
22
|
-
|
23
|
-
it_behaves_like "basic star"
|
24
|
-
it_behaves_like "object with style" do
|
25
|
-
let(:subject_without_style) { Shoes::Star.new(app, parent, left, top, 5, 50, 30) }
|
26
|
-
let(:subject_with_style) { Shoes::Star.new(app, parent, left, top, 5, 50, 30, arg_styles) }
|
27
|
-
end
|
28
|
-
|
29
|
-
it_behaves_like "object with dimensions"
|
30
|
-
it_behaves_like "movable object"
|
31
|
-
it_behaves_like 'object with parent'
|
32
|
-
it_behaves_like "object with hover"
|
33
|
-
|
34
|
-
describe "in_bounds?" do
|
35
|
-
before do
|
36
|
-
# Gotta pretend like we've been positioned
|
37
|
-
subject.x_dimension.absolute_start = subject.left
|
38
|
-
subject.y_dimension.absolute_start = subject.top
|
39
|
-
end
|
40
|
-
|
41
|
-
it "in bounds" do
|
42
|
-
expect(subject.in_bounds?(50, 50)).to eq(true)
|
43
|
-
end
|
44
|
-
|
45
|
-
it "out of bounds" do
|
46
|
-
expect(subject.in_bounds?(200, 200)).to eq(false)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,77 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::TextBlockDimensions do
|
4
|
-
let(:left) { 0 }
|
5
|
-
let(:top) { 10 }
|
6
|
-
let(:width) { 5 }
|
7
|
-
let(:height) { 10 }
|
8
|
-
|
9
|
-
let(:old_dimension) { Shoes::Dimensions.new(nil, left, top, width, height) }
|
10
|
-
subject { Shoes::TextBlockDimensions.new(nil, left, top, width, height) }
|
11
|
-
|
12
|
-
before(:each) do
|
13
|
-
old_dimension.absolute_left = subject.absolute_left = 0
|
14
|
-
old_dimension.absolute_top = subject.absolute_top = 0
|
15
|
-
end
|
16
|
-
|
17
|
-
describe "positions" do
|
18
|
-
it "inherits from base" do
|
19
|
-
expect(subject.absolute_right).to eq(old_dimension.absolute_right)
|
20
|
-
expect(subject.absolute_bottom).to eq(old_dimension.absolute_bottom)
|
21
|
-
end
|
22
|
-
|
23
|
-
it "overrides absolute right" do
|
24
|
-
subject.absolute_right = 200
|
25
|
-
expect(subject.absolute_right).to eq(200)
|
26
|
-
end
|
27
|
-
|
28
|
-
it "overrides absolute bottom" do
|
29
|
-
subject.absolute_bottom = 200
|
30
|
-
expect(subject.absolute_bottom).to eq(200)
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "calculated sizes" do
|
35
|
-
it "inherits from base" do
|
36
|
-
expect(subject.width).to eq(5)
|
37
|
-
expect(subject.height).to eq(10)
|
38
|
-
end
|
39
|
-
|
40
|
-
it "override with calculated width" do
|
41
|
-
subject.width = nil
|
42
|
-
subject.calculated_width = 200
|
43
|
-
expect(subject.width).to eq(200)
|
44
|
-
end
|
45
|
-
|
46
|
-
it "override with calculated height" do
|
47
|
-
subject.height = nil
|
48
|
-
subject.calculated_height = 200
|
49
|
-
expect(subject.height).to eq(200)
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "containing width" do
|
54
|
-
it "uses immediate width if it can" do
|
55
|
-
expect(subject.containing_width).to eq(5)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "applies margins" do
|
59
|
-
subject.margin = 1
|
60
|
-
expect(subject.containing_width).to eq(3)
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "with parent" do
|
64
|
-
let(:parent) do
|
65
|
-
double('parent', element_width: 100,
|
66
|
-
x_dimension: double("x"),
|
67
|
-
y_dimension: double("y"))
|
68
|
-
end
|
69
|
-
|
70
|
-
subject { Shoes::TextBlockDimensions.new(parent, left, top, nil, height) }
|
71
|
-
|
72
|
-
it "delegates to parent if no width of its own" do
|
73
|
-
expect(subject.containing_width).to eq(100)
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
@@ -1,314 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shoes/helpers/sample17_helper'
|
3
|
-
|
4
|
-
describe Shoes::TextBlock do
|
5
|
-
include_context "dsl app"
|
6
|
-
|
7
|
-
let(:text_link) { Shoes::Link.new(app, ['Hello']) }
|
8
|
-
let(:text) { [text_link, ", world!"] }
|
9
|
-
subject(:text_block) { Shoes::Para.new(app, parent, text, app: app) }
|
10
|
-
|
11
|
-
it_behaves_like "object with style" do
|
12
|
-
let(:subject_without_style) { Shoes::Para.new(app, parent, text) }
|
13
|
-
let(:subject_with_style) { Shoes::Para.new(app, parent, text, arg_styles) }
|
14
|
-
end
|
15
|
-
|
16
|
-
it_behaves_like "object with hover"
|
17
|
-
|
18
|
-
describe "initialize" do
|
19
|
-
it "creates gui object" do
|
20
|
-
expect(text_block.gui).not_to be_nil
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe "text" do
|
25
|
-
context "with an array of [Shoes::Link, String]" do
|
26
|
-
it "sets text" do
|
27
|
-
expect(text_block.text).to eq "Hello, world!"
|
28
|
-
end
|
29
|
-
|
30
|
-
it "changes the text" do
|
31
|
-
text_block.text = "Goodbye Cruel World"
|
32
|
-
expect(text_block.text).to eq "Goodbye Cruel World"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "with a single string" do
|
37
|
-
let(:text) { "Hello, world!" }
|
38
|
-
|
39
|
-
it "sets text" do
|
40
|
-
expect(text_block.text).to eq "Hello, world!"
|
41
|
-
end
|
42
|
-
|
43
|
-
it "changes the text" do
|
44
|
-
text_block.text = "Goodbye Cruel World"
|
45
|
-
expect(text_block.text).to eq "Goodbye Cruel World"
|
46
|
-
end
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "#takes_up_space?" do
|
51
|
-
it "does with default alignment" do
|
52
|
-
expect(text_block.takes_up_space?).to eq(true)
|
53
|
-
end
|
54
|
-
|
55
|
-
it "does when left aligned" do
|
56
|
-
text_block.align = "left"
|
57
|
-
expect(text_block.takes_up_space?).to eq(true)
|
58
|
-
end
|
59
|
-
|
60
|
-
it "doesn't when right aligned" do
|
61
|
-
text_block.align = "right"
|
62
|
-
expect(text_block.takes_up_space?).to eq(false)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe "#to_s" do
|
67
|
-
it "is the same as #text" do
|
68
|
-
text = text_block.text
|
69
|
-
expect(text_block.to_s).to eq(text)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe "#replace" do
|
74
|
-
it "replaces text" do
|
75
|
-
text_block.replace "Goodbye Cruel World"
|
76
|
-
expect(text_block.text).to eq("Goodbye Cruel World")
|
77
|
-
end
|
78
|
-
|
79
|
-
it "allows two arguments" do
|
80
|
-
text_block.replace "Goodbye Cruel World, ", text_link
|
81
|
-
expect(text_block.text).to eq("Goodbye Cruel World, Hello")
|
82
|
-
end
|
83
|
-
|
84
|
-
it "updates contents" do
|
85
|
-
text_block.replace("Later Gator")
|
86
|
-
expect(text_block.contents).to eq(["Later Gator"])
|
87
|
-
end
|
88
|
-
|
89
|
-
it "updates text styles" do
|
90
|
-
text_block.replace "Later Gator"
|
91
|
-
expect(text_block.text_styles).to be_empty
|
92
|
-
end
|
93
|
-
|
94
|
-
it "updates styles from options hash" do
|
95
|
-
text_block.replace "Later Gator", stroke: Shoes::COLORS[:aquamarine]
|
96
|
-
expect(text_block.stroke).to eq(Shoes::COLORS[:aquamarine])
|
97
|
-
end
|
98
|
-
|
99
|
-
it "updates font from options hash" do
|
100
|
-
text_block.replace "Later Gator", font: 'Monospace 18px'
|
101
|
-
expect(text_block.font).to eq('Monospace')
|
102
|
-
expect(text_block.size).to eq(18)
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
|
-
describe "#contents" do
|
107
|
-
it "returns text elements" do
|
108
|
-
expect(text_block.contents).to eql([text_link, ", world!"])
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
describe "font" do
|
113
|
-
let(:text_block) { Shoes::Para.new(app, parent, ["Hello, world!"], style) }
|
114
|
-
|
115
|
-
context "with defaults" do
|
116
|
-
let(:style) { Hash.new }
|
117
|
-
|
118
|
-
it "sets the default font to Arial" do
|
119
|
-
expect(text_block.font).to eq "Arial"
|
120
|
-
end
|
121
|
-
end
|
122
|
-
|
123
|
-
context "with a font family string" do
|
124
|
-
let(:style) { { font: "Helvetica" } }
|
125
|
-
|
126
|
-
it "sets the font family" do
|
127
|
-
expect(text_block.font).to eq "Helvetica"
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
context "with a font family string and size with 'px'" do
|
132
|
-
let(:style) { { font: "Helvetica 33px" } }
|
133
|
-
|
134
|
-
it "sets the font family" do
|
135
|
-
expect(text_block.font).to eq "Helvetica"
|
136
|
-
end
|
137
|
-
|
138
|
-
it "sets the font size" do
|
139
|
-
expect(text_block.size).to eq 33
|
140
|
-
end
|
141
|
-
end
|
142
|
-
|
143
|
-
context "with a font family string and size with ' px'" do
|
144
|
-
let(:style) { { font: "Helvetica 33 px" } }
|
145
|
-
|
146
|
-
it "sets the font family" do
|
147
|
-
expect(text_block.font).to eq "Helvetica"
|
148
|
-
end
|
149
|
-
|
150
|
-
it "sets the font size" do
|
151
|
-
expect(text_block.size).to eq 33
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
context "with a quoted font family string and size with 'px'" do
|
156
|
-
let(:style) { { font: '"Comic Sans" 13px' } }
|
157
|
-
|
158
|
-
it "sets the font family" do
|
159
|
-
expect(text_block.font).to eq "Comic Sans"
|
160
|
-
end
|
161
|
-
|
162
|
-
it "sets the size" do
|
163
|
-
expect(text_block.size).to eq 13
|
164
|
-
end
|
165
|
-
end
|
166
|
-
end
|
167
|
-
|
168
|
-
describe "stroke" do
|
169
|
-
it "should accept a hex code" do
|
170
|
-
s = Shoes::Para.new(app, parent, ["Hello, world!"], stroke: "#fda", app: app)
|
171
|
-
color = s.style[:stroke]
|
172
|
-
expect(color.red).to eql 255
|
173
|
-
expect(color.green).to eql 221
|
174
|
-
expect(color.blue).to eql 170
|
175
|
-
end
|
176
|
-
end
|
177
|
-
|
178
|
-
describe "width" do
|
179
|
-
before(:each) do
|
180
|
-
allow(parent).to receive(:element_width) { 300 }
|
181
|
-
allow(parent).to receive(:absolute_left) { 0 }
|
182
|
-
end
|
183
|
-
|
184
|
-
context "when not explicitly set" do
|
185
|
-
subject(:text_block) { Shoes::Para.new(app, parent, ["text"]) }
|
186
|
-
|
187
|
-
it "delegates to calculated width" do
|
188
|
-
subject.calculated_width = 240
|
189
|
-
expect(subject.width).to eql 240
|
190
|
-
end
|
191
|
-
|
192
|
-
it "delegates to calculated height" do
|
193
|
-
subject.calculated_height = 240
|
194
|
-
expect(subject.height).to eql 240
|
195
|
-
end
|
196
|
-
|
197
|
-
it "bases desired width off parent" do
|
198
|
-
subject.absolute_left = 20
|
199
|
-
expect(subject.desired_width).to eql 280
|
200
|
-
end
|
201
|
-
|
202
|
-
it "can base desired off explicit containing width" do
|
203
|
-
subject.absolute_left = 20
|
204
|
-
expect(subject.desired_width(1000)).to eql(980)
|
205
|
-
end
|
206
|
-
|
207
|
-
it "factors margins into desired width" do
|
208
|
-
subject.absolute_left = 0
|
209
|
-
subject.margin = 10
|
210
|
-
expect(subject.desired_width(1000)).to eql(980)
|
211
|
-
end
|
212
|
-
end
|
213
|
-
|
214
|
-
context "when explicitly set" do
|
215
|
-
subject(:text_block) { Shoes::Para.new(app, parent, ["text"], width: 120) }
|
216
|
-
|
217
|
-
it "gets returned" do
|
218
|
-
expect(subject.width).to eql 120
|
219
|
-
end
|
220
|
-
|
221
|
-
it "is used for desired width" do
|
222
|
-
expect(subject.desired_width).to eql 120
|
223
|
-
end
|
224
|
-
|
225
|
-
it "factors in if parent space is too small" do
|
226
|
-
subject.absolute_left = parent.element_width - 100
|
227
|
-
expect(subject.desired_width).to eql(100)
|
228
|
-
end
|
229
|
-
end
|
230
|
-
end
|
231
|
-
|
232
|
-
context "cursor management" do
|
233
|
-
let(:textcursor) { double("textcursor") }
|
234
|
-
|
235
|
-
before(:each) do
|
236
|
-
allow(app).to receive(:textcursor) { textcursor }
|
237
|
-
end
|
238
|
-
|
239
|
-
it "creates a textcursor" do
|
240
|
-
expect(subject.textcursor).to eq(textcursor)
|
241
|
-
expect(app).to have_received(:textcursor)
|
242
|
-
end
|
243
|
-
|
244
|
-
it "only creates textcursor" do
|
245
|
-
original = subject.textcursor
|
246
|
-
allow(app).to receive(:textcursor) { double("new cursor") }
|
247
|
-
|
248
|
-
expect(subject.textcursor).to eq(original)
|
249
|
-
expect(app).to have_received(:textcursor).once
|
250
|
-
end
|
251
|
-
end
|
252
|
-
|
253
|
-
context "with empty subelements" do
|
254
|
-
let!(:link) { actual_app.link('') }
|
255
|
-
let!(:span) { actual_app.span('') }
|
256
|
-
let!(:para) { actual_app.para(link, span) }
|
257
|
-
let(:actual_app) { app.app }
|
258
|
-
|
259
|
-
it "properly ignores empty element lengths in text_styles" do
|
260
|
-
text_styles = { 0...0 => [link, span] }
|
261
|
-
|
262
|
-
expect(para.text_styles).to eq(text_styles)
|
263
|
-
end
|
264
|
-
end
|
265
|
-
|
266
|
-
# Emulates samples/sample17.rb
|
267
|
-
#
|
268
|
-
# Shoes.app width: 240, height: 95 do
|
269
|
-
# para 'Testing, test, test. ',
|
270
|
-
# strong('Breadsticks. '),
|
271
|
-
# em('Breadsticks. '),
|
272
|
-
# code('Breadsticks. '),
|
273
|
-
# bg(fg(strong(ins('EVEN BETTER.')), white), rgb(255, 0, 192)),
|
274
|
-
# sub('fine!')
|
275
|
-
# end
|
276
|
-
#
|
277
|
-
context "with nested text fragments" do
|
278
|
-
let(:helper) { Sample17Helper.new(app) }
|
279
|
-
let!(:para) { helper.create_para }
|
280
|
-
|
281
|
-
it "has full text of fragments" do
|
282
|
-
expect(para.text).to eq("Testing, test, test. Breadsticks. Breadsticks. Breadsticks. EVEN BETTER.fine!")
|
283
|
-
end
|
284
|
-
|
285
|
-
it "has fragment styles" do
|
286
|
-
text_styles = {
|
287
|
-
21..33 => [helper.strong_breadsticks],
|
288
|
-
34..46 => [helper.em],
|
289
|
-
47..59 => [helper.code],
|
290
|
-
60..71 => [helper.bg, helper.fg, helper.strong, helper.ins],
|
291
|
-
72..76 => [helper.sub]
|
292
|
-
}
|
293
|
-
expect(para.text_styles).to eq(text_styles)
|
294
|
-
end
|
295
|
-
|
296
|
-
it 'sets the parent_text of the non nested texts to the para' do
|
297
|
-
expect(helper.strong_breadsticks.parent).to eq para
|
298
|
-
end
|
299
|
-
|
300
|
-
it 'sets the parent_text of nested fragments correctly' do
|
301
|
-
expect(helper.ins.parent).to eq helper.strong
|
302
|
-
end
|
303
|
-
|
304
|
-
it 'lets the nested text fragements know what their text block is' do
|
305
|
-
expect(helper.ins.text_block).to eq para
|
306
|
-
end
|
307
|
-
end
|
308
|
-
|
309
|
-
describe "links" do
|
310
|
-
it "finds em" do
|
311
|
-
expect(text_block.links).to eq([text_link])
|
312
|
-
end
|
313
|
-
end
|
314
|
-
end
|
data/spec/shoes/text_spec.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Text do
|
4
|
-
include_context "dsl app"
|
5
|
-
|
6
|
-
let(:link) { Shoes::Link.new(app, ['link']) }
|
7
|
-
|
8
|
-
it "finds no links" do
|
9
|
-
text = Shoes::Text.new(['text'])
|
10
|
-
expect(text.links).to be_empty
|
11
|
-
end
|
12
|
-
|
13
|
-
it "finds a link" do
|
14
|
-
text = Shoes::Text.new(['text', link])
|
15
|
-
expect(text.links).to eq([link])
|
16
|
-
end
|
17
|
-
|
18
|
-
it "finds multiple" do
|
19
|
-
text = Shoes::Text.new([Shoes::Text.new(['yo', link]), link])
|
20
|
-
expect(text.links).to eq([link, link])
|
21
|
-
end
|
22
|
-
end
|