shoes-swt 4.0.0.pre2 → 4.0.0.pre3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +5 -200
- data/Rakefile +1 -0
- data/bin/shoes-swt +11 -0
- data/lib/shoes/swt.rb +5 -2
- data/lib/shoes/swt/animation.rb +2 -2
- data/lib/shoes/swt/app.rb +45 -50
- data/lib/shoes/swt/arc.rb +7 -7
- data/lib/shoes/swt/background.rb +1 -1
- data/lib/shoes/swt/border.rb +1 -2
- data/lib/shoes/swt/click_listener.rb +70 -0
- data/lib/shoes/swt/color.rb +5 -5
- data/lib/shoes/swt/common/clickable.rb +2 -53
- data/lib/shoes/swt/common/fill.rb +1 -1
- data/lib/shoes/swt/common/painter.rb +7 -7
- data/lib/shoes/swt/common/painter_updates_position.rb +2 -2
- data/lib/shoes/swt/common/remove.rb +2 -3
- data/lib/shoes/swt/common/resource.rb +1 -1
- data/lib/shoes/swt/common/selection_listener.rb +14 -14
- data/lib/shoes/swt/common/stroke.rb +1 -2
- data/lib/shoes/swt/common/update_position.rb +1 -1
- data/lib/shoes/swt/dialog.rb +3 -45
- data/lib/shoes/swt/disposed_protection.rb +1 -1
- data/lib/shoes/swt/download.rb +0 -1
- data/lib/shoes/swt/font.rb +4 -4
- data/lib/shoes/swt/generate-backend.rb +9 -0
- data/lib/shoes/swt/gradient.rb +17 -16
- data/lib/shoes/swt/image.rb +3 -5
- data/lib/shoes/swt/image_pattern.rb +2 -2
- data/lib/shoes/swt/input_box.rb +3 -3
- data/lib/shoes/swt/key_listener.rb +6 -6
- data/lib/shoes/swt/line.rb +4 -24
- data/lib/shoes/swt/link.rb +2 -2
- data/lib/shoes/swt/link_segment.rb +3 -3
- data/lib/shoes/swt/list_box.rb +4 -4
- data/lib/shoes/swt/mouse_move_listener.rb +6 -5
- data/lib/shoes/swt/oval.rb +2 -3
- data/lib/shoes/swt/packager.rb +82 -0
- data/lib/shoes/swt/progress.rb +2 -2
- data/lib/shoes/swt/radio.rb +0 -2
- data/lib/shoes/swt/radio_group.rb +54 -54
- data/lib/shoes/swt/rect_painter.rb +7 -7
- data/lib/shoes/swt/redrawing_aspect.rb +32 -34
- data/lib/shoes/swt/shape.rb +1 -1
- data/lib/shoes/swt/shoes_layout.rb +5 -2
- data/lib/shoes/swt/slot.rb +2 -3
- data/lib/shoes/swt/sound.rb +17 -22
- data/lib/shoes/swt/star.rb +30 -8
- data/lib/shoes/swt/swt_button.rb +3 -2
- data/lib/shoes/swt/text_block.rb +3 -3
- data/lib/shoes/swt/text_block/cursor_painter.rb +2 -2
- data/lib/shoes/swt/text_block/fitter.rb +5 -3
- data/lib/shoes/swt/text_block/painter.rb +9 -9
- data/lib/shoes/swt/text_block/text_font_factory.rb +3 -3
- data/lib/shoes/swt/text_block/text_segment.rb +9 -9
- data/lib/shoes/swt/text_block/text_segment_collection.rb +2 -0
- data/lib/shoes/swt/text_block/text_style_factory.rb +9 -3
- data/lib/shoes/swt/timer.rb +1 -1
- data/lib/shoes/swt/version.rb +1 -1
- data/shoes-swt.gemspec +7 -6
- data/spec/shoes/cli_spec.rb +2 -2
- data/spec/{swt_shoes → shoes/swt}/animation_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/app_spec.rb +36 -3
- data/spec/{swt_shoes → shoes/swt}/arc_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/background_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/border_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/button_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/check_spec.rb +1 -1
- data/spec/shoes/swt/click_listener_spec.rb +162 -0
- data/spec/{swt_shoes → shoes/swt}/color_factory_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/color_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/common/painter_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/common/remove_spec.rb +4 -11
- data/spec/{swt_shoes → shoes/swt}/configuration_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/dialog_spec.rb +1 -7
- data/spec/{swt_shoes → shoes/swt}/disposed_protection_spec.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/flow_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/font_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/gradient_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/image_pattern_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/image_spec.rb +4 -3
- data/spec/{swt_shoes → shoes/swt}/input_box_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/integration_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/key_listener_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/line_spec.rb +4 -8
- data/spec/{swt_shoes → shoes/swt}/link_segment_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/link_spec.rb +3 -10
- data/spec/{swt_shoes → shoes/swt}/list_box_spec.rb +5 -3
- data/spec/{swt_shoes → shoes/swt}/minimal.png +0 -0
- data/spec/{swt_shoes → shoes/swt}/mouse_move_listener_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/oval_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/progress_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/radio_group_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/radio_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/rect_painter_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/rect_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/shape_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/shared_examples/button.rb +0 -0
- data/spec/shoes/swt/shared_examples/clickable.rb +13 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/movable.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/paintable.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/painter.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/pattern.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shared_examples/removable.rb +1 -3
- data/spec/{swt_shoes → shoes/swt}/shared_examples/swt_app_context.rb +11 -3
- data/spec/{swt_shoes → shoes/swt}/shared_examples/visibility.rb +0 -0
- data/spec/{swt_shoes → shoes/swt}/shell_control_listener_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/slot_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/spec_helper.rb +0 -1
- data/spec/{swt_shoes → shoes/swt}/star_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block/centered_text_segment_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block/cursor_painter_spec.rb +8 -4
- data/spec/{swt_shoes → shoes/swt}/text_block/fitter_spec.rb +5 -5
- data/spec/{swt_shoes → shoes/swt}/text_block/painter_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block/text_font_factory_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block/text_segment_collection_spec.rb +7 -2
- data/spec/{swt_shoes → shoes/swt}/text_block/text_segment_spec.rb +1 -1
- data/spec/{swt_shoes → shoes/swt}/text_block_spec.rb +2 -5
- data/spec/spec_helper.rb +7 -3
- metadata +132 -331
- data/CHANGELOG +0 -84
- data/Gemfile +0 -24
- data/Guardfile +0 -11
- data/manifests/common.rb +0 -34
- data/manifests/shoes-swt.rb +0 -29
- data/spec/code_coverage.rb +0 -14
- data/spec/shoes/animation_spec.rb +0 -65
- data/spec/shoes/app_spec.rb +0 -484
- data/spec/shoes/arc_spec.rb +0 -51
- data/spec/shoes/background_spec.rb +0 -53
- data/spec/shoes/border_spec.rb +0 -47
- data/spec/shoes/builtin_methods_spec.rb +0 -110
- data/spec/shoes/button_spec.rb +0 -44
- data/spec/shoes/check_spec.rb +0 -35
- data/spec/shoes/color_spec.rb +0 -408
- data/spec/shoes/common/inspect_spec.rb +0 -26
- data/spec/shoes/common/remove_spec.rb +0 -38
- data/spec/shoes/common/style_normalizer_spec.rb +0 -28
- data/spec/shoes/common/style_spec.rb +0 -147
- data/spec/shoes/configuration_spec.rb +0 -36
- data/spec/shoes/constants_spec.rb +0 -38
- data/spec/shoes/dialog_spec.rb +0 -163
- data/spec/shoes/dimension_spec.rb +0 -407
- data/spec/shoes/dimensions_spec.rb +0 -837
- data/spec/shoes/download_spec.rb +0 -142
- data/spec/shoes/flow_spec.rb +0 -133
- data/spec/shoes/font_spec.rb +0 -37
- data/spec/shoes/framework_learning_spec.rb +0 -30
- data/spec/shoes/gradient_spec.rb +0 -32
- data/spec/shoes/helpers/fake_element.rb +0 -17
- data/spec/shoes/helpers/inspect_helpers.rb +0 -5
- data/spec/shoes/helpers/sample17_helper.rb +0 -66
- data/spec/shoes/image_spec.rb +0 -49
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +0 -80
- data/spec/shoes/integration_spec.rb +0 -20
- data/spec/shoes/internal_app_spec.rb +0 -141
- data/spec/shoes/keypress_spec.rb +0 -11
- data/spec/shoes/keyrelease_spec.rb +0 -12
- data/spec/shoes/line_spec.rb +0 -49
- data/spec/shoes/link_spec.rb +0 -105
- data/spec/shoes/list_box_spec.rb +0 -74
- data/spec/shoes/logger/ruby_spec.rb +0 -8
- data/spec/shoes/logger_spec.rb +0 -45
- data/spec/shoes/oval_spec.rb +0 -24
- data/spec/shoes/point_spec.rb +0 -71
- data/spec/shoes/progress_spec.rb +0 -54
- data/spec/shoes/radio_spec.rb +0 -32
- data/spec/shoes/rect_spec.rb +0 -39
- data/spec/shoes/renamed_delegate_spec.rb +0 -70
- data/spec/shoes/shape_spec.rb +0 -95
- 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 -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/video.rb +0 -5
- 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/scroll.rb +0 -41
- data/spec/shoes/shared_examples/shared_element_method.rb +0 -60
- data/spec/shoes/shared_examples/slot.rb +0 -331
- data/spec/shoes/shared_examples/state.rb +0 -19
- data/spec/shoes/shared_examples/style.rb +0 -82
- data/spec/shoes/slot_spec.rb +0 -130
- data/spec/shoes/sound_spec.rb +0 -15
- 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 -31
- data/spec/shoes/text_block_dimensions_spec.rb +0 -75
- data/spec/shoes/text_block_spec.rb +0 -270
- data/spec/shoes/url_spec.rb +0 -68
- data/spec/shoes/widget_spec.rb +0 -70
- data/spec/shoes_spec.rb +0 -44
- data/spec/swt_shoes/shared_examples/clickable.rb +0 -85
- data/spec/swt_shoes/sound.rb +0 -10
data/spec/shoes/arc_spec.rb
DELETED
@@ -1,51 +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 style" do
|
18
|
-
let(:subject_without_style) { Shoes::Arc.new(app, parent, left, top, width, height, start_angle, end_angle) }
|
19
|
-
let(:subject_with_style) { Shoes::Arc.new(app, parent, left, top, width, height, start_angle, end_angle, arg_styles) }
|
20
|
-
end
|
21
|
-
it_behaves_like "object with dimensions"
|
22
|
-
it_behaves_like "left, top as center", :start_angle, :end_angle
|
23
|
-
it_behaves_like "object with parent"
|
24
|
-
|
25
|
-
#it_styles_with :art_styles, :center, :dimensions, :radius
|
26
|
-
|
27
|
-
it "is a Shoes::Arc" do
|
28
|
-
expect(arc.class).to be(Shoes::Arc)
|
29
|
-
end
|
30
|
-
|
31
|
-
its(:angle1) { should eq(0) }
|
32
|
-
its(:angle2) { should eq(Shoes::TWO_PI) }
|
33
|
-
its(:wedge) { should eq(false) }
|
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 "with wedge: true" do
|
47
|
-
subject(:arc) { Shoes::Arc.new(app, parent, left, top, width, height, start_angle, end_angle, wedge: true) }
|
48
|
-
|
49
|
-
its(:wedge) { should eq(true) }
|
50
|
-
end
|
51
|
-
end
|
@@ -1,53 +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" do
|
24
|
-
subject(:background) { Shoes::Background.new(app, parent, Shoes::COLORS[:black]) }
|
25
|
-
let(:subject_without_style) { Shoes::Background.new(app, parent, blue) }
|
26
|
-
let(:subject_with_style) { Shoes::Background.new(app, parent, blue, arg_styles) }
|
27
|
-
end
|
28
|
-
|
29
|
-
it_behaves_like "object with dimensions"
|
30
|
-
|
31
|
-
describe "relative dimensions from parent" do
|
32
|
-
subject { Shoes::Background.new(app, parent, blue, relative_opts) }
|
33
|
-
it_behaves_like "object with relative dimensions"
|
34
|
-
end
|
35
|
-
|
36
|
-
context "negative dimensions" do
|
37
|
-
subject { Shoes::Background.new(app, parent, blue, negative_opts) }
|
38
|
-
it_behaves_like "object with negative dimensions"
|
39
|
-
end
|
40
|
-
|
41
|
-
describe '#needs_to_be_positioned?' do
|
42
|
-
context 'without absolute dimensions' do
|
43
|
-
let(:input_opts) {{}}
|
44
|
-
it {is_expected.not_to be_needs_to_be_positioned}
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with absolute dimensions' do
|
48
|
-
it {is_expected.to be_needs_to_be_positioned}
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
it {is_expected.not_to be_takes_up_space}
|
53
|
-
end
|
data/spec/shoes/border_spec.rb
DELETED
@@ -1,47 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for "basic border" 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::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" do
|
29
|
-
subject { Shoes::Border.new(app, parent, Shoes::COLORS[:black]) }
|
30
|
-
let(:subject_without_style) { Shoes::Border.new(app, parent, blue) }
|
31
|
-
let(:subject_with_style) { Shoes::Border.new(app, parent, blue, arg_styles) }
|
32
|
-
end
|
33
|
-
it_behaves_like "object with dimensions"
|
34
|
-
|
35
|
-
describe "relative dimensions from parent" do
|
36
|
-
subject { Shoes::Border.new(app, parent, blue, relative_opts) }
|
37
|
-
it_behaves_like "object with relative dimensions"
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "negative dimensions" do
|
41
|
-
subject { Shoes::Border.new(app, parent, blue, negative_opts) }
|
42
|
-
it_behaves_like "object with negative dimensions"
|
43
|
-
end
|
44
|
-
|
45
|
-
it {is_expected.not_to be_takes_up_space}
|
46
|
-
it {is_expected.not_to be_needs_to_be_positioned}
|
47
|
-
end
|
@@ -1,110 +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
|
-
allow(Shoes).to receive(: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
|
-
expect(Shoes::LOG).to include ['debug', 'message'.inspect]
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'also handles object the way they should be handled' do
|
20
|
-
Shoes.p []
|
21
|
-
expect(Shoes::LOG).to include ['debug', '[]']
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe "info" do
|
26
|
-
before :each do
|
27
|
-
allow(logger).to receive(: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
|
-
allow(logger).to receive(: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
|
-
allow(logger).to receive(: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
|
-
allow(logger).to receive(: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
|
-
|
85
|
-
# just testing responds to things since the implementation is tested
|
86
|
-
# elsewhere
|
87
|
-
describe 'are builtin methods are also available from Shoes' do
|
88
|
-
builtin_methods = [:alert, :ask, :ask_color, :ask_open_file, :ask_save_file,
|
89
|
-
:ask_open_folder, :ask_save_folder, :confirm, :color,
|
90
|
-
:debug, :error, :font, :gradient, :gray, :rgb, :info,
|
91
|
-
:pattern, :warn]
|
92
|
-
|
93
|
-
builtin_methods.each do |method|
|
94
|
-
it "responds to #{method}" do
|
95
|
-
expect(Shoes).to respond_to method
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
describe 'does not get to the nitty gritty helper_methods' do
|
101
|
-
helper_methods = [:image_file?, :image_pattern]
|
102
|
-
|
103
|
-
helper_methods.each do |method|
|
104
|
-
it "does not respond to #{method}" do
|
105
|
-
expect(Shoes).not_to respond_to method
|
106
|
-
end
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
data/spec/shoes/button_spec.rb
DELETED
@@ -1,44 +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 style" do
|
19
|
-
let(:subject_without_style) { Shoes::Button.new(app, parent, "text") }
|
20
|
-
let(:subject_with_style) { Shoes::Button.new(app, parent, "text", arg_styles) }
|
21
|
-
end
|
22
|
-
it_behaves_like "object with dimensions"
|
23
|
-
|
24
|
-
it { is_expected.to respond_to :click }
|
25
|
-
it { is_expected.to respond_to :focus }
|
26
|
-
|
27
|
-
describe "initialize" do
|
28
|
-
its(:parent) { should eq(parent) }
|
29
|
-
its(:text) { should eq("text") }
|
30
|
-
its(:width) { should eq(131) }
|
31
|
-
its(:height) { should eq(137) }
|
32
|
-
its(:state) { should eq("disabled") }
|
33
|
-
end
|
34
|
-
|
35
|
-
describe "relative dimensions" do
|
36
|
-
subject { Shoes::Button.new(app, parent, "text", relative_opts, input_block) }
|
37
|
-
it_behaves_like "object with relative dimensions"
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "negative dimensions" do
|
41
|
-
subject { Shoes::Button.new(app, parent, "text", negative_opts, input_block) }
|
42
|
-
it_behaves_like "object with negative dimensions"
|
43
|
-
end
|
44
|
-
end
|
data/spec/shoes/check_spec.rb
DELETED
@@ -1,35 +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
|
-
it_behaves_like "object with style" do
|
11
|
-
let(:subject_without_style) { Shoes::Check.new(app, parent) }
|
12
|
-
let(:subject_with_style) { Shoes::Check.new(app, parent, arg_styles) }
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "dimensions" do
|
16
|
-
let(:left) { 10 }
|
17
|
-
let(:top) { 20 }
|
18
|
-
let(:width) { 100 }
|
19
|
-
let(:height) { 200 }
|
20
|
-
let(:input_opts){ {left: left, top: top, width: width, height: height} }
|
21
|
-
subject { Shoes::Check.new(app, parent, input_opts) }
|
22
|
-
|
23
|
-
it_behaves_like "object with dimensions"
|
24
|
-
|
25
|
-
describe "takes relative dimensions from parent" do
|
26
|
-
subject { Shoes::Check.new(app, parent, relative_opts) }
|
27
|
-
it_behaves_like "object with relative dimensions"
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "negative dimensions" do
|
31
|
-
subject { Shoes::Check.new(app, parent, negative_opts) }
|
32
|
-
it_behaves_like "object with negative dimensions"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
data/spec/shoes/color_spec.rb
DELETED
@@ -1,408 +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
|
-
expect(Shoes::Color.create(color)).to eq(color)
|
9
|
-
end
|
10
|
-
|
11
|
-
it "accepts string" do
|
12
|
-
expect(Shoes::Color.create("28323c")).to 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 { is_expected.to be_black }
|
23
|
-
it { is_expected.not_to be_white }
|
24
|
-
end
|
25
|
-
|
26
|
-
shared_examples "color with bad arguments" do
|
27
|
-
it "raises ArgumentError" do
|
28
|
-
expect(subject).to 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 { is_expected.to eq(rgb) }
|
58
|
-
end
|
59
|
-
|
60
|
-
context "with '000000'" do
|
61
|
-
subject { Shoes::Color.new("000000") }
|
62
|
-
it { is_expected.to eq(rgb) }
|
63
|
-
end
|
64
|
-
|
65
|
-
context "with '000'" do
|
66
|
-
subject { Shoes::Color.new("000") }
|
67
|
-
it { is_expected.to eq(rgb) }
|
68
|
-
end
|
69
|
-
|
70
|
-
context "with '#000'" do
|
71
|
-
subject { Shoes::Color.new("#000") }
|
72
|
-
it { is_expected.to 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 { is_expected.to 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 { is_expected.to 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
|
-
describe "inspect" do
|
118
|
-
include InspectHelpers
|
119
|
-
|
120
|
-
# Using patterns here so we can handle the variable hex string identifier
|
121
|
-
let(:rgb_pattern) { 'rgb[(]10, 20, 30[)]' }
|
122
|
-
let(:inspect_pattern) { "[(]Shoes::Color:#{shoes_object_id_pattern} #{rgb_pattern} alpha:40[)]$" }
|
123
|
-
subject(:color) { Shoes::Color.new(10, 20, 30, 40) }
|
124
|
-
|
125
|
-
its(:to_s) { should match(rgb_pattern) }
|
126
|
-
its(:inspect) { should match(inspect_pattern) }
|
127
|
-
end
|
128
|
-
|
129
|
-
context "white" do
|
130
|
-
subject { Shoes::Color.new(255, 255, 255) }
|
131
|
-
it { is_expected.to be_white }
|
132
|
-
it { is_expected.not_to be_black }
|
133
|
-
end
|
134
|
-
|
135
|
-
context "peru" do
|
136
|
-
shared_examples_for "peru" do
|
137
|
-
its(:class) { should eq(Shoes::Color) }
|
138
|
-
its(:red) { should eq(205) }
|
139
|
-
its(:green) { should eq(133) }
|
140
|
-
its(:blue) { should eq(63) }
|
141
|
-
it { is_expected.not_to be_black }
|
142
|
-
it { is_expected.not_to be_white }
|
143
|
-
end
|
144
|
-
|
145
|
-
context "with optional alpha" do
|
146
|
-
subject { Shoes::Color.new(205, 133, 63, 100) }
|
147
|
-
it_behaves_like("peru")
|
148
|
-
its(:alpha) { should eq(100) }
|
149
|
-
end
|
150
|
-
|
151
|
-
context "without optional alpha" do
|
152
|
-
subject { Shoes::Color.new(205, 133, 63) }
|
153
|
-
it_behaves_like("peru")
|
154
|
-
its(:alpha) { should eq(255) }
|
155
|
-
end
|
156
|
-
|
157
|
-
context "using floats" do
|
158
|
-
let(:red) { 0.805 }
|
159
|
-
let(:green) { 0.52 }
|
160
|
-
let(:blue) { 0.248 }
|
161
|
-
let(:alpha) { 0.392 }
|
162
|
-
|
163
|
-
context "with optional alpha" do
|
164
|
-
subject { Shoes::Color.new(red, green, blue, alpha) }
|
165
|
-
it_behaves_like "peru"
|
166
|
-
its(:alpha) { should eq(100) }
|
167
|
-
end
|
168
|
-
|
169
|
-
context "without optional alpha" do
|
170
|
-
subject { Shoes::Color.new(red, green, blue) }
|
171
|
-
it_behaves_like "peru"
|
172
|
-
its(:alpha) { should eq(255) }
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
|
177
|
-
describe "light and dark" do
|
178
|
-
let(:lightgreen) { Shoes::Color.new(144, 238, 144) }
|
179
|
-
let(:darkgreen) { Shoes::Color.new(0, 100, 0) }
|
180
|
-
let(:mediumseagreen) { Shoes::Color.new(60, 179, 113) }
|
181
|
-
|
182
|
-
specify "light color is light" do
|
183
|
-
expect(lightgreen).to be_light
|
184
|
-
expect(mediumseagreen).not_to be_light
|
185
|
-
expect(darkgreen).not_to be_light
|
186
|
-
end
|
187
|
-
|
188
|
-
specify "dark color is dark" do
|
189
|
-
expect(lightgreen).not_to be_dark
|
190
|
-
expect(mediumseagreen).not_to be_dark
|
191
|
-
expect(darkgreen).to be_dark
|
192
|
-
end
|
193
|
-
end
|
194
|
-
|
195
|
-
describe "transparency" do
|
196
|
-
let(:transparent) { Shoes::Color.new(25, 25, 112, 0) }
|
197
|
-
let(:semi) { Shoes::Color.new(25, 25, 112, 100) }
|
198
|
-
let(:opaque) { Shoes::Color.new(25, 25, 25) }
|
199
|
-
|
200
|
-
specify "only transparent colors are transparent" do
|
201
|
-
expect(transparent).to be_transparent
|
202
|
-
expect(semi).not_to be_transparent
|
203
|
-
expect(opaque).not_to be_transparent
|
204
|
-
end
|
205
|
-
|
206
|
-
specify "only opaque colors should be opaque" do
|
207
|
-
expect(transparent).not_to be_opaque
|
208
|
-
expect(semi).not_to be_opaque
|
209
|
-
expect(opaque).to be_opaque
|
210
|
-
end
|
211
|
-
end
|
212
|
-
|
213
|
-
describe "comparable" do
|
214
|
-
let(:color_1) { Shoes::Color.new(255, 69, 0) }
|
215
|
-
let(:red) {Shoes::Color.new 255, 0, 0}
|
216
|
-
let(:green) {Shoes::Color.new 0, 255, 0}
|
217
|
-
|
218
|
-
it "is equal when values are equal" do
|
219
|
-
color_2 = Shoes::Color.new(255, 69, 0)
|
220
|
-
expect(color_1).to eq(color_2)
|
221
|
-
end
|
222
|
-
|
223
|
-
it "is less than when darker" do
|
224
|
-
color_2 = Shoes::Color.new(255, 70, 0)
|
225
|
-
expect(color_1).to be < color_2
|
226
|
-
end
|
227
|
-
|
228
|
-
it "is greater than when lighter" do
|
229
|
-
color_2 = Shoes::Color.new(255, 68, 0)
|
230
|
-
expect(color_1).to be > color_2
|
231
|
-
end
|
232
|
-
|
233
|
-
it 'does not claim for full red and full green to be equal' do
|
234
|
-
expect(red).not_to eq green
|
235
|
-
end
|
236
|
-
|
237
|
-
it 'claims that a color is the same as itself' do
|
238
|
-
expect(green).to eq green
|
239
|
-
end
|
240
|
-
|
241
|
-
context "same rgb values" do
|
242
|
-
let(:color_2) { Shoes::Color.new(255, 69, 0, 254) }
|
243
|
-
it "is less than when less opaque" do
|
244
|
-
expect(color_2).to be < color_1
|
245
|
-
end
|
246
|
-
|
247
|
-
it "is greater than when more opaque" do
|
248
|
-
expect(color_1).to be > color_2
|
249
|
-
end
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
describe "Shoes built-in colors" do
|
256
|
-
class MockApp
|
257
|
-
include Shoes::DSL
|
258
|
-
end
|
259
|
-
|
260
|
-
subject { MockApp.new }
|
261
|
-
|
262
|
-
its(:papayawhip) { should eq(Shoes::Color.new(255, 239, 213)) }
|
263
|
-
its(:aquamarine) { should eq(Shoes::Color.new(127, 255, 212)) }
|
264
|
-
its(:tomato) { should eq(Shoes::Color.new(255, 99, 71)) }
|
265
|
-
end
|
266
|
-
|
267
|
-
describe "Shoes built in gray" do
|
268
|
-
let(:app) { Shoes::App.new }
|
269
|
-
|
270
|
-
it "creates a dsl method for gray" do
|
271
|
-
expect(app).to respond_to(:gray)
|
272
|
-
end
|
273
|
-
|
274
|
-
specify "gray with no parameters is [128, 128, 128, OPAQUE]" do
|
275
|
-
expect(app.gray).to eq(Shoes::Color.new(128, 128, 128))
|
276
|
-
end
|
277
|
-
|
278
|
-
specify "single parameter specifies the gray level" do
|
279
|
-
expect(app.gray(64)).to eq(Shoes::Color.new(64, 64, 64))
|
280
|
-
end
|
281
|
-
|
282
|
-
specify "two parameters specifies the gray level and opacity" do
|
283
|
-
expect(app.gray(13, 57)).to eq(Shoes::Color.new(13, 13, 13, 57))
|
284
|
-
end
|
285
|
-
|
286
|
-
specify "float parameters should be normalised" do
|
287
|
-
expect(app.gray(1.0, 0.5)).to eq(Shoes::Color.new( 255, 255, 255, 128 ))
|
288
|
-
end
|
289
|
-
|
290
|
-
it 'hangles 0.93 right as well' do
|
291
|
-
result_93 = (0.93 * 255).to_i
|
292
|
-
expect(app.gray(0.93)).to eq(Shoes::Color.new(result_93, result_93, result_93))
|
293
|
-
end
|
294
|
-
|
295
|
-
it 'also has a grey alias for our BE friends' do
|
296
|
-
expect(app).to respond_to :grey
|
297
|
-
end
|
298
|
-
end
|
299
|
-
|
300
|
-
# Differences between this implementation and Red Shoes
|
301
|
-
describe "differences from Red Shoes" do
|
302
|
-
let(:white) { Shoes::Color.new(255, 255, 255) }
|
303
|
-
let(:transparent_black) { Shoes::Color.new(0, 0, 0, 0) }
|
304
|
-
|
305
|
-
context "integers" do
|
306
|
-
specify "too-large values become 255" do
|
307
|
-
expect(Shoes::Color.new(256, 256, 256, 256)).to eq(white)
|
308
|
-
end
|
309
|
-
|
310
|
-
specify "too-small values become 0" do
|
311
|
-
expect(Shoes::Color.new(-1, -1, -1, -1)).to eq(transparent_black)
|
312
|
-
end
|
313
|
-
end
|
314
|
-
|
315
|
-
context "floats" do
|
316
|
-
specify "too-large values become 255" do
|
317
|
-
expect(Shoes::Color.new(1.1, 1.1, 1.1, 1.1)).to eq(white)
|
318
|
-
end
|
319
|
-
|
320
|
-
specify "too-small values become 0" do
|
321
|
-
expect(Shoes::Color.new(-0.1, -0.1, -0.1, -0.1)).to eq(transparent_black)
|
322
|
-
end
|
323
|
-
end
|
324
|
-
|
325
|
-
# These specifications describe how this implementation differs from Red Shoes.
|
326
|
-
# These are examples of what Red Shoes _does_ do, and what this implementation
|
327
|
-
# _does not_ do.
|
328
|
-
describe "unusual input" do
|
329
|
-
let(:baseline) { Shoes::Color.new(50, 0, 200) }
|
330
|
-
|
331
|
-
describe "too-large values" do
|
332
|
-
specify "red does not get modulo-256'd into bounds" do
|
333
|
-
expect(Shoes::Color.new(306, 0, 200)).not_to eq(baseline)
|
334
|
-
expect(Shoes::Color.new(1.197, 0, 200)).not_to eq(baseline)
|
335
|
-
end
|
336
|
-
|
337
|
-
specify "green does not get modulo-256'd into bounds" do
|
338
|
-
expect(Shoes::Color.new(50, 256, 200)).not_to eq(baseline)
|
339
|
-
expect(Shoes::Color.new(50, 2.005, 200)).not_to eq(baseline)
|
340
|
-
end
|
341
|
-
|
342
|
-
specify "blue does not get modulo-256'd into bounds" do
|
343
|
-
expect(Shoes::Color.new(50, 0, 456)).not_to eq(baseline)
|
344
|
-
expect(Shoes::Color.new(50, 0, 2.7913137254902)).not_to eq(baseline)
|
345
|
-
end
|
346
|
-
end
|
347
|
-
|
348
|
-
describe "negative values" do
|
349
|
-
specify "-1 does not become 255" do
|
350
|
-
expect(Shoes::Color.new(-1, -1, -1, -1)).not_to eq(Shoes::Color.new(255, 255, 255))
|
351
|
-
end
|
352
|
-
|
353
|
-
specify "256 and neighbors" do
|
354
|
-
expect(Shoes::Color.new(-256, -255, -257)).not_to eq(Shoes::Color.new(0, 1, 255))
|
355
|
-
end
|
356
|
-
|
357
|
-
specify "float behaviour" do
|
358
|
-
expect(Shoes::Color.new(-1.0, -0.5, -0.0)).not_to eq(Shoes::Color.new(0, 128, 1))
|
359
|
-
end
|
360
|
-
end
|
361
|
-
|
362
|
-
describe "edge cases" do
|
363
|
-
specify "0.0 does not become 1" do
|
364
|
-
expect(Shoes::Color.new(0.0, 0.0, 0.0)).not_to eq(Shoes::Color.new(1, 1, 1))
|
365
|
-
end
|
366
|
-
|
367
|
-
specify "1.0 does not become 0" do
|
368
|
-
expect(Shoes::Color.new(1.0, 1.0, 1.0)).not_to eq(Shoes::Color.new(0, 0, 0))
|
369
|
-
end
|
370
|
-
end
|
371
|
-
end
|
372
|
-
end
|
373
|
-
|
374
|
-
describe Shoes::Color::DSLHelpers do
|
375
|
-
class ColorDSLHelperTest
|
376
|
-
include Shoes::Color::DSLHelpers
|
377
|
-
end
|
378
|
-
|
379
|
-
subject {ColorDSLHelperTest.new}
|
380
|
-
|
381
|
-
describe '#pattern' do
|
382
|
-
it 'creates an image pattern when fed a string for which a file exists' do
|
383
|
-
allow(File).to receive_messages(exist?: true)
|
384
|
-
my_path = '/some/path/to/image.png'
|
385
|
-
image_pattern = subject.pattern(my_path)
|
386
|
-
expect(image_pattern.path).to eq my_path
|
387
|
-
end
|
388
|
-
|
389
|
-
it 'raises an argument error for bad input like a single number' do
|
390
|
-
expect {subject.pattern(1)}.to raise_error(ArgumentError)
|
391
|
-
end
|
392
|
-
|
393
|
-
it 'creates a gradient given 2 arguments' do
|
394
|
-
expect(subject).to receive(:gradient)
|
395
|
-
subject.pattern([10, 10, 10], [30, 30, 30])
|
396
|
-
end
|
397
|
-
end
|
398
|
-
|
399
|
-
describe '#gradient' do
|
400
|
-
it 'raises an argument error for no arguments supplied' do
|
401
|
-
expect{subject.gradient}.to raise_error ArgumentError
|
402
|
-
end
|
403
|
-
|
404
|
-
it 'raises an argument error for too many (> 2) args supplied' do
|
405
|
-
expect{subject.gradient 1, 2, 3}.to raise_error ArgumentError
|
406
|
-
end
|
407
|
-
end
|
408
|
-
end
|