shoes 4.0.0.pre1 → 4.0.0.pre2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG +84 -32
- data/Gemfile +22 -1
- data/README.md +28 -13
- data/Rakefile +7 -210
- data/bin/ruby-shoes +2 -2
- data/ext/install/shoes.bat +4 -1
- data/lib/shoes.rb +1 -121
- data/lib/shoes/{cli.rb → ui/cli.rb} +7 -1
- data/lib/shoes/{help.rb → ui/help.rb} +2 -2
- data/lib/shoes/{manual.rb → ui/manual.rb} +1 -1
- data/lib/shoes/version.rb +1 -1
- data/manifests/common.rb +34 -0
- data/manifests/shoes.rb +44 -0
- data/samples/Gemfile +3 -0
- data/samples/Gemfile.lock +35 -0
- data/samples/README +16 -5
- data/samples/boom.rb +239 -0
- data/samples/clicky.rb +24 -0
- data/samples/flow.rb +63 -0
- data/samples/gray.rb +11 -0
- data/samples/nks_booklist.rb +24 -0
- data/samples/nks_breadsticks.rb +7 -0
- data/samples/nks_dancing_circle.rb +13 -0
- data/samples/nks_dictionary.rb +23 -0
- data/samples/nks_edit_box.rb +4 -0
- data/samples/nks_edit_line.rb +6 -0
- data/samples/nks_notes.rb +16 -0
- data/samples/nks_self.rb +6 -0
- data/samples/nks_text_sizes.rb +10 -0
- data/samples/nks_trurl.rb +5 -0
- data/samples/packaging/package_me.rb +6 -0
- data/samples/present.rb +27 -0
- data/samples/progress.rb +10 -0
- data/samples/sample31.rb +1 -1
- data/samples/simple-calc.rb +1 -1
- data/samples/simple-tictactoe.rb +238 -0
- data/samples/simple-visibility.rb +11 -0
- data/samples/simple-widget.rb +9 -0
- data/samples/swt-raw.rb +20 -0
- data/samples/troll.rb +22 -0
- data/shoes.gemspec +10 -22
- data/snapshots/sample56.png +0 -0
- data/static/manual-en.txt +16 -7
- data/tasks/changelog.rb +92 -0
- data/tasks/gem.rb +38 -0
- data/tasks/rspec.rb +106 -0
- data/tasks/sample.rb +66 -0
- data/tasks/yard.rb +13 -0
- metadata +55 -488
- data/.gitignore +0 -53
- data/.rspec +0 -3
- data/.ruby-gemset +0 -1
- data/.ruby-version +0 -1
- data/.travis.yml +0 -31
- data/bin/shoes +0 -59
- data/bin/shoes.bat +0 -6
- data/fonts/Coolvetica.ttf +0 -0
- data/fonts/Lacuna.ttf +0 -0
- data/lib/ext/highlighter.rb +0 -2
- data/lib/ext/highlighter/common.rb +0 -197
- data/lib/ext/highlighter/lang/ruby.rb +0 -316
- data/lib/ext/highlighter/markup.rb +0 -222
- data/lib/rubygems_plugin.rb +0 -19
- data/lib/shoes/animation.rb +0 -55
- data/lib/shoes/app.rb +0 -320
- data/lib/shoes/arc.rb +0 -35
- data/lib/shoes/background.rb +0 -30
- data/lib/shoes/border.rb +0 -33
- data/lib/shoes/builtin_methods.rb +0 -73
- data/lib/shoes/button.rb +0 -32
- data/lib/shoes/check_button.rb +0 -43
- data/lib/shoes/color.rb +0 -375
- data/lib/shoes/common/background_element.rb +0 -9
- data/lib/shoes/common/changeable.rb +0 -34
- data/lib/shoes/common/clickable.rb +0 -17
- data/lib/shoes/common/common_methods.rb +0 -70
- data/lib/shoes/common/fill.rb +0 -21
- data/lib/shoes/common/registration.rb +0 -33
- data/lib/shoes/common/state.rb +0 -18
- data/lib/shoes/common/stroke.rb +0 -28
- data/lib/shoes/common/style.rb +0 -34
- data/lib/shoes/common/style_normalizer.rb +0 -16
- data/lib/shoes/configuration.rb +0 -96
- data/lib/shoes/dialog.rb +0 -27
- data/lib/shoes/dimension.rb +0 -237
- data/lib/shoes/dimensions.rb +0 -194
- data/lib/shoes/download.rb +0 -117
- data/lib/shoes/dsl.rb +0 -478
- data/lib/shoes/font.rb +0 -49
- data/lib/shoes/gradient.rb +0 -18
- data/lib/shoes/image.rb +0 -33
- data/lib/shoes/image_pattern.rb +0 -10
- data/lib/shoes/input_box.rb +0 -68
- data/lib/shoes/key_event.rb +0 -17
- data/lib/shoes/line.rb +0 -38
- data/lib/shoes/link.rb +0 -49
- data/lib/shoes/link_hover.rb +0 -5
- data/lib/shoes/list_box.rb +0 -44
- data/lib/shoes/logger.rb +0 -66
- data/lib/shoes/logger/ruby.rb +0 -18
- data/lib/shoes/mock.rb +0 -30
- data/lib/shoes/mock/animation.rb +0 -8
- data/lib/shoes/mock/app.rb +0 -44
- data/lib/shoes/mock/arc.rb +0 -8
- data/lib/shoes/mock/background.rb +0 -10
- data/lib/shoes/mock/border.rb +0 -7
- data/lib/shoes/mock/button.rb +0 -10
- data/lib/shoes/mock/check.rb +0 -24
- data/lib/shoes/mock/common_methods.rb +0 -11
- data/lib/shoes/mock/dialog.rb +0 -13
- data/lib/shoes/mock/download.rb +0 -18
- data/lib/shoes/mock/font.rb +0 -17
- data/lib/shoes/mock/image.rb +0 -12
- data/lib/shoes/mock/image_pattern.rb +0 -9
- data/lib/shoes/mock/input_box.rb +0 -23
- data/lib/shoes/mock/keypress.rb +0 -8
- data/lib/shoes/mock/keyrelease.rb +0 -8
- data/lib/shoes/mock/line.rb +0 -14
- data/lib/shoes/mock/link.rb +0 -11
- data/lib/shoes/mock/list_box.rb +0 -16
- data/lib/shoes/mock/oval.rb +0 -11
- data/lib/shoes/mock/progress.rb +0 -10
- data/lib/shoes/mock/radio.rb +0 -26
- data/lib/shoes/mock/rect.rb +0 -13
- data/lib/shoes/mock/shape.rb +0 -19
- data/lib/shoes/mock/slot.rb +0 -14
- data/lib/shoes/mock/sound.rb +0 -8
- data/lib/shoes/mock/star.rb +0 -13
- data/lib/shoes/mock/text_block.rb +0 -29
- data/lib/shoes/mock/timer.rb +0 -8
- data/lib/shoes/oval.rb +0 -28
- data/lib/shoes/point.rb +0 -43
- data/lib/shoes/progress.rb +0 -26
- data/lib/shoes/radio.rb +0 -15
- data/lib/shoes/rect.rb +0 -28
- data/lib/shoes/renamed_delegate.rb +0 -15
- data/lib/shoes/shape.rb +0 -175
- data/lib/shoes/slot.rb +0 -232
- data/lib/shoes/slot_contents.rb +0 -56
- data/lib/shoes/sound.rb +0 -16
- data/lib/shoes/span.rb +0 -16
- data/lib/shoes/star.rb +0 -49
- data/lib/shoes/swt.rb +0 -114
- data/lib/shoes/swt/animation.rb +0 -46
- data/lib/shoes/swt/app.rb +0 -300
- data/lib/shoes/swt/arc.rb +0 -70
- data/lib/shoes/swt/background.rb +0 -31
- data/lib/shoes/swt/border.rb +0 -37
- data/lib/shoes/swt/button.rb +0 -18
- data/lib/shoes/swt/check.rb +0 -14
- data/lib/shoes/swt/check_button.rb +0 -19
- data/lib/shoes/swt/color.rb +0 -45
- data/lib/shoes/swt/common/child.rb +0 -16
- data/lib/shoes/swt/common/clear.rb +0 -24
- data/lib/shoes/swt/common/clickable.rb +0 -62
- data/lib/shoes/swt/common/container.rb +0 -28
- data/lib/shoes/swt/common/fill.rb +0 -37
- data/lib/shoes/swt/common/painter.rb +0 -83
- data/lib/shoes/swt/common/painter_updates_position.rb +0 -12
- data/lib/shoes/swt/common/resource.rb +0 -14
- data/lib/shoes/swt/common/selection_listener.rb +0 -14
- data/lib/shoes/swt/common/stroke.rb +0 -41
- data/lib/shoes/swt/common/toggle.rb +0 -13
- data/lib/shoes/swt/common/update_position.rb +0 -15
- data/lib/shoes/swt/dialog.rb +0 -89
- data/lib/shoes/swt/disposed_protection.rb +0 -23
- data/lib/shoes/swt/download.rb +0 -24
- data/lib/shoes/swt/fitted_text_layout.rb +0 -94
- data/lib/shoes/swt/fitted_text_layout_collection.rb +0 -108
- data/lib/shoes/swt/font.rb +0 -32
- data/lib/shoes/swt/gradient.rb +0 -77
- data/lib/shoes/swt/image.rb +0 -130
- data/lib/shoes/swt/image_pattern.rb +0 -19
- data/lib/shoes/swt/input_box.rb +0 -73
- data/lib/shoes/swt/key_listener.rb +0 -145
- data/lib/shoes/swt/line.rb +0 -57
- data/lib/shoes/swt/link.rb +0 -37
- data/lib/shoes/swt/link_segment.rb +0 -108
- data/lib/shoes/swt/list_box.rb +0 -49
- data/lib/shoes/swt/mouse_move_listener.rb +0 -61
- data/lib/shoes/swt/oval.rb +0 -53
- data/lib/shoes/swt/progress.rb +0 -35
- data/lib/shoes/swt/radio.rb +0 -29
- data/lib/shoes/swt/radio_group.rb +0 -54
- data/lib/shoes/swt/rect.rb +0 -31
- data/lib/shoes/swt/rect_painter.rb +0 -23
- data/lib/shoes/swt/redrawing_aspect.rb +0 -122
- data/lib/shoes/swt/shape.rb +0 -101
- data/lib/shoes/swt/shoes_layout.rb +0 -43
- data/lib/shoes/swt/slot.rb +0 -25
- data/lib/shoes/swt/sound.rb +0 -119
- data/lib/shoes/swt/star.rb +0 -51
- data/lib/shoes/swt/swt_button.rb +0 -49
- data/lib/shoes/swt/text_block.rb +0 -133
- data/lib/shoes/swt/text_block_cursor_painter.rb +0 -112
- data/lib/shoes/swt/text_block_fitter.rb +0 -180
- data/lib/shoes/swt/text_block_painter.rb +0 -49
- data/lib/shoes/swt/text_font_factory.rb +0 -27
- data/lib/shoes/swt/text_style_factory.rb +0 -88
- data/lib/shoes/swt/timer.rb +0 -19
- data/lib/shoes/swt/tooling/leak_hunter.rb +0 -84
- data/lib/shoes/text.rb +0 -14
- data/lib/shoes/text_block.rb +0 -162
- data/lib/shoes/timer.rb +0 -10
- data/lib/shoes/url.rb +0 -47
- data/lib/shoes/widget.rb +0 -73
- data/lib/support/jl1.0.1.jar +0 -0
- data/lib/support/jogg-0.0.7.jar +0 -0
- data/lib/support/jorbis-0.0.15.jar +0 -0
- data/lib/support/log4j-1.2.16.jar +0 -0
- data/lib/support/mp3spi1.9.5.jar +0 -0
- data/lib/support/tritonus_share.jar +0 -0
- data/lib/support/vorbisspi1.0.3.jar +0 -0
- data/samples/good-clock-adjusted.rb +0 -49
- data/spec/async_helper.rb +0 -21
- data/spec/code_coverage.rb +0 -11
- data/spec/shoes/animation_spec.rb +0 -65
- data/spec/shoes/app_spec.rb +0 -411
- data/spec/shoes/arc_spec.rb +0 -53
- data/spec/shoes/background_spec.rb +0 -48
- data/spec/shoes/border_spec.rb +0 -43
- data/spec/shoes/builtin_methods_spec.rb +0 -84
- data/spec/shoes/button_spec.rb +0 -41
- data/spec/shoes/check_spec.rb +0 -31
- data/spec/shoes/cli_spec.rb +0 -16
- data/spec/shoes/color_spec.rb +0 -396
- data/spec/shoes/common/style_normalizer_spec.rb +0 -28
- data/spec/shoes/common/style_spec.rb +0 -58
- data/spec/shoes/configuration_spec.rb +0 -37
- data/spec/shoes/constants_spec.rb +0 -38
- data/spec/shoes/dialog_spec.rb +0 -163
- data/spec/shoes/dimension_spec.rb +0 -381
- data/spec/shoes/dimensions_spec.rb +0 -831
- data/spec/shoes/download_spec.rb +0 -133
- data/spec/shoes/flow_spec.rb +0 -92
- data/spec/shoes/font_spec.rb +0 -38
- data/spec/shoes/framework_learning_spec.rb +0 -30
- data/spec/shoes/helpers/fake_element.rb +0 -11
- data/spec/shoes/helpers/sample17_helper.rb +0 -66
- data/spec/shoes/image_spec.rb +0 -45
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +0 -44
- data/spec/shoes/integration_spec.rb +0 -20
- data/spec/shoes/keypress_spec.rb +0 -11
- data/spec/shoes/keyrelease_spec.rb +0 -12
- data/spec/shoes/line_spec.rb +0 -47
- data/spec/shoes/link_spec.rb +0 -89
- data/spec/shoes/list_box_spec.rb +0 -63
- data/spec/shoes/logger/ruby_spec.rb +0 -9
- data/spec/shoes/logger_spec.rb +0 -45
- data/spec/shoes/oval_spec.rb +0 -20
- data/spec/shoes/point_spec.rb +0 -51
- data/spec/shoes/progress_spec.rb +0 -40
- data/spec/shoes/radio_spec.rb +0 -28
- data/spec/shoes/rect_spec.rb +0 -38
- data/spec/shoes/renamed_delegate_spec.rb +0 -70
- data/spec/shoes/shape_spec.rb +0 -54
- 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 -42
- data/spec/shoes/shared_examples/dimensions.rb +0 -32
- data/spec/shoes/shared_examples/dsl.rb +0 -42
- 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/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 -52
- 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 -60
- 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 -26
- data/spec/shoes/shared_examples/dsl/shape.rb +0 -21
- data/spec/shoes/shared_examples/dsl/star.rb +0 -48
- 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 -81
- data/spec/shoes/shared_examples/dsl_app_context.rb +0 -8
- data/spec/shoes/shared_examples/hover_leave.rb +0 -11
- data/spec/shoes/shared_examples/parent.rb +0 -6
- data/spec/shoes/shared_examples/shared_element_method.rb +0 -52
- data/spec/shoes/shared_examples/slot.rb +0 -272
- data/spec/shoes/shared_examples/state.rb +0 -19
- data/spec/shoes/shared_examples/style.rb +0 -24
- data/spec/shoes/slot_spec.rb +0 -60
- data/spec/shoes/sound_spec.rb +0 -15
- data/spec/shoes/span_spec.rb +0 -94
- data/spec/shoes/spec_helper.rb +0 -1
- data/spec/shoes/stack_spec.rb +0 -53
- data/spec/shoes/star_spec.rb +0 -30
- data/spec/shoes/text_block_spec.rb +0 -242
- data/spec/shoes/url_spec.rb +0 -66
- data/spec/shoes/widget_spec.rb +0 -34
- data/spec/shoes_spec.rb +0 -44
- data/spec/spec_helper.rb +0 -16
- data/spec/swt_shoes/animation_spec.rb +0 -86
- data/spec/swt_shoes/app_spec.rb +0 -75
- data/spec/swt_shoes/arc_spec.rb +0 -101
- data/spec/swt_shoes/background_spec.rb +0 -56
- data/spec/swt_shoes/border_spec.rb +0 -51
- data/spec/swt_shoes/button_spec.rb +0 -101
- data/spec/swt_shoes/check_spec.rb +0 -28
- data/spec/swt_shoes/color_spec.rb +0 -67
- data/spec/swt_shoes/common/painter_spec.rb +0 -29
- data/spec/swt_shoes/configuration_spec.rb +0 -12
- data/spec/swt_shoes/dialog_spec.rb +0 -106
- data/spec/swt_shoes/disposed_protection_spec.rb +0 -49
- data/spec/swt_shoes/fitted_text_layout_collection_spec.rb +0 -174
- data/spec/swt_shoes/fitted_text_layout_spec.rb +0 -130
- data/spec/swt_shoes/flow_spec.rb +0 -26
- data/spec/swt_shoes/font_spec.rb +0 -33
- data/spec/swt_shoes/gradient_spec.rb +0 -20
- data/spec/swt_shoes/image_pattern_spec.rb +0 -19
- data/spec/swt_shoes/image_spec.rb +0 -100
- data/spec/swt_shoes/input_box_spec.rb +0 -110
- data/spec/swt_shoes/integration_spec.rb +0 -18
- data/spec/swt_shoes/key_listener_spec.rb +0 -320
- data/spec/swt_shoes/line_spec.rb +0 -43
- data/spec/swt_shoes/link_segment_spec.rb +0 -103
- data/spec/swt_shoes/link_spec.rb +0 -59
- data/spec/swt_shoes/list_box_spec.rb +0 -51
- data/spec/swt_shoes/minimal.png +0 -0
- data/spec/swt_shoes/mouse_move_listener_spec.rb +0 -129
- data/spec/swt_shoes/oval_spec.rb +0 -51
- data/spec/swt_shoes/progress_spec.rb +0 -44
- data/spec/swt_shoes/radio_group_spec.rb +0 -73
- data/spec/swt_shoes/radio_spec.rb +0 -56
- data/spec/swt_shoes/rect_painter_spec.rb +0 -45
- data/spec/swt_shoes/rect_spec.rb +0 -19
- data/spec/swt_shoes/shape_spec.rb +0 -81
- data/spec/swt_shoes/shared_examples/button.rb +0 -24
- data/spec/swt_shoes/shared_examples/clearable.rb +0 -32
- data/spec/swt_shoes/shared_examples/clickable.rb +0 -60
- data/spec/swt_shoes/shared_examples/movable.rb +0 -36
- data/spec/swt_shoes/shared_examples/paintable_spec.rb +0 -7
- data/spec/swt_shoes/shared_examples/painter.rb +0 -83
- data/spec/swt_shoes/shared_examples/pattern.rb +0 -32
- data/spec/swt_shoes/shared_examples/swt_app_context.rb +0 -17
- data/spec/swt_shoes/shared_examples/togglable.rb +0 -15
- data/spec/swt_shoes/shell_control_listener_spec.rb +0 -23
- data/spec/swt_shoes/sound.rb +0 -10
- data/spec/swt_shoes/spec_helper.rb +0 -31
- data/spec/swt_shoes/star_spec.rb +0 -47
- data/spec/swt_shoes/text_block_cursor_painter_spec.rb +0 -202
- data/spec/swt_shoes/text_block_fitter_spec.rb +0 -181
- data/spec/swt_shoes/text_block_painter_spec.rb +0 -221
- data/spec/swt_shoes/text_block_spec.rb +0 -183
@@ -1,28 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Common::StyleNormalizer do
|
4
|
-
subject {Shoes::Common::StyleNormalizer.new}
|
5
|
-
|
6
|
-
it 'does not modify a simple hash' do
|
7
|
-
input = {left: 100, width: 233}
|
8
|
-
expect(subject.normalize input).to eq input
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'turns hexcodes for fill into colors' do
|
12
|
-
input = {fill: 'ffffff'}
|
13
|
-
expected = {fill: Shoes::Color.new(255, 255, 255)}
|
14
|
-
expect(subject.normalize input).to eq expected
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'turns hexcodes for stroke into colors' do
|
18
|
-
input = {stroke: 'ffffff'}
|
19
|
-
expected = {stroke: Shoes::Color.new(255, 255, 255)}
|
20
|
-
expect(subject.normalize input).to eq expected
|
21
|
-
end
|
22
|
-
|
23
|
-
it 'does not modify the original hash' do
|
24
|
-
input = {stroke: '333333'}
|
25
|
-
subject.normalize input
|
26
|
-
expect(input).to eq({stroke: '333333'})
|
27
|
-
end
|
28
|
-
end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Common::Style do
|
4
|
-
|
5
|
-
class StyleTester
|
6
|
-
include Shoes::Common::Style
|
7
|
-
|
8
|
-
def initialize(style = {})
|
9
|
-
@style = style
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
subject {StyleTester.new}
|
14
|
-
|
15
|
-
its(:style) {should eq Hash.new}
|
16
|
-
|
17
|
-
describe 'changing the style trhough #style(hash)' do
|
18
|
-
let(:changed_style) {{key: 'value'}}
|
19
|
-
|
20
|
-
before :each do
|
21
|
-
subject.style changed_style
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'returns the changed style' do
|
25
|
-
expect(subject.style).to eq changed_style
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'does update values for new values' do
|
29
|
-
subject.style new_key: 'new value'
|
30
|
-
expect(subject.style[:new_key]).to eq 'new value'
|
31
|
-
end
|
32
|
-
|
33
|
-
# these specs are rather extensive as they are performance critical for
|
34
|
-
# redrawing
|
35
|
-
describe 'calling or not calling #update_style' do
|
36
|
-
it 'does not call #update_style if no key value pairs changed' do
|
37
|
-
expect(subject).not_to receive(:update_style)
|
38
|
-
subject.style changed_style
|
39
|
-
end
|
40
|
-
|
41
|
-
it 'does not call #update_style if called without arg' do
|
42
|
-
expect(subject).not_to receive(:update_style)
|
43
|
-
subject.style
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'does call #update_style if the values change' do
|
47
|
-
expect(subject).to receive(:update_style)
|
48
|
-
subject.style key: 'new value'
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'does call #update_style if there is a new key-value' do
|
52
|
-
expect(subject).to receive(:update_style)
|
53
|
-
subject.style new_key: 'value'
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
end
|
@@ -1,37 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Configuration do
|
4
|
-
after { Shoes.configuration.reset }
|
5
|
-
|
6
|
-
describe "#logger" do
|
7
|
-
describe ":ruby" do
|
8
|
-
before { Shoes.configuration.logger = :ruby }
|
9
|
-
|
10
|
-
it "uses the Ruby logger" do
|
11
|
-
Shoes.logger.instance_of?(Shoes::Logger::Ruby).should == true
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "backend" do
|
17
|
-
include_context "dsl app"
|
18
|
-
|
19
|
-
let(:args) { Hash.new }
|
20
|
-
let(:dsl_object) { Shoes::Shape.new app, args }
|
21
|
-
|
22
|
-
describe "#backend_with_app_for" do
|
23
|
-
it "passes app.gui to backend" do
|
24
|
-
Shoes.configuration.backend::Shape.should_receive(:new).with(dsl_object, app.gui, args)
|
25
|
-
dsl_object
|
26
|
-
end
|
27
|
-
|
28
|
-
it "returns shape backend object" do
|
29
|
-
Shoes.configuration.backend_with_app_for(dsl_object, args).should be_instance_of(Shoes.configuration.backend::Shape)
|
30
|
-
end
|
31
|
-
|
32
|
-
it "raises ArgumentError for a non-Shoes object" do
|
33
|
-
lambda { Shoes.configuration.backend_with_app_for(1..100) }.should raise_error(ArgumentError)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
require "pathname"
|
2
|
-
|
3
|
-
describe "Shoes constants" do
|
4
|
-
specify "PI equals Math::PI" do
|
5
|
-
Shoes::PI.should eq(Math::PI)
|
6
|
-
end
|
7
|
-
|
8
|
-
specify "TWO_PI equals 2 * Math::PI" do
|
9
|
-
Shoes::TWO_PI.should eq(2 * Math::PI)
|
10
|
-
end
|
11
|
-
|
12
|
-
specify "HALF_PI equals 0.5 * Math::PI" do
|
13
|
-
Shoes::HALF_PI.should eq(0.5 * Math::PI)
|
14
|
-
end
|
15
|
-
|
16
|
-
describe "DIR" do
|
17
|
-
let(:shoes_home_dir) { Pathname.new(__FILE__).join("../../..").expand_path }
|
18
|
-
subject { Pathname.new Shoes::DIR }
|
19
|
-
|
20
|
-
it "is the shoes home directory" do
|
21
|
-
subject.should eq(shoes_home_dir)
|
22
|
-
end
|
23
|
-
|
24
|
-
it "contains lib/shoes.rb" do
|
25
|
-
subject.join("lib/shoes.rb").should exist
|
26
|
-
end
|
27
|
-
|
28
|
-
it "contains static/shoes_icon.png" do
|
29
|
-
subject.join("static/shoes-icon.png").should exist
|
30
|
-
end
|
31
|
-
|
32
|
-
it "remains constant when current directory changes" do
|
33
|
-
Dir.chdir ".." do
|
34
|
-
subject.should eq(shoes_home_dir)
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
data/spec/shoes/dialog_spec.rb
DELETED
@@ -1,163 +0,0 @@
|
|
1
|
-
require 'spec/shoes/spec_helper'
|
2
|
-
# NOTE: This spec is sadly circumventing the integration specs since we couldn't
|
3
|
-
# figure out how to get rid of the alert - it stopped the running tests
|
4
|
-
|
5
|
-
main_object = self
|
6
|
-
|
7
|
-
describe Shoes::Dialog do
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@dialog = Shoes::Dialog.new
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'is not nil' do
|
14
|
-
@dialog.should_not be_nil
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#alert' do
|
18
|
-
it 'returns nil' do
|
19
|
-
@dialog.alert('something').should be_nil
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
describe '#confirm' do
|
24
|
-
it 'responds to it' do
|
25
|
-
@dialog.should respond_to :confirm
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
describe '#ask_open_file' do
|
30
|
-
it 'responds to it' do
|
31
|
-
@dialog.should respond_to :dialog_chooser
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
describe '#ask_save_file' do
|
36
|
-
it 'responds to it' do
|
37
|
-
@dialog.should respond_to :dialog_chooser
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#ask_open_folder' do
|
42
|
-
it 'responds to it' do
|
43
|
-
@dialog.should respond_to :dialog_chooser
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe '#ask_save_folder' do
|
48
|
-
it 'responds to it' do
|
49
|
-
@dialog.should respond_to :dialog_chooser
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
describe '#ask' do
|
54
|
-
it 'responds to it' do
|
55
|
-
@dialog.should respond_to :ask
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#ask_color' do
|
60
|
-
it 'responds to it' do
|
61
|
-
@dialog.should respond_to :ask_color
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
describe 'nothing monkey patched on to Object' do
|
66
|
-
it 'is not monkey patched on to object' do
|
67
|
-
Object.new.should_not respond_to :alert
|
68
|
-
end
|
69
|
-
|
70
|
-
it 'is not monkey patched on to object' do
|
71
|
-
Object.new.should_not respond_to :confirm
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'is not monkey patched on to object' do
|
75
|
-
Object.new.should_not respond_to :dialog_chooser
|
76
|
-
end
|
77
|
-
|
78
|
-
it 'is not monkey patched on to object' do
|
79
|
-
Object.new.should_not respond_to :ask
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'is not monkey patched on to object' do
|
83
|
-
Object.new.should_not respond_to :ask_color
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe 'the main object' do
|
88
|
-
it 'knows of #alert' do
|
89
|
-
main_object.should respond_to :alert
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'knows of #confirm' do
|
93
|
-
main_object.should respond_to :confirm
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'knows of #confirm?' do
|
97
|
-
main_object.should respond_to :confirm?
|
98
|
-
end
|
99
|
-
|
100
|
-
it 'knows of #ask_open_file' do
|
101
|
-
main_object.should respond_to :ask_open_file
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'knows of #ask_save_file' do
|
105
|
-
main_object.should respond_to :ask_save_file
|
106
|
-
end
|
107
|
-
|
108
|
-
it 'knows of #ask_open_folder' do
|
109
|
-
main_object.should respond_to :ask_open_folder
|
110
|
-
end
|
111
|
-
|
112
|
-
it 'knows of #ask_save_folder' do
|
113
|
-
main_object.should respond_to :ask_save_folder
|
114
|
-
end
|
115
|
-
|
116
|
-
it 'knows of #ask' do
|
117
|
-
main_object.should respond_to :ask
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'knows of #ask' do
|
121
|
-
main_object.should respond_to :ask_color
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe 'Shoes::App' do
|
126
|
-
before :each do
|
127
|
-
@app = Shoes::App.new
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'knows about #alert' do
|
131
|
-
@app.should respond_to :alert
|
132
|
-
end
|
133
|
-
|
134
|
-
it 'knows about #confirm' do
|
135
|
-
@app.should respond_to :confirm
|
136
|
-
end
|
137
|
-
|
138
|
-
it 'knows about #ask_open_file' do
|
139
|
-
@app.should respond_to :ask_open_file
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'knows about #ask_save_file' do
|
143
|
-
@app.should respond_to :ask_save_file
|
144
|
-
end
|
145
|
-
|
146
|
-
it 'knows about #ask_open_folder' do
|
147
|
-
@app.should respond_to :ask_open_folder
|
148
|
-
end
|
149
|
-
|
150
|
-
it 'knows about #ask_save_folder' do
|
151
|
-
@app.should respond_to :ask_save_folder
|
152
|
-
end
|
153
|
-
|
154
|
-
it 'knows about #ask_save_folder' do
|
155
|
-
@app.should respond_to :ask
|
156
|
-
end
|
157
|
-
|
158
|
-
it 'knows about #ask_save_color' do
|
159
|
-
@app.should respond_to :ask_color
|
160
|
-
end
|
161
|
-
end
|
162
|
-
|
163
|
-
end
|
@@ -1,381 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Dimension do
|
4
|
-
|
5
|
-
subject {Shoes::Dimension.new parent_dimension}
|
6
|
-
let(:start) {10}
|
7
|
-
let(:extent) {21}
|
8
|
-
let(:parent_element_start) {34}
|
9
|
-
let(:parent_element_end) {83}
|
10
|
-
let(:parent_element_extent) {600}
|
11
|
-
let(:parent_dimension) { double 'parent_dimension',
|
12
|
-
element_start: parent_element_start,
|
13
|
-
element_end: parent_element_end,
|
14
|
-
element_extent: parent_element_extent }
|
15
|
-
|
16
|
-
ONE_PIXEL = 1
|
17
|
-
|
18
|
-
describe 'initialization' do
|
19
|
-
describe 'without arguments (even no parent)' do
|
20
|
-
subject {Shoes::Dimension.new nil}
|
21
|
-
|
22
|
-
its(:start) {should eq nil}
|
23
|
-
its(:end) {should eq nil}
|
24
|
-
its(:extent) {should eq nil}
|
25
|
-
its(:margin_start) {should eq 0}
|
26
|
-
its(:margin_end) {should eq 0}
|
27
|
-
its(:displace_start) {should eq 0}
|
28
|
-
it {should_not be_positioned}
|
29
|
-
it {should_not be_absolute_position}
|
30
|
-
it {should_not be_start_as_center}
|
31
|
-
end
|
32
|
-
|
33
|
-
describe 'with a parent and being positioned itself' do
|
34
|
-
subject {Shoes::Dimension.new parent_dimension}
|
35
|
-
|
36
|
-
TESTING_OFFSET = 11
|
37
|
-
|
38
|
-
before :each do
|
39
|
-
subject.absolute_start = parent_element_start + TESTING_OFFSET
|
40
|
-
subject.extent = 10
|
41
|
-
end
|
42
|
-
|
43
|
-
its(:start) {should eq TESTING_OFFSET}
|
44
|
-
its(:end) {should eq parent_element_end - subject.element_end}
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'start as center' do
|
48
|
-
subject {Shoes::Dimension.new parent_dimension, true}
|
49
|
-
it {should be_start_as_center}
|
50
|
-
|
51
|
-
it 'takes start as the center' do
|
52
|
-
subject.extent = 100
|
53
|
-
subject.start = 60
|
54
|
-
expect(subject.start).to eq 10
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe 'extent' do
|
60
|
-
let(:parent_element_extent) {600}
|
61
|
-
let(:parent_extent) {580}
|
62
|
-
let(:parent) {double 'parent', element_extent: parent_element_extent,
|
63
|
-
extent: parent_extent}
|
64
|
-
|
65
|
-
subject {Shoes::Dimension.new parent}
|
66
|
-
|
67
|
-
it 'gets and sets' do
|
68
|
-
subject.extent = extent
|
69
|
-
expect(subject.extent).to eq extent
|
70
|
-
end
|
71
|
-
|
72
|
-
describe 'negative values' do
|
73
|
-
it 'subtracts them from the parent taking margins into account' do
|
74
|
-
subject.extent = -70
|
75
|
-
expect(subject.extent).to eq parent_element_extent - 70
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
describe 'relative values from the parent taking margins into account' do
|
80
|
-
it 'takes them relative to the parent for smaller values' do
|
81
|
-
subject.extent = 0.8
|
82
|
-
expect(subject.extent).to be_within(ONE_PIXEL).of 0.8 *
|
83
|
-
parent_element_extent
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'handles negative relative values' do
|
87
|
-
subject.extent = -0.3
|
88
|
-
expect(subject.extent).to be_within(ONE_PIXEL).of 0.7 *
|
89
|
-
parent_element_extent
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'equal parent extent for 1.0' do
|
93
|
-
subject.extent = 1.0
|
94
|
-
expect(subject.extent).to eq parent_element_extent
|
95
|
-
end
|
96
|
-
|
97
|
-
it 'does not take them relative to the parent for bigger values' do
|
98
|
-
subject.extent = 1.3
|
99
|
-
expect(subject.extent).to eq 1.3
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
describe 'string values' do
|
104
|
-
it 'handles pure number strings' do
|
105
|
-
subject.extent = '100'
|
106
|
-
expect(subject.extent).to eq 100
|
107
|
-
end
|
108
|
-
|
109
|
-
it 'handles px strings' do
|
110
|
-
subject.extent = '80px'
|
111
|
-
expect(subject.extent).to eq 80
|
112
|
-
end
|
113
|
-
|
114
|
-
it 'takes care of some px white space' do
|
115
|
-
subject.extent = '70 px'
|
116
|
-
expect(subject.extent).to eq 70
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'also handles negative values' do
|
120
|
-
subject.extent = '-50px'
|
121
|
-
expect(subject.extent).to eq parent_element_extent - 50
|
122
|
-
end
|
123
|
-
|
124
|
-
it 'handles percent as relative value' do
|
125
|
-
subject.extent = '75%'
|
126
|
-
expect(subject.extent).to be_within(ONE_PIXEL).of 0.75 *
|
127
|
-
parent_element_extent
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'handles negative percent values' do
|
131
|
-
subject.extent = '-10%'
|
132
|
-
expect(subject.extent).to be_within(ONE_PIXEL).of 0.9 *
|
133
|
-
parent_element_extent
|
134
|
-
end
|
135
|
-
|
136
|
-
it 'handles percent values with floats' do
|
137
|
-
subject.extent = '20.5%'
|
138
|
-
expect(subject.extent).to be_within(ONE_PIXEL).of 0.205 *
|
139
|
-
parent_element_extent
|
140
|
-
end
|
141
|
-
|
142
|
-
it 'returns nil for invalid strings' do
|
143
|
-
subject.extent = 'hell0'
|
144
|
-
expect(subject.extent).to be_nil
|
145
|
-
end
|
146
|
-
end
|
147
|
-
end
|
148
|
-
|
149
|
-
describe 'start' do
|
150
|
-
let(:start) {23}
|
151
|
-
|
152
|
-
before :each do
|
153
|
-
subject.start = start
|
154
|
-
end
|
155
|
-
|
156
|
-
its(:start) {should eq start}
|
157
|
-
it {should be_absolute_position}
|
158
|
-
|
159
|
-
it 'can set a start relative to parent element_extent' do
|
160
|
-
subject.start = 0.3
|
161
|
-
expected = 0.3 * parent_element_extent
|
162
|
-
expect(subject.start).to be_within(ONE_PIXEL).of expected
|
163
|
-
end
|
164
|
-
|
165
|
-
# might be surprising if people do calculations that result in a float
|
166
|
-
# and all of a sudden they have 10.4 and the button is nowhere to be found
|
167
|
-
it 'uses literal float values for values over 1.0' do
|
168
|
-
subject.start = 1.01
|
169
|
-
expect(subject.start).to eq 1.01
|
170
|
-
end
|
171
|
-
|
172
|
-
context 'without a parent' do
|
173
|
-
let(:parent_dimension) {nil}
|
174
|
-
|
175
|
-
it 'just takes the relative value' do
|
176
|
-
subject.start = 0.8
|
177
|
-
expect(subject.start).to eq 0.8
|
178
|
-
end
|
179
|
-
end
|
180
|
-
end
|
181
|
-
|
182
|
-
describe 'absolute_start' do
|
183
|
-
let(:absolute_start) {8}
|
184
|
-
|
185
|
-
before :each do
|
186
|
-
subject.absolute_start = absolute_start
|
187
|
-
end
|
188
|
-
|
189
|
-
it 'gets and sets absolute_start' do
|
190
|
-
expect(subject.absolute_start).to eq absolute_start
|
191
|
-
end
|
192
|
-
|
193
|
-
it {should be_positioned}
|
194
|
-
end
|
195
|
-
|
196
|
-
describe 'absolute_end' do
|
197
|
-
it 'is the sum of start and extent' do
|
198
|
-
subject.absolute_start = 7
|
199
|
-
subject.extent = 22
|
200
|
-
expect(subject.absolute_end).to eq 29 - ONE_PIXEL # pixel counting adjustment
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
describe 'margins' do
|
205
|
-
|
206
|
-
let(:margin_start) {11}
|
207
|
-
let(:margin_end) {17}
|
208
|
-
|
209
|
-
before :each do
|
210
|
-
subject.margin_start = margin_start
|
211
|
-
subject.margin_end = margin_end
|
212
|
-
end
|
213
|
-
|
214
|
-
its(:margin_start) {should eq margin_start}
|
215
|
-
its(:margin_end) {should eq margin_end}
|
216
|
-
|
217
|
-
context 'absolute_start set' do
|
218
|
-
let(:absolute_start) {7}
|
219
|
-
|
220
|
-
before :each do
|
221
|
-
subject.absolute_start = absolute_start
|
222
|
-
end
|
223
|
-
|
224
|
-
it 'does not influence absolute_start' do
|
225
|
-
expect(subject.absolute_start).to eq absolute_start
|
226
|
-
end
|
227
|
-
|
228
|
-
it 'does influence element_start' do
|
229
|
-
expect(subject.element_start).to eq absolute_start + margin_start
|
230
|
-
end
|
231
|
-
|
232
|
-
context 'extent set' do
|
233
|
-
let(:extent) {67}
|
234
|
-
|
235
|
-
before :each do
|
236
|
-
subject.extent = extent
|
237
|
-
end
|
238
|
-
|
239
|
-
it 'does not influence absolute_end' do
|
240
|
-
expect(subject.absolute_end).to eq absolute_start + extent - ONE_PIXEL
|
241
|
-
end
|
242
|
-
|
243
|
-
it 'does influence element_end' do
|
244
|
-
expect(subject.element_end).to eq absolute_start + extent -
|
245
|
-
margin_end - ONE_PIXEL
|
246
|
-
end
|
247
|
-
end
|
248
|
-
|
249
|
-
context 'element_extent set' do
|
250
|
-
let(:element_extent) {77}
|
251
|
-
|
252
|
-
before :each do
|
253
|
-
subject.element_extent = element_extent
|
254
|
-
end
|
255
|
-
|
256
|
-
its(:element_extent) {should eq element_extent}
|
257
|
-
its(:extent) {should eq element_extent + margin_start + margin_end}
|
258
|
-
its(:element_end) {should eq subject.element_start + element_extent -
|
259
|
-
ONE_PIXEL}
|
260
|
-
end
|
261
|
-
end
|
262
|
-
end
|
263
|
-
|
264
|
-
describe 'in_bounds?' do
|
265
|
-
let(:absolute_start) {20}
|
266
|
-
let(:extent) {100}
|
267
|
-
let(:absolute_end) {20 + 100 -ONE_PIXEL} # -1 due to pixel counting adjustment
|
268
|
-
|
269
|
-
before :each do
|
270
|
-
subject.absolute_start = absolute_start
|
271
|
-
subject.extent = extent
|
272
|
-
end
|
273
|
-
|
274
|
-
its(:absolute_end) {should eq absolute_end}
|
275
|
-
|
276
|
-
it {should be_in_bounds absolute_start}
|
277
|
-
it {should be_in_bounds absolute_end}
|
278
|
-
it {should be_in_bounds absolute_start + ONE_PIXEL}
|
279
|
-
it {should be_in_bounds absolute_end - ONE_PIXEL}
|
280
|
-
it {should be_in_bounds 40}
|
281
|
-
it {should be_in_bounds 105}
|
282
|
-
it {should be_in_bounds 20.021}
|
283
|
-
it {should_not be_in_bounds absolute_end + ONE_PIXEL}
|
284
|
-
it {should_not be_in_bounds absolute_start - ONE_PIXEL
|
285
|
-
}
|
286
|
-
it {should_not be_in_bounds -5}
|
287
|
-
it {should_not be_in_bounds 0}
|
288
|
-
it {should_not be_in_bounds 150}
|
289
|
-
it {should_not be_in_bounds 123178}
|
290
|
-
end
|
291
|
-
|
292
|
-
it 'can displace the placement' do
|
293
|
-
subject.displace_start = 5
|
294
|
-
subject.absolute_start = 10
|
295
|
-
expect(subject.element_start).to eq 15
|
296
|
-
end
|
297
|
-
|
298
|
-
describe 'start/end/margin and other values parse simple string values' do
|
299
|
-
it 'parses a normal number' do
|
300
|
-
subject.start = '50'
|
301
|
-
expect(subject.start).to eq 50
|
302
|
-
end
|
303
|
-
|
304
|
-
it 'parses pixel values' do
|
305
|
-
subject.start = '77px'
|
306
|
-
expect(subject.start).to eq 77
|
307
|
-
end
|
308
|
-
|
309
|
-
it 'parses negative values' do
|
310
|
-
subject.start = '-13'
|
311
|
-
expect(subject.start).to eq -13
|
312
|
-
end
|
313
|
-
|
314
|
-
it 'even parses negative values with px' do
|
315
|
-
subject.start = '-22px'
|
316
|
-
expect(subject.start).to eq -22
|
317
|
-
end
|
318
|
-
|
319
|
-
it 'returns nil for unknown values' do
|
320
|
-
subject.start = []
|
321
|
-
expect(subject.start).to be_nil
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
describe Shoes::ParentDimension do
|
326
|
-
let(:parent) {Shoes::Dimension.new}
|
327
|
-
let(:parent_start) {7}
|
328
|
-
let(:parent_extent) {27}
|
329
|
-
let(:margin) {5}
|
330
|
-
|
331
|
-
subject {Shoes::ParentDimension.new parent}
|
332
|
-
|
333
|
-
before :each do
|
334
|
-
parent.start = parent_start
|
335
|
-
parent.extent = parent_extent
|
336
|
-
parent.margin_start = margin
|
337
|
-
parent.margin_end = margin
|
338
|
-
end
|
339
|
-
|
340
|
-
describe 'it takes its parent values if no values are set' do
|
341
|
-
its(:start) {should eq parent_start}
|
342
|
-
its(:extent) {should eq parent_extent}
|
343
|
-
its(:margin_start) {should eq margin}
|
344
|
-
its(:margin_end) {should eq margin}
|
345
|
-
|
346
|
-
context 'with parent absolute_start set' do
|
347
|
-
before :each do
|
348
|
-
parent.absolute_start = 11
|
349
|
-
end
|
350
|
-
|
351
|
-
its(:absolute_start) {should eq 11}
|
352
|
-
its(:element_start) {should eq parent.element_start}
|
353
|
-
its(:element_end) {should eq parent.element_end}
|
354
|
-
end
|
355
|
-
end
|
356
|
-
|
357
|
-
describe 'otherwise it takes its own values' do
|
358
|
-
before :each do
|
359
|
-
subject.start = start
|
360
|
-
subject.extent = extent
|
361
|
-
subject.absolute_start = 17
|
362
|
-
end
|
363
|
-
|
364
|
-
its(:start) {should eq start}
|
365
|
-
its(:extent) {should eq extent}
|
366
|
-
its(:absolute_start) {should eq 17}
|
367
|
-
|
368
|
-
it 'can still handle special values like a negative extent' do
|
369
|
-
subject.extent = -10
|
370
|
-
expect(subject.extent).to eq (parent_extent - 2 * margin) - 10
|
371
|
-
end
|
372
|
-
|
373
|
-
it 'can also still handle special values like relative values' do
|
374
|
-
subject.extent = 0.8
|
375
|
-
expect(subject.extent).to be_within(ONE_PIXEL).of(0.8 * parent.element_extent)
|
376
|
-
end
|
377
|
-
end
|
378
|
-
end
|
379
|
-
|
380
|
-
end
|
381
|
-
|