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/list_box_spec.rb
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::ListBox do
|
4
|
-
include_context "dsl app"
|
5
|
-
let(:input_opts) { { items: items, left: left, top: top, width: width,
|
6
|
-
height: height } }
|
7
|
-
|
8
|
-
let(:items) {["Wine", "Vodka", "Water"]}
|
9
|
-
|
10
|
-
let(:left) { 10 }
|
11
|
-
let(:top) { 20 }
|
12
|
-
let(:width) { 100 }
|
13
|
-
let(:height) { 200 }
|
14
|
-
|
15
|
-
subject(:list_box) { Shoes::ListBox.new(app, parent, input_opts, input_block) }
|
16
|
-
|
17
|
-
it_behaves_like "an element that can respond to change"
|
18
|
-
it_behaves_like "object with style" do
|
19
|
-
let(:subject_without_style) { Shoes::ListBox.new(app, parent) }
|
20
|
-
let(:subject_with_style) { Shoes::ListBox.new(app, parent, arg_styles) }
|
21
|
-
end
|
22
|
-
it_behaves_like "object with state"
|
23
|
-
it_behaves_like "object with dimensions"
|
24
|
-
|
25
|
-
describe "relative dimensions from parent" do
|
26
|
-
subject { Shoes::ListBox.new(app, parent, relative_opts, input_block) }
|
27
|
-
it_behaves_like "object with relative dimensions"
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "negative dimensions" do
|
31
|
-
subject { Shoes::ListBox.new(app, parent, negative_opts, input_block) }
|
32
|
-
it_behaves_like "object with negative dimensions"
|
33
|
-
end
|
34
|
-
|
35
|
-
it "contains the correct items" do
|
36
|
-
expect(subject.items).to eq(["Wine", "Vodka", "Water"])
|
37
|
-
end
|
38
|
-
|
39
|
-
it "changes the items" do
|
40
|
-
list_box.items = ["Pie", "Apple", "Pig"]
|
41
|
-
expect(list_box.items).to eq(["Pie", "Apple", "Pig"])
|
42
|
-
end
|
43
|
-
|
44
|
-
describe 'Choosing' do
|
45
|
-
it "allows us to choose an option" do
|
46
|
-
expect(list_box).to respond_to(:choose)
|
47
|
-
end
|
48
|
-
|
49
|
-
def expect_gui_choose_with(string)
|
50
|
-
expect_any_instance_of(Shoes.configuration.backend::ListBox).
|
51
|
-
to receive(:choose).with string
|
52
|
-
end
|
53
|
-
|
54
|
-
it "should call @gui.choose when we choose something" do
|
55
|
-
expect_gui_choose_with "Wine"
|
56
|
-
list_box.choose "Wine"
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should call @gui.choose when the choose option is passed' do
|
60
|
-
expect_gui_choose_with 'Wine'
|
61
|
-
Shoes::ListBox.new app, parent, input_opts.merge(choose: 'Wine')
|
62
|
-
end
|
63
|
-
end
|
64
|
-
|
65
|
-
it "should delegate #text to the backend" do
|
66
|
-
expect_any_instance_of(Shoes.configuration.backend::ListBox).
|
67
|
-
to receive(:text).and_return("Sneakers & Sandals")
|
68
|
-
expect(list_box.text).to eq("Sneakers & Sandals")
|
69
|
-
end
|
70
|
-
|
71
|
-
it 'has the initialized text elements' do
|
72
|
-
expect(subject.items).to eq items
|
73
|
-
end
|
74
|
-
end
|
data/spec/shoes/logger_spec.rb
DELETED
@@ -1,45 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Logger do
|
4
|
-
let(:awesome_logger) { Class.new }
|
5
|
-
after { Shoes::Logger.unregister(:awesome_logger) }
|
6
|
-
|
7
|
-
describe ".register" do
|
8
|
-
it "allows new loggers to be registered" do
|
9
|
-
Shoes::Logger.register(:awesome_logger, awesome_logger)
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe ".get" do
|
14
|
-
before { Shoes::Logger.register(:awesome_logger, awesome_logger) }
|
15
|
-
|
16
|
-
it "retrieves a registered logger" do
|
17
|
-
expect(Shoes::Logger.get(:awesome_logger)).to equal(awesome_logger)
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
describe "default logger" do
|
22
|
-
let(:logger) { Shoes.logger }
|
23
|
-
|
24
|
-
it "is a ruby logger" do
|
25
|
-
expect(logger).to be_an_instance_of(Shoes::Logger::Ruby)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
describe Shoes::Logger::Ruby do
|
31
|
-
let(:logdevice) { StringIO.new }
|
32
|
-
subject(:logger) { Shoes::Logger::Ruby.new logdevice }
|
33
|
-
|
34
|
-
it "logs messages with format 'LEVEL: Message'" do
|
35
|
-
logger.info "Message"
|
36
|
-
expect(logdevice.string).to eq("INFO: Message\n")
|
37
|
-
end
|
38
|
-
|
39
|
-
it "defaults to STDERR" do
|
40
|
-
allow(STDERR).to receive(:write)
|
41
|
-
logger = Shoes::Logger::Ruby.new
|
42
|
-
logger.error "Message"
|
43
|
-
expect(STDERR).to have_received(:write)
|
44
|
-
end
|
45
|
-
end
|
data/spec/shoes/oval_spec.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Oval do
|
4
|
-
include_context "dsl app"
|
5
|
-
|
6
|
-
let(:left) { 20 }
|
7
|
-
let(:top) { 30 }
|
8
|
-
let(:width) { 100 }
|
9
|
-
let(:height) { 200 }
|
10
|
-
|
11
|
-
describe "basic" do
|
12
|
-
subject { Shoes::Oval.new(app, parent, left, top, width, height) }
|
13
|
-
it_behaves_like "object with style" do
|
14
|
-
let(:subject_without_style) { Shoes::Oval.new(app, parent, left, top, width, height) }
|
15
|
-
let(:subject_with_style) { Shoes::Oval.new(app, parent, left, top, width, height, arg_styles) }
|
16
|
-
end
|
17
|
-
it_behaves_like "object with dimensions"
|
18
|
-
it_behaves_like "movable object"
|
19
|
-
it_behaves_like "left, top as center"
|
20
|
-
it_behaves_like "object with parent"
|
21
|
-
|
22
|
-
#it_styles_with :art_styles, :center, :dimensions, :radius
|
23
|
-
end
|
24
|
-
end
|
data/spec/shoes/point_spec.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Point do
|
4
|
-
subject { Shoes::Point.new(40, 50) }
|
5
|
-
let(:other_point) { Shoes::Point.new(10, 60) }
|
6
|
-
|
7
|
-
its(:x) { should eq(40) }
|
8
|
-
its(:y) { should eq(50) }
|
9
|
-
|
10
|
-
it "#left works on either point" do
|
11
|
-
expect(subject.left(other_point)).to eq(10)
|
12
|
-
expect(other_point.left(subject)).to eq(10)
|
13
|
-
end
|
14
|
-
|
15
|
-
it "#top works on either point" do
|
16
|
-
expect(subject.top(other_point)).to eq(50)
|
17
|
-
expect(other_point.top(subject)).to eq(50)
|
18
|
-
end
|
19
|
-
|
20
|
-
describe "equality" do
|
21
|
-
it "requires x and y to be equal" do
|
22
|
-
expect(subject).to eq(Shoes::Point.new 40, 50)
|
23
|
-
expect(subject).not_to eq(Shoes::Point.new 41, 50)
|
24
|
-
expect(subject).not_to eq(Shoes::Point.new 40, 51)
|
25
|
-
end
|
26
|
-
|
27
|
-
it "works with other (x,y) objects" do
|
28
|
-
expect(subject).to eq(Struct.new(:x, :y).new(40, 50))
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
describe "#to" do
|
33
|
-
it "positive" do
|
34
|
-
expect(subject.to(24, 166)).to eq(Shoes::Point.new(64, 216))
|
35
|
-
end
|
36
|
-
|
37
|
-
it "negative" do
|
38
|
-
expect(subject.to(-24, -166)).to eq(Shoes::Point.new(16, -116))
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
it "calculates width of rectangle created with other point" do
|
43
|
-
expect(subject.width(other_point)).to eq(30)
|
44
|
-
expect(other_point.width(subject)).to eq(30)
|
45
|
-
end
|
46
|
-
|
47
|
-
it "calculates height of rectangle created with other point" do
|
48
|
-
expect(subject.height(other_point)).to eq(10)
|
49
|
-
expect(other_point.height(subject)).to eq(10)
|
50
|
-
end
|
51
|
-
|
52
|
-
describe "converting to string" do
|
53
|
-
include InspectHelpers
|
54
|
-
|
55
|
-
it "looks like (x,y)" do
|
56
|
-
expect(subject.to_s).to eq("(40,50)")
|
57
|
-
end
|
58
|
-
|
59
|
-
it "inspects like (Shoes::Point:0x01234567 (x,y))" do
|
60
|
-
expect(subject.inspect).to match(/[(]Shoes::Point:#{shoes_object_id_pattern} [(]40,50[)][)]/)
|
61
|
-
end
|
62
|
-
|
63
|
-
describe "with nil values" do
|
64
|
-
subject { Shoes::Point.new(nil, nil) }
|
65
|
-
|
66
|
-
it "looks like (nil,nil)" do
|
67
|
-
expect(subject.to_s).to eq("(_,_)")
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/spec/shoes/progress_spec.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Progress do
|
4
|
-
include_context "dsl app"
|
5
|
-
let(:input_opts) { { left: left, top: top, width: width, height: height } }
|
6
|
-
|
7
|
-
let(:left) { 10 }
|
8
|
-
let(:top) { 20 }
|
9
|
-
let(:width) { 100 }
|
10
|
-
let(:height) { 200 }
|
11
|
-
|
12
|
-
subject(:progress) { Shoes::Progress.new(app, parent, input_opts, input_block) }
|
13
|
-
|
14
|
-
it { is_expected.to respond_to :fraction }
|
15
|
-
it { is_expected.to respond_to :fraction= }
|
16
|
-
|
17
|
-
it_behaves_like "object with dimensions"
|
18
|
-
|
19
|
-
it_behaves_like "object with style" do
|
20
|
-
let(:subject_without_style) { Shoes::Progress.new(app, parent) }
|
21
|
-
let(:subject_with_style) { Shoes::Progress.new(app, parent, arg_styles) }
|
22
|
-
end
|
23
|
-
|
24
|
-
context "initialize" do
|
25
|
-
let(:input_opts) { { fraction: 50 } }
|
26
|
-
|
27
|
-
it "sets fraction" do
|
28
|
-
expect_any_instance_of(Shoes.configuration.backend::Progress).to receive(:fraction=).with(50)
|
29
|
-
expect(progress).not_to be_nil
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
context "setting fraction" do
|
34
|
-
it "sets on gui" do
|
35
|
-
expect(progress.gui).to receive(:fraction=).with(0.5)
|
36
|
-
progress.fraction = 0.5
|
37
|
-
end
|
38
|
-
|
39
|
-
it "sets on self" do
|
40
|
-
progress.fraction = 0.5
|
41
|
-
expect(progress.fraction).to eq(0.5)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe "relative dimensions from parent" do
|
46
|
-
subject { Shoes::Progress.new(app, parent, relative_opts, input_block) }
|
47
|
-
it_behaves_like "object with relative dimensions"
|
48
|
-
end
|
49
|
-
|
50
|
-
describe "negative dimensions" do
|
51
|
-
subject { Shoes::Progress.new(app, parent, negative_opts, input_block) }
|
52
|
-
it_behaves_like "object with negative dimensions"
|
53
|
-
end
|
54
|
-
end
|
data/spec/shoes/radio_spec.rb
DELETED
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Radio do
|
4
|
-
include_context "dsl app"
|
5
|
-
|
6
|
-
subject(:radio) { Shoes::Radio.new(app, parent, group, input_opts, input_block) }
|
7
|
-
let(:group) { :a_group }
|
8
|
-
|
9
|
-
it_behaves_like "checkable"
|
10
|
-
it_behaves_like "object with state"
|
11
|
-
|
12
|
-
it_behaves_like "object with style" do
|
13
|
-
let(:subject_without_style) { Shoes::Radio.new(app, parent, group) }
|
14
|
-
let(:subject_with_style) { Shoes::Radio.new(app, parent, group, arg_styles) }
|
15
|
-
end
|
16
|
-
|
17
|
-
# only one radio in a group can be checked
|
18
|
-
|
19
|
-
describe "#initialize" do
|
20
|
-
it "sets accessors" do
|
21
|
-
expect(radio.parent).to eq(parent)
|
22
|
-
expect(radio.group).to eq(group)
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#group=" do
|
27
|
-
it "changes the group" do
|
28
|
-
radio.group = "New Group"
|
29
|
-
expect(radio.group).to eq("New Group")
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/spec/shoes/rect_spec.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
shared_examples_for "basic rect" do
|
4
|
-
it "retains app" do
|
5
|
-
expect(rect.app).to eq(app)
|
6
|
-
end
|
7
|
-
|
8
|
-
it "creates gui object" do
|
9
|
-
expect(rect.gui).not_to be_nil
|
10
|
-
end
|
11
|
-
end
|
12
|
-
|
13
|
-
describe Shoes::Rect do
|
14
|
-
include_context "dsl app"
|
15
|
-
|
16
|
-
let(:parent) { app }
|
17
|
-
let(:left) { 44 }
|
18
|
-
let(:top) { 66 }
|
19
|
-
let(:width) { 111 }
|
20
|
-
let(:height) { 333 }
|
21
|
-
subject(:rect) { Shoes::Rect.new(app, parent, left, top, width, height) }
|
22
|
-
|
23
|
-
describe '#style' do
|
24
|
-
it 'restyles handed in fill colors (even the weird ones)' do
|
25
|
-
subject.style fill: 'fff'
|
26
|
-
expect(subject.style[:fill]).to eq Shoes::Color.new 255, 255, 255
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it_behaves_like "basic rect"
|
31
|
-
it_behaves_like "object with style" do
|
32
|
-
let(:subject_without_style) { Shoes::Rect.new(app, parent, left, top, width, height) }
|
33
|
-
let(:subject_with_style) { Shoes::Rect.new(app, parent, left, top, width, height, arg_styles) }
|
34
|
-
end
|
35
|
-
it_behaves_like "object with dimensions"
|
36
|
-
it_behaves_like "movable object"
|
37
|
-
it_behaves_like "left, top as center"
|
38
|
-
it_behaves_like 'object with parent'
|
39
|
-
end
|
@@ -1,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RenamedDelegate do
|
4
|
-
|
5
|
-
class ToDelegate
|
6
|
-
def method_key
|
7
|
-
end
|
8
|
-
|
9
|
-
def abcd
|
10
|
-
end
|
11
|
-
|
12
|
-
def key
|
13
|
-
end
|
14
|
-
|
15
|
-
def bla_key
|
16
|
-
end
|
17
|
-
|
18
|
-
def method_something
|
19
|
-
end
|
20
|
-
|
21
|
-
def key_something
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class TestClass
|
26
|
-
extend RenamedDelegate
|
27
|
-
|
28
|
-
attr_reader :delegate
|
29
|
-
|
30
|
-
def initialize(delegate)
|
31
|
-
@delegate = delegate
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
TestClass.renamed_delegate_to :delegate,
|
36
|
-
ToDelegate.public_instance_methods(false),
|
37
|
-
{'key' => 'shoes', 'something' => 'awesome'}
|
38
|
-
|
39
|
-
let(:delegate) {double('delegate').as_null_object}
|
40
|
-
subject {TestClass.new delegate}
|
41
|
-
|
42
|
-
def test_renaming(new_name, old_name)
|
43
|
-
subject.public_send new_name
|
44
|
-
expect(delegate).to have_received old_name
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'delegates method_shoes to method_key' do
|
48
|
-
test_renaming :method_shoes, :method_key
|
49
|
-
end
|
50
|
-
|
51
|
-
it 'delegates shoes to key' do
|
52
|
-
test_renaming :shoes, :key
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'delegates bla_shoes to bla_key' do
|
56
|
-
test_renaming :bla_shoes, :bla_key
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'delegates method_awesome to method_something' do
|
60
|
-
test_renaming :method_awesome, :method_something
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'also applies multiple renamings' do
|
64
|
-
test_renaming :shoes_awesome, :key_something
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'does not define a method for methods without renamings' do
|
68
|
-
expect(subject).not_to respond_to :abcd
|
69
|
-
end
|
70
|
-
end
|
data/spec/shoes/shape_spec.rb
DELETED
@@ -1,95 +0,0 @@
|
|
1
|
-
require 'shoes/spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Shape do
|
4
|
-
include_context "dsl app"
|
5
|
-
|
6
|
-
let(:style) { Hash.new }
|
7
|
-
let(:draw) { Proc.new { } }
|
8
|
-
|
9
|
-
subject { Shoes::Shape.new app, parent, style, draw }
|
10
|
-
|
11
|
-
it_behaves_like "object with style" do
|
12
|
-
let(:subject_without_style) { Shoes::Shape.new(app, parent) }
|
13
|
-
let(:subject_with_style) { Shoes::Shape.new(app, parent, arg_styles) }
|
14
|
-
end
|
15
|
-
|
16
|
-
it_behaves_like "movable object"
|
17
|
-
|
18
|
-
describe "octagon" do
|
19
|
-
let(:draw) {
|
20
|
-
Proc.new {
|
21
|
-
xs = [200, 300, 370, 370, 300, 200, 130, 130]
|
22
|
-
ys = [100, 100, 170, 270, 340, 340, 270, 170]
|
23
|
-
move_to xs.first, ys.first
|
24
|
-
xs.zip(ys).each do |x, y|
|
25
|
-
line_to(x, y)
|
26
|
-
end
|
27
|
-
line_to xs.first, ys.first
|
28
|
-
}
|
29
|
-
}
|
30
|
-
|
31
|
-
its(:left) { should be_nil }
|
32
|
-
its(:top) { should be_nil }
|
33
|
-
its(:left_bound) { should eq(130) }
|
34
|
-
its(:top_bound) { should eq(100) }
|
35
|
-
its(:right_bound) { should eq(370) }
|
36
|
-
its(:bottom_bound) { should eq(340) }
|
37
|
-
its(:width) { should eq(app.width) }
|
38
|
-
its(:height) { should eq app.height }
|
39
|
-
|
40
|
-
it_behaves_like "movable object"
|
41
|
-
|
42
|
-
describe "when created with left and top values" do
|
43
|
-
let(:style) { {left: 10, top: 100} }
|
44
|
-
|
45
|
-
its(:left) { should eq(10) }
|
46
|
-
its(:top) { should eq(100) }
|
47
|
-
its(:left_bound) { should eq(130) }
|
48
|
-
its(:top_bound) { should eq(100) }
|
49
|
-
its(:right_bound) { should eq(370) }
|
50
|
-
its(:bottom_bound) { should eq(340) }
|
51
|
-
its(:width) { should eq(app.width) }
|
52
|
-
its(:height) { should eq app.height }
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
describe "curve" do
|
57
|
-
let(:draw) {
|
58
|
-
Proc.new {
|
59
|
-
move_to 10, 10
|
60
|
-
curve_to 20, 30, 100, 200, 50, 50
|
61
|
-
}
|
62
|
-
}
|
63
|
-
|
64
|
-
its(:left_bound) { should eq(10) }
|
65
|
-
its(:top_bound) { should eq(10) }
|
66
|
-
its(:right_bound) { should eq(100) }
|
67
|
-
its(:bottom_bound) { should eq(200) }
|
68
|
-
its(:width) { should eq(app.width) }
|
69
|
-
its(:height) { should eq app.height }
|
70
|
-
|
71
|
-
it_behaves_like "movable object"
|
72
|
-
end
|
73
|
-
|
74
|
-
describe "arc" do
|
75
|
-
let(:draw) {
|
76
|
-
Proc.new {
|
77
|
-
arc 10, 10, 100, 100, Shoes::PI, Shoes::TWO_PI
|
78
|
-
}
|
79
|
-
}
|
80
|
-
|
81
|
-
it_behaves_like "movable object"
|
82
|
-
end
|
83
|
-
|
84
|
-
describe "accesses app" do
|
85
|
-
let(:draw) {
|
86
|
-
Proc.new {
|
87
|
-
background Shoes::COLORS[:red]
|
88
|
-
stroke Shoes::COLORS[:blue]
|
89
|
-
rect 10, 10, 100, 100
|
90
|
-
}
|
91
|
-
}
|
92
|
-
|
93
|
-
it_behaves_like "movable object"
|
94
|
-
end
|
95
|
-
end
|