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
data/spec/shoes/arc_spec.rb
DELETED
@@ -1,53 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Arc do
|
4
|
-
include_context "dsl app"
|
5
|
-
let(:parent) { app }
|
6
|
-
|
7
|
-
let(:left) { 13 }
|
8
|
-
let(:top) { 44 }
|
9
|
-
let(:width) { 200 }
|
10
|
-
let(:height) { 300 }
|
11
|
-
let(:start_angle) { 0 }
|
12
|
-
let(:end_angle) { Shoes::TWO_PI }
|
13
|
-
|
14
|
-
context "basic" do
|
15
|
-
subject(:arc) { Shoes::Arc.new(app, parent, left, top, width, height, start_angle, end_angle) }
|
16
|
-
|
17
|
-
it_behaves_like "object with stroke"
|
18
|
-
it_behaves_like "object with style"
|
19
|
-
it_behaves_like "object with fill"
|
20
|
-
it_behaves_like "object with dimensions"
|
21
|
-
it_behaves_like "left, top as center", :start_angle, :end_angle
|
22
|
-
it_behaves_like 'object with parent'
|
23
|
-
|
24
|
-
it "is a Shoes::Arc" do
|
25
|
-
expect(arc.class).to be(Shoes::Arc)
|
26
|
-
end
|
27
|
-
|
28
|
-
its(:angle1) { should eq(0) }
|
29
|
-
its(:angle2) { should eq(Shoes::TWO_PI) }
|
30
|
-
|
31
|
-
specify "defaults to chord fill" do
|
32
|
-
expect(arc).not_to be_wedge
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
context "relative dimensions" do
|
37
|
-
subject(:arc) { Shoes::Arc.new(app, parent, left, top, relative_width, relative_height, start_angle, end_angle) }
|
38
|
-
it_behaves_like "object with relative dimensions"
|
39
|
-
end
|
40
|
-
|
41
|
-
context "negative dimensions" do
|
42
|
-
subject(:arc) { Shoes::Arc.new(app, parent, left, top, -width, -height, 0, Shoes::TWO_PI) }
|
43
|
-
it_behaves_like "object with negative dimensions"
|
44
|
-
end
|
45
|
-
|
46
|
-
context "wedge" do
|
47
|
-
subject(:arc) { Shoes::Arc.new(app, parent, left, top, width, height, start_angle, end_angle, :wedge => true) }
|
48
|
-
|
49
|
-
specify "accepts :wedge => true" do
|
50
|
-
expect(arc).to be_wedge
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Background do
|
4
|
-
include_context "dsl app"
|
5
|
-
|
6
|
-
let(:left) { 10 }
|
7
|
-
let(:top) { 20 }
|
8
|
-
let(:width) { 100 }
|
9
|
-
let(:height) { 200 }
|
10
|
-
|
11
|
-
let(:blue) { Shoes::COLORS[:blue] }
|
12
|
-
let(:input_opts){ {left: left, top: top, width: width, height: height, color: blue} }
|
13
|
-
subject(:background) { Shoes::Background.new(app, parent, blue, input_opts) }
|
14
|
-
|
15
|
-
it "retains app" do
|
16
|
-
expect(background.app).to eq(app)
|
17
|
-
end
|
18
|
-
|
19
|
-
it "creates gui object" do
|
20
|
-
expect(background.gui).not_to be_nil
|
21
|
-
end
|
22
|
-
|
23
|
-
it_behaves_like "object with style"
|
24
|
-
it_behaves_like "object with dimensions"
|
25
|
-
|
26
|
-
describe "relative dimensions from parent" do
|
27
|
-
subject { Shoes::Background.new(app, parent, blue, relative_opts) }
|
28
|
-
it_behaves_like "object with relative dimensions"
|
29
|
-
end
|
30
|
-
|
31
|
-
context "negative dimensions" do
|
32
|
-
subject { Shoes::Background.new(app, parent, blue, negative_opts) }
|
33
|
-
it_behaves_like "object with negative dimensions"
|
34
|
-
end
|
35
|
-
|
36
|
-
describe '#needs_to_be_positioned?' do
|
37
|
-
context 'without absolute dimensions' do
|
38
|
-
let(:input_opts) {{}}
|
39
|
-
it {should_not be_needs_to_be_positioned}
|
40
|
-
end
|
41
|
-
|
42
|
-
context 'with absolute dimensions' do
|
43
|
-
it {should be_needs_to_be_positioned}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
it {should_not be_takes_up_space}
|
48
|
-
end
|
data/spec/shoes/border_spec.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for "basic border" do
|
4
|
-
it "retains app" do
|
5
|
-
subject.app.should eq(app)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "creates gui object" do
|
9
|
-
subject.gui.should_not be_nil
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe Shoes::Border do
|
14
|
-
include_context "dsl app"
|
15
|
-
let(:parent) { Shoes::FakeElement.new nil, left, top, width, height}
|
16
|
-
let(:opts){ {left: left, top: top, width: width, height: height} }
|
17
|
-
|
18
|
-
let(:left) { 10 }
|
19
|
-
let(:top) { 20 }
|
20
|
-
let(:width) { 100 }
|
21
|
-
let(:height) { 200 }
|
22
|
-
|
23
|
-
let(:blue) { Shoes::COLORS[:blue] }
|
24
|
-
|
25
|
-
subject { Shoes::Border.new(app, parent, blue, opts) }
|
26
|
-
|
27
|
-
it_behaves_like "basic border"
|
28
|
-
it_behaves_like "object with style"
|
29
|
-
it_behaves_like "object with dimensions"
|
30
|
-
|
31
|
-
describe "relative dimensions from parent" do
|
32
|
-
subject { Shoes::Border.new(app, parent, blue, relative_opts) }
|
33
|
-
it_behaves_like "object with relative dimensions"
|
34
|
-
end
|
35
|
-
|
36
|
-
describe "negative dimensions" do
|
37
|
-
subject { Shoes::Border.new(app, parent, blue, negative_opts) }
|
38
|
-
it_behaves_like "object with negative dimensions"
|
39
|
-
end
|
40
|
-
|
41
|
-
it {should_not be_takes_up_space}
|
42
|
-
it {should_not be_needs_to_be_positioned}
|
43
|
-
end
|
@@ -1,84 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::BuiltinMethods do
|
4
|
-
let(:input_blk) { Proc.new {} }
|
5
|
-
let(:app) { Shoes::App.new({}, &input_blk) }
|
6
|
-
let(:logger) { double("logger") }
|
7
|
-
|
8
|
-
before :each do
|
9
|
-
Shoes::LOG.clear
|
10
|
-
Shoes.stub(:logger) { logger }
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'Shoes.p' do
|
14
|
-
it 'adds a debug to the log with an inspected object' do
|
15
|
-
Shoes.p 'message'
|
16
|
-
Shoes::LOG.should include ['debug', 'message'.inspect]
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'also handles object the way they should be handled' do
|
20
|
-
Shoes.p []
|
21
|
-
Shoes::LOG.should include ['debug', '[]']
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "info" do
|
26
|
-
before :each do
|
27
|
-
logger.stub(:info)
|
28
|
-
app.info("test")
|
29
|
-
end
|
30
|
-
|
31
|
-
it "sets Shoes::LOG" do
|
32
|
-
expect(Shoes::LOG).to eq([["info", "test"]])
|
33
|
-
end
|
34
|
-
|
35
|
-
it "sends message to logger" do
|
36
|
-
expect(logger).to have_received(:info)
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "debug" do
|
41
|
-
before :each do
|
42
|
-
logger.stub(:debug)
|
43
|
-
app.debug("test")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "sets Shoes::LOG" do
|
47
|
-
expect(Shoes::LOG).to eq([["debug", "test"]])
|
48
|
-
end
|
49
|
-
|
50
|
-
it "sends message to logger" do
|
51
|
-
expect(logger).to have_received(:debug)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
describe "warn" do
|
56
|
-
before :each do
|
57
|
-
logger.stub(:warn)
|
58
|
-
app.warn("test")
|
59
|
-
end
|
60
|
-
|
61
|
-
it "sets Shoes::LOG" do
|
62
|
-
expect(Shoes::LOG).to eq([["warn", "test"]])
|
63
|
-
end
|
64
|
-
|
65
|
-
it "sends message to logger" do
|
66
|
-
expect(logger).to have_received(:warn)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
describe "error" do
|
71
|
-
before :each do
|
72
|
-
logger.stub(:error)
|
73
|
-
app.error("test")
|
74
|
-
end
|
75
|
-
|
76
|
-
it "sets Shoes::LOG" do
|
77
|
-
expect(Shoes::LOG).to eq([["error", "test"]])
|
78
|
-
end
|
79
|
-
|
80
|
-
it "sends message to logger" do
|
81
|
-
expect(logger).to have_received(:error)
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
data/spec/shoes/button_spec.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require "shoes/spec_helper"
|
2
|
-
|
3
|
-
describe Shoes::Button do
|
4
|
-
include_context "dsl app"
|
5
|
-
let(:input_opts) { {:left => left, :top => top, :width => width,
|
6
|
-
:height => height, :margin => margin, :state => "disabled"} }
|
7
|
-
|
8
|
-
let(:left) { 13 }
|
9
|
-
let(:top) { 44 }
|
10
|
-
let(:width) { 131 }
|
11
|
-
let(:height) { 137 }
|
12
|
-
let(:margin) { 14 }
|
13
|
-
|
14
|
-
subject(:button) { Shoes::Button.new(app, parent, "text", input_opts, input_block) }
|
15
|
-
|
16
|
-
it_behaves_like "movable object"
|
17
|
-
it_behaves_like "object with state"
|
18
|
-
it_behaves_like "object with dimensions"
|
19
|
-
|
20
|
-
it { should respond_to :click }
|
21
|
-
it { should respond_to :focus }
|
22
|
-
|
23
|
-
describe "initialize" do
|
24
|
-
its(:parent) { should eq(parent) }
|
25
|
-
its(:blk) { should eq(input_block) }
|
26
|
-
its(:text) { should eq("text") }
|
27
|
-
its(:width) { should eq(131) }
|
28
|
-
its(:height) { should eq(137) }
|
29
|
-
its(:state) { should eq("disabled") }
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "relative dimensions" do
|
33
|
-
subject { Shoes::Button.new(app, parent, "text", relative_opts, input_block) }
|
34
|
-
it_behaves_like "object with relative dimensions"
|
35
|
-
end
|
36
|
-
|
37
|
-
describe "negative dimensions" do
|
38
|
-
subject { Shoes::Button.new(app, parent, "text", negative_opts, input_block) }
|
39
|
-
it_behaves_like "object with negative dimensions"
|
40
|
-
end
|
41
|
-
end
|
data/spec/shoes/check_spec.rb
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Check do
|
4
|
-
include_context "dsl app"
|
5
|
-
|
6
|
-
subject { Shoes::Check.new(app, parent, input_opts, input_block) }
|
7
|
-
|
8
|
-
it_behaves_like "checkable"
|
9
|
-
it_behaves_like "object with state"
|
10
|
-
|
11
|
-
describe "dimensions" do
|
12
|
-
let(:left) { 10 }
|
13
|
-
let(:top) { 20 }
|
14
|
-
let(:width) { 100 }
|
15
|
-
let(:height) { 200 }
|
16
|
-
let(:input_opts){ {left: left, top: top, width: width, height: height} }
|
17
|
-
subject { Shoes::Check.new(app, parent, input_opts) }
|
18
|
-
|
19
|
-
it_behaves_like "object with dimensions"
|
20
|
-
|
21
|
-
describe "takes relative dimensions from parent" do
|
22
|
-
subject { Shoes::Check.new(app, parent, relative_opts) }
|
23
|
-
it_behaves_like "object with relative dimensions"
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "negative dimensions" do
|
27
|
-
subject { Shoes::Check.new(app, parent, negative_opts) }
|
28
|
-
it_behaves_like "object with negative dimensions"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
data/spec/shoes/cli_spec.rb
DELETED
@@ -1,16 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'shoes/cli'
|
3
|
-
|
4
|
-
describe Shoes::CLI do
|
5
|
-
subject {Shoes::CLI.new}
|
6
|
-
|
7
|
-
before :each do
|
8
|
-
subject.stub :package
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'does not raise an error for a normal packaging command #624' do
|
12
|
-
expect do
|
13
|
-
subject.run ['-p', 'swt:app', 'test/simple-sound.rb']
|
14
|
-
end.not_to raise_error
|
15
|
-
end
|
16
|
-
end
|
data/spec/shoes/color_spec.rb
DELETED
@@ -1,396 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Color do
|
4
|
-
describe ".create" do
|
5
|
-
let(:color) { Shoes::Color.new(40, 50, 60) }
|
6
|
-
|
7
|
-
it "accepts color" do
|
8
|
-
Shoes::Color.create(color).should eq(color)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "accepts string" do
|
12
|
-
Shoes::Color.create("28323c").should eq(color)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
shared_examples_for "black" do
|
17
|
-
its(:class) { should eq(Shoes::Color) }
|
18
|
-
its(:red) { should eq(0) }
|
19
|
-
its(:green) { should eq(0) }
|
20
|
-
its(:blue) { should eq(0) }
|
21
|
-
its(:hex) { should eq("#000000") }
|
22
|
-
it { should be_black }
|
23
|
-
it { should_not be_white }
|
24
|
-
end
|
25
|
-
|
26
|
-
shared_examples "color with bad arguments" do
|
27
|
-
it "raises ArgumentError" do
|
28
|
-
subject.should raise_error(ArgumentError)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
context "with wrong number of arguments" do
|
33
|
-
subject { lambda { Shoes::Color.new(10, 10) } }
|
34
|
-
it_behaves_like "color with bad arguments"
|
35
|
-
end
|
36
|
-
|
37
|
-
context "with too many hex chars" do
|
38
|
-
subject { lambda { Shoes::Color.new("a1b2c3d") } }
|
39
|
-
it_behaves_like "color with bad arguments"
|
40
|
-
end
|
41
|
-
|
42
|
-
context "with too few hex chars" do
|
43
|
-
subject { lambda { Shoes::Color.new("a1") } }
|
44
|
-
it_behaves_like "color with bad arguments"
|
45
|
-
end
|
46
|
-
|
47
|
-
context "with invalid hex chars" do
|
48
|
-
subject { lambda { Shoes::Color.new("#g01234") } }
|
49
|
-
it_behaves_like "color with bad arguments"
|
50
|
-
end
|
51
|
-
|
52
|
-
context "hex" do
|
53
|
-
let(:rgb) { Shoes::Color.new(0, 0, 0, 255) }
|
54
|
-
|
55
|
-
context "with '#000000'" do
|
56
|
-
subject { Shoes::Color.new("#000000") }
|
57
|
-
it { should eq(rgb) }
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with '000000'" do
|
61
|
-
subject { Shoes::Color.new("000000") }
|
62
|
-
it { should eq(rgb) }
|
63
|
-
end
|
64
|
-
|
65
|
-
context "with '000'" do
|
66
|
-
subject { Shoes::Color.new("000") }
|
67
|
-
it { should eq(rgb) }
|
68
|
-
end
|
69
|
-
|
70
|
-
context "with '#000'" do
|
71
|
-
subject { Shoes::Color.new("#000") }
|
72
|
-
it { should eq(rgb) }
|
73
|
-
end
|
74
|
-
|
75
|
-
context "with '#FFF'" do
|
76
|
-
let(:rgb) { Shoes::Color.new(255, 255, 255) }
|
77
|
-
subject { Shoes::Color.new("#FFF") }
|
78
|
-
it { should eq(rgb) }
|
79
|
-
end
|
80
|
-
|
81
|
-
context "with '#fff'" do
|
82
|
-
let(:rgb) { Shoes::Color.new(255, 255, 255) }
|
83
|
-
subject { Shoes::Color.new("#fff") }
|
84
|
-
it { should eq(rgb) }
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context "rgb" do
|
89
|
-
context "black" do
|
90
|
-
context "with optional alpha" do
|
91
|
-
subject { Shoes::Color.new(0, 0, 0, 0) }
|
92
|
-
it_behaves_like "black"
|
93
|
-
its(:alpha) { should eq(0) }
|
94
|
-
end
|
95
|
-
|
96
|
-
context "without optional alpha" do
|
97
|
-
subject { Shoes::Color.new(0, 0, 0) }
|
98
|
-
it_behaves_like "black"
|
99
|
-
its(:alpha) { should eq(255) }
|
100
|
-
end
|
101
|
-
|
102
|
-
context "using floats" do
|
103
|
-
context "with optional alpha" do
|
104
|
-
subject { Shoes::Color.new(0.0, 0.0, 0.0, 0.0) }
|
105
|
-
it_behaves_like "black"
|
106
|
-
its(:alpha) { should eq(0) }
|
107
|
-
end
|
108
|
-
|
109
|
-
context "without optional alpha" do
|
110
|
-
subject { Shoes::Color.new(0.0, 0.0, 0.0) }
|
111
|
-
it_behaves_like "black"
|
112
|
-
its(:alpha) { should eq(255) }
|
113
|
-
end
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
context "white" do
|
118
|
-
subject { Shoes::Color.new(255, 255, 255) }
|
119
|
-
it { should be_white }
|
120
|
-
it { should_not be_black }
|
121
|
-
end
|
122
|
-
|
123
|
-
context "peru" do
|
124
|
-
shared_examples_for "peru" do
|
125
|
-
its(:class) { should eq(Shoes::Color) }
|
126
|
-
its(:red) { should eq(205) }
|
127
|
-
its(:green) { should eq(133) }
|
128
|
-
its(:blue) { should eq(63) }
|
129
|
-
it { should_not be_black }
|
130
|
-
it { should_not be_white }
|
131
|
-
end
|
132
|
-
|
133
|
-
context "with optional alpha" do
|
134
|
-
subject { Shoes::Color.new(205, 133, 63, 100) }
|
135
|
-
it_behaves_like("peru")
|
136
|
-
its(:alpha) { should eq(100) }
|
137
|
-
end
|
138
|
-
|
139
|
-
context "without optional alpha" do
|
140
|
-
subject { Shoes::Color.new(205, 133, 63) }
|
141
|
-
it_behaves_like("peru")
|
142
|
-
its(:alpha) { should eq(255) }
|
143
|
-
end
|
144
|
-
|
145
|
-
context "using floats" do
|
146
|
-
let(:red) { 0.805 }
|
147
|
-
let(:green) { 0.52 }
|
148
|
-
let(:blue) { 0.248 }
|
149
|
-
let(:alpha) { 0.392 }
|
150
|
-
|
151
|
-
context "with optional alpha" do
|
152
|
-
subject { Shoes::Color.new(red, green, blue, alpha) }
|
153
|
-
it_behaves_like "peru"
|
154
|
-
its(:alpha) { should eq(100) }
|
155
|
-
end
|
156
|
-
|
157
|
-
context "without optional alpha" do
|
158
|
-
subject { Shoes::Color.new(red, green, blue) }
|
159
|
-
it_behaves_like "peru"
|
160
|
-
its(:alpha) { should eq(255) }
|
161
|
-
end
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
describe "light and dark" do
|
166
|
-
let(:lightgreen) { Shoes::Color.new(144, 238, 144) }
|
167
|
-
let(:darkgreen) { Shoes::Color.new(0, 100, 0) }
|
168
|
-
let(:mediumseagreen) { Shoes::Color.new(60, 179, 113) }
|
169
|
-
|
170
|
-
specify "light color is light" do
|
171
|
-
lightgreen.should be_light
|
172
|
-
mediumseagreen.should_not be_light
|
173
|
-
darkgreen.should_not be_light
|
174
|
-
end
|
175
|
-
|
176
|
-
specify "dark color is dark" do
|
177
|
-
lightgreen.should_not be_dark
|
178
|
-
mediumseagreen.should_not be_dark
|
179
|
-
darkgreen.should be_dark
|
180
|
-
end
|
181
|
-
end
|
182
|
-
|
183
|
-
describe "transparency" do
|
184
|
-
let(:transparent) { Shoes::Color.new(25, 25, 112, 0) }
|
185
|
-
let(:semi) { Shoes::Color.new(25, 25, 112, 100) }
|
186
|
-
let(:opaque) { Shoes::Color.new(25, 25, 25) }
|
187
|
-
|
188
|
-
specify "only transparent colors are transparent" do
|
189
|
-
transparent.should be_transparent
|
190
|
-
semi.should_not be_transparent
|
191
|
-
opaque.should_not be_transparent
|
192
|
-
end
|
193
|
-
|
194
|
-
specify "only opaque colors should be opaque" do
|
195
|
-
transparent.should_not be_opaque
|
196
|
-
semi.should_not be_opaque
|
197
|
-
opaque.should be_opaque
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe "comparable" do
|
202
|
-
let(:color_1) { Shoes::Color.new(255, 69, 0) }
|
203
|
-
let(:red) {Shoes::Color.new 255, 0, 0}
|
204
|
-
let(:green) {Shoes::Color.new 0, 255, 0}
|
205
|
-
|
206
|
-
it "is equal when values are equal" do
|
207
|
-
color_2 = Shoes::Color.new(255, 69, 0)
|
208
|
-
color_1.should eq(color_2)
|
209
|
-
end
|
210
|
-
|
211
|
-
it "is less than when darker" do
|
212
|
-
color_2 = Shoes::Color.new(255, 70, 0)
|
213
|
-
color_1.should be < color_2
|
214
|
-
end
|
215
|
-
|
216
|
-
it "is greater than when lighter" do
|
217
|
-
color_2 = Shoes::Color.new(255, 68, 0)
|
218
|
-
color_1.should be > color_2
|
219
|
-
end
|
220
|
-
|
221
|
-
it 'does not claim for full red and full green to be equal' do
|
222
|
-
expect(red).not_to eq green
|
223
|
-
end
|
224
|
-
|
225
|
-
it 'claims that a color is the same as itself' do
|
226
|
-
expect(green).to eq green
|
227
|
-
end
|
228
|
-
|
229
|
-
context "same rgb values" do
|
230
|
-
let(:color_2) { Shoes::Color.new(255, 69, 0, 254) }
|
231
|
-
it "is less than when less opaque" do
|
232
|
-
color_2.should be < color_1
|
233
|
-
end
|
234
|
-
|
235
|
-
it "is greater than when more opaque" do
|
236
|
-
color_1.should be > color_2
|
237
|
-
end
|
238
|
-
end
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
|
243
|
-
describe "Shoes built-in colors" do
|
244
|
-
class MockApp
|
245
|
-
include Shoes::DSL
|
246
|
-
end
|
247
|
-
|
248
|
-
subject { MockApp.new }
|
249
|
-
|
250
|
-
its(:papayawhip) { should eq(Shoes::Color.new(255, 239, 213)) }
|
251
|
-
its(:aquamarine) { should eq(Shoes::Color.new(127, 255, 212)) }
|
252
|
-
its(:tomato) { should eq(Shoes::Color.new(255, 99, 71)) }
|
253
|
-
end
|
254
|
-
|
255
|
-
describe "Shoes built in gray" do
|
256
|
-
let(:app) { Shoes::App.new }
|
257
|
-
|
258
|
-
it "creates a dsl method for gray" do
|
259
|
-
app.should respond_to(:gray)
|
260
|
-
end
|
261
|
-
|
262
|
-
specify "gray with no parameters is [128, 128, 128, OPAQUE]" do
|
263
|
-
app.gray.should eq(Shoes::Color.new(128, 128, 128))
|
264
|
-
end
|
265
|
-
|
266
|
-
specify "single parameter specifies the gray level" do
|
267
|
-
app.gray(64).should eq(Shoes::Color.new(64, 64, 64))
|
268
|
-
end
|
269
|
-
|
270
|
-
specify "two parameters specifies the gray level and opacity" do
|
271
|
-
app.gray(13, 57).should eq(Shoes::Color.new(13, 13, 13, 57))
|
272
|
-
end
|
273
|
-
|
274
|
-
specify "float parameters should be normalised" do
|
275
|
-
app.gray(1.0, 0.5).should eq(Shoes::Color.new( 255, 255, 255, 128 ))
|
276
|
-
end
|
277
|
-
|
278
|
-
it 'hangles 0.93 right as well' do
|
279
|
-
result_93 = (0.93 * 255).to_i
|
280
|
-
expect(app.gray(0.93)).to eq(Shoes::Color.new(result_93, result_93, result_93))
|
281
|
-
end
|
282
|
-
|
283
|
-
it 'also has a grey alias for our BE friends' do
|
284
|
-
expect(app).to respond_to :grey
|
285
|
-
end
|
286
|
-
end
|
287
|
-
|
288
|
-
# Differences between this implementation and Red Shoes
|
289
|
-
describe "differences from Red Shoes" do
|
290
|
-
let(:white) { Shoes::Color.new(255, 255, 255) }
|
291
|
-
let(:transparent_black) { Shoes::Color.new(0, 0, 0, 0) }
|
292
|
-
|
293
|
-
context "integers" do
|
294
|
-
specify "too-large values become 255" do
|
295
|
-
Shoes::Color.new(256, 256, 256, 256).should eq(white)
|
296
|
-
end
|
297
|
-
|
298
|
-
specify "too-small values become 0" do
|
299
|
-
Shoes::Color.new(-1, -1, -1, -1).should eq(transparent_black)
|
300
|
-
end
|
301
|
-
end
|
302
|
-
|
303
|
-
context "floats" do
|
304
|
-
specify "too-large values become 255" do
|
305
|
-
Shoes::Color.new(1.1, 1.1, 1.1, 1.1).should eq(white)
|
306
|
-
end
|
307
|
-
|
308
|
-
specify "too-small values become 0" do
|
309
|
-
Shoes::Color.new(-0.1, -0.1, -0.1, -0.1).should eq(transparent_black)
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
# These specifications describe how this implementation differs from Red Shoes.
|
314
|
-
# These are examples of what Red Shoes _does_ do, and what this implementation
|
315
|
-
# _does not_ do.
|
316
|
-
describe "unusual input" do
|
317
|
-
let(:baseline) { Shoes::Color.new(50, 0, 200) }
|
318
|
-
|
319
|
-
describe "too-large values" do
|
320
|
-
specify "red does not get modulo-256'd into bounds" do
|
321
|
-
Shoes::Color.new(306, 0, 200).should_not eq(baseline)
|
322
|
-
Shoes::Color.new(1.197, 0, 200).should_not eq(baseline)
|
323
|
-
end
|
324
|
-
|
325
|
-
specify "green does not get modulo-256'd into bounds" do
|
326
|
-
Shoes::Color.new(50, 256, 200).should_not eq(baseline)
|
327
|
-
Shoes::Color.new(50, 2.005, 200).should_not eq(baseline)
|
328
|
-
end
|
329
|
-
|
330
|
-
specify "blue does not get modulo-256'd into bounds" do
|
331
|
-
Shoes::Color.new(50, 0, 456).should_not eq(baseline)
|
332
|
-
Shoes::Color.new(50, 0, 2.7913137254902).should_not eq(baseline)
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
describe "negative values" do
|
337
|
-
specify "-1 does not become 255" do
|
338
|
-
Shoes::Color.new(-1, -1, -1, -1).should_not eq(Shoes::Color.new(255, 255, 255))
|
339
|
-
end
|
340
|
-
|
341
|
-
specify "256 and neighbors" do
|
342
|
-
Shoes::Color.new(-256, -255, -257).should_not eq(Shoes::Color.new(0, 1, 255))
|
343
|
-
end
|
344
|
-
|
345
|
-
specify "float behaviour" do
|
346
|
-
Shoes::Color.new(-1.0, -0.5, -0.0).should_not eq(Shoes::Color.new(0, 128, 1))
|
347
|
-
end
|
348
|
-
end
|
349
|
-
|
350
|
-
describe "edge cases" do
|
351
|
-
specify "0.0 does not become 1" do
|
352
|
-
Shoes::Color.new(0.0, 0.0, 0.0).should_not eq(Shoes::Color.new(1, 1, 1))
|
353
|
-
end
|
354
|
-
|
355
|
-
specify "1.0 does not become 0" do
|
356
|
-
Shoes::Color.new(1.0, 1.0, 1.0).should_not eq(Shoes::Color.new(0, 0, 0))
|
357
|
-
end
|
358
|
-
end
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
describe Shoes::Color::DSLHelpers do
|
363
|
-
class ColorDSLHelperTest
|
364
|
-
include Shoes::Color::DSLHelpers
|
365
|
-
end
|
366
|
-
|
367
|
-
subject {ColorDSLHelperTest.new}
|
368
|
-
|
369
|
-
describe '#pattern' do
|
370
|
-
it 'creates an image pattern when fed a string for which a file exists' do
|
371
|
-
File.stub(exist?: true)
|
372
|
-
my_path = '/some/path/to/image.png'
|
373
|
-
image_pattern = subject.pattern(my_path)
|
374
|
-
expect(image_pattern.path).to eq my_path
|
375
|
-
end
|
376
|
-
|
377
|
-
it 'raises an argument error for bad input like a single number' do
|
378
|
-
expect {subject.pattern(1)}.to raise_error(ArgumentError)
|
379
|
-
end
|
380
|
-
|
381
|
-
it 'creates a gradient given 2 arguments' do
|
382
|
-
expect(subject).to receive(:gradient)
|
383
|
-
subject.pattern([10, 10, 10], [30, 30, 30])
|
384
|
-
end
|
385
|
-
end
|
386
|
-
|
387
|
-
describe '#gradient' do
|
388
|
-
it 'raises an argument error for no arguments supplied' do
|
389
|
-
expect{subject.gradient}.to raise_error ArgumentError
|
390
|
-
end
|
391
|
-
|
392
|
-
it 'raises an argument error for too many (> 2) args supplied' do
|
393
|
-
expect{subject.gradient 1, 2, 3}.to raise_error ArgumentError
|
394
|
-
end
|
395
|
-
end
|
396
|
-
end
|