shoes-core 4.0.0.pre7 → 4.0.0.pre8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/shoes/arc.rb +10 -13
- data/lib/shoes/arrow.rb +1 -11
- data/lib/shoes/background.rb +0 -3
- data/lib/shoes/border.rb +0 -3
- data/lib/shoes/button.rb +4 -1
- data/lib/shoes/check_button.rb +0 -1
- data/lib/shoes/common/art_element.rb +21 -0
- data/lib/shoes/common/background_element.rb +10 -0
- data/lib/shoes/common/clickable.rb +2 -0
- data/lib/shoes/common/rotate.rb +1 -2
- data/lib/shoes/common/ui_element.rb +10 -1
- data/lib/shoes/core/version.rb +1 -1
- data/lib/shoes/download.rb +47 -29
- data/lib/shoes/dsl.rb +99 -40
- data/lib/shoes/font.rb +0 -4
- data/lib/shoes/http_request.rb +91 -0
- data/lib/shoes/image.rb +0 -1
- data/lib/shoes/input_box.rb +0 -1
- data/lib/shoes/internal_app.rb +1 -1
- data/lib/shoes/line.rb +25 -11
- data/lib/shoes/link.rb +10 -4
- data/lib/shoes/list_box.rb +0 -1
- data/lib/shoes/mock/app.rb +6 -0
- data/lib/shoes/mock/clickable.rb +3 -0
- data/lib/shoes/mock/font.rb +0 -4
- data/lib/shoes/oval.rb +3 -13
- data/lib/shoes/progress.rb +0 -1
- data/lib/shoes/rect.rb +1 -11
- data/lib/shoes/shape.rb +16 -8
- data/lib/shoes/slot.rb +2 -1
- data/lib/shoes/star.rb +8 -11
- data/lib/shoes/text_block.rb +0 -1
- data/lib/shoes/ui/picker.rb +29 -8
- data/lib/shoes/version.rb +1 -1
- metadata +8 -231
- data/Guardfile +0 -5
- data/Rakefile +0 -1
- data/bin/shoes-stub +0 -62
- data/ext/install/Rakefile +0 -39
- data/ext/install/shoes.bat +0 -17
- data/lib/rubygems_plugin.rb +0 -24
- data/shoes-core.gemspec +0 -22
- data/spec/shoes/animation_spec.rb +0 -71
- data/spec/shoes/app_spec.rb +0 -454
- data/spec/shoes/arc_spec.rb +0 -52
- data/spec/shoes/arrow_spec.rb +0 -28
- data/spec/shoes/background_spec.rb +0 -47
- data/spec/shoes/border_spec.rb +0 -46
- data/spec/shoes/builtin_methods_spec.rb +0 -122
- data/spec/shoes/button_spec.rb +0 -55
- data/spec/shoes/check_spec.rb +0 -36
- data/spec/shoes/color_spec.rb +0 -429
- data/spec/shoes/common/attachable_spec.rb +0 -32
- data/spec/shoes/common/inspect_spec.rb +0 -26
- data/spec/shoes/common/remove_spec.rb +0 -37
- data/spec/shoes/common/rotate_spec.rb +0 -13
- data/spec/shoes/common/style_normalizer_spec.rb +0 -28
- data/spec/shoes/common/style_spec.rb +0 -197
- data/spec/shoes/common/translate_spec.rb +0 -27
- data/spec/shoes/configuration_spec.rb +0 -51
- data/spec/shoes/constants_spec.rb +0 -39
- data/spec/shoes/dialog_spec.rb +0 -169
- data/spec/shoes/dimension_spec.rb +0 -451
- data/spec/shoes/dimensions_spec.rb +0 -868
- data/spec/shoes/download_spec.rb +0 -198
- data/spec/shoes/flow_spec.rb +0 -132
- data/spec/shoes/font_spec.rb +0 -36
- data/spec/shoes/framework_learning_spec.rb +0 -31
- data/spec/shoes/gradient_spec.rb +0 -31
- data/spec/shoes/helpers/fake_absolute_element.rb +0 -31
- data/spec/shoes/helpers/fake_element.rb +0 -25
- data/spec/shoes/helpers/inspect_helpers.rb +0 -5
- data/spec/shoes/helpers/sample17_helper.rb +0 -65
- data/spec/shoes/image_spec.rb +0 -69
- data/spec/shoes/images/shoe.jpg +0 -0
- data/spec/shoes/input_box_spec.rb +0 -80
- data/spec/shoes/integration_spec.rb +0 -19
- data/spec/shoes/internal_app_spec.rb +0 -148
- data/spec/shoes/keypress_spec.rb +0 -11
- data/spec/shoes/keyrelease_spec.rb +0 -11
- data/spec/shoes/line_spec.rb +0 -120
- data/spec/shoes/link_spec.rb +0 -149
- data/spec/shoes/list_box_spec.rb +0 -87
- data/spec/shoes/logger/ruby_spec.rb +0 -8
- data/spec/shoes/logger_spec.rb +0 -45
- data/spec/shoes/oval_spec.rb +0 -25
- data/spec/shoes/packager_spec.rb +0 -25
- data/spec/shoes/point_spec.rb +0 -99
- data/spec/shoes/progress_spec.rb +0 -54
- data/spec/shoes/radio_spec.rb +0 -32
- data/spec/shoes/rect_spec.rb +0 -40
- data/spec/shoes/renamed_delegate_spec.rb +0 -69
- data/spec/shoes/shape_spec.rb +0 -119
- data/spec/shoes/shared_examples/button.rb +0 -6
- data/spec/shoes/shared_examples/changeable.rb +0 -26
- data/spec/shoes/shared_examples/clickable.rb +0 -5
- data/spec/shoes/shared_examples/common_methods.rb +0 -35
- data/spec/shoes/shared_examples/dimensions.rb +0 -32
- data/spec/shoes/shared_examples/dsl.rb +0 -44
- data/spec/shoes/shared_examples/dsl/animate.rb +0 -29
- data/spec/shoes/shared_examples/dsl/arc.rb +0 -45
- data/spec/shoes/shared_examples/dsl/background.rb +0 -26
- data/spec/shoes/shared_examples/dsl/border.rb +0 -10
- data/spec/shoes/shared_examples/dsl/button.rb +0 -5
- data/spec/shoes/shared_examples/dsl/cap.rb +0 -6
- data/spec/shoes/shared_examples/dsl/check.rb +0 -11
- data/spec/shoes/shared_examples/dsl/edit_box.rb +0 -8
- data/spec/shoes/shared_examples/dsl/edit_line.rb +0 -8
- data/spec/shoes/shared_examples/dsl/editable_element.rb +0 -29
- data/spec/shoes/shared_examples/dsl/fill.rb +0 -27
- data/spec/shoes/shared_examples/dsl/flow.rb +0 -15
- data/spec/shoes/shared_examples/dsl/gradient.rb +0 -62
- data/spec/shoes/shared_examples/dsl/image.rb +0 -21
- data/spec/shoes/shared_examples/dsl/line.rb +0 -9
- data/spec/shoes/shared_examples/dsl/nofill.rb +0 -6
- data/spec/shoes/shared_examples/dsl/nostroke.rb +0 -6
- data/spec/shoes/shared_examples/dsl/oval.rb +0 -88
- data/spec/shoes/shared_examples/dsl/pattern.rb +0 -34
- data/spec/shoes/shared_examples/dsl/progress.rb +0 -7
- data/spec/shoes/shared_examples/dsl/rect.rb +0 -92
- data/spec/shoes/shared_examples/dsl/rgb.rb +0 -28
- data/spec/shoes/shared_examples/dsl/shape.rb +0 -61
- data/spec/shoes/shared_examples/dsl/star.rb +0 -110
- data/spec/shoes/shared_examples/dsl/stroke.rb +0 -30
- data/spec/shoes/shared_examples/dsl/strokewidth.rb +0 -19
- data/spec/shoes/shared_examples/dsl/style.rb +0 -32
- data/spec/shoes/shared_examples/dsl/text_elements.rb +0 -84
- data/spec/shoes/shared_examples/dsl/video.rb +0 -5
- data/spec/shoes/shared_examples/dsl_app_context.rb +0 -11
- data/spec/shoes/shared_examples/hover.rb +0 -78
- data/spec/shoes/shared_examples/parent.rb +0 -6
- data/spec/shoes/shared_examples/scroll.rb +0 -41
- data/spec/shoes/shared_examples/shared_element_method.rb +0 -60
- data/spec/shoes/shared_examples/slot.rb +0 -441
- data/spec/shoes/shared_examples/state.rb +0 -26
- data/spec/shoes/shared_examples/style.rb +0 -77
- data/spec/shoes/slot_spec.rb +0 -176
- data/spec/shoes/sound_spec.rb +0 -16
- data/spec/shoes/span_spec.rb +0 -112
- data/spec/shoes/spec_helper.rb +0 -24
- data/spec/shoes/stack_spec.rb +0 -79
- data/spec/shoes/star_spec.rb +0 -49
- data/spec/shoes/text_block_dimensions_spec.rb +0 -77
- data/spec/shoes/text_block_spec.rb +0 -314
- data/spec/shoes/text_spec.rb +0 -22
- data/spec/shoes/ui/picker_spec.rb +0 -69
- data/spec/shoes/url_spec.rb +0 -67
- data/spec/shoes/widget_spec.rb +0 -78
- data/spec/shoes_spec.rb +0 -41
- data/spec/spec_helper.rb +0 -27
data/spec/shoes/point_spec.rb
DELETED
@@ -1,99 +0,0 @@
|
|
1
|
-
require '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 "#+" do
|
33
|
-
it "performs element-wise addition with other point" do
|
34
|
-
expect(subject + Shoes::Point.new(40, 50)).to eq(Shoes::Point.new(80, 100))
|
35
|
-
end
|
36
|
-
|
37
|
-
it "performs element-wise addition with an array" do
|
38
|
-
expect(subject + [40, 50]).to eq(Shoes::Point.new(80, 100))
|
39
|
-
end
|
40
|
-
|
41
|
-
it "doesn't perform addition when dimensions don't match" do
|
42
|
-
expect { subject + [40, 50, 60] }.to raise_error(ArgumentError)
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
describe "#-" do
|
47
|
-
it "performs element-wise subtraction with other point" do
|
48
|
-
expect(subject - Shoes::Point.new(40, 50)).to eq(Shoes::Point.new(0, 0))
|
49
|
-
end
|
50
|
-
|
51
|
-
it "performs element-wise subtraction with an array" do
|
52
|
-
expect(subject - [40, 50]).to eq(Shoes::Point.new(0, 0))
|
53
|
-
end
|
54
|
-
|
55
|
-
it "doesn't perform subtraction when dimensions don't match" do
|
56
|
-
expect { subject - [40, 50, 60] }.to raise_error(ArgumentError)
|
57
|
-
end
|
58
|
-
end
|
59
|
-
|
60
|
-
describe "#to" do
|
61
|
-
it "positive" do
|
62
|
-
expect(subject.to(24, 166)).to eq(Shoes::Point.new(64, 216))
|
63
|
-
end
|
64
|
-
|
65
|
-
it "negative" do
|
66
|
-
expect(subject.to(-24, -166)).to eq(Shoes::Point.new(16, -116))
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
it "calculates width of rectangle created with other point" do
|
71
|
-
expect(subject.width(other_point)).to eq(30)
|
72
|
-
expect(other_point.width(subject)).to eq(30)
|
73
|
-
end
|
74
|
-
|
75
|
-
it "calculates height of rectangle created with other point" do
|
76
|
-
expect(subject.height(other_point)).to eq(10)
|
77
|
-
expect(other_point.height(subject)).to eq(10)
|
78
|
-
end
|
79
|
-
|
80
|
-
describe "converting to string" do
|
81
|
-
include InspectHelpers
|
82
|
-
|
83
|
-
it "looks like (x,y)" do
|
84
|
-
expect(subject.to_s).to eq("(40,50)")
|
85
|
-
end
|
86
|
-
|
87
|
-
it "inspects like (Shoes::Point:0x01234567 (x,y))" do
|
88
|
-
expect(subject.inspect).to match(/[(]Shoes::Point:#{shoes_object_id_pattern} [(]40,50[)][)]/)
|
89
|
-
end
|
90
|
-
|
91
|
-
describe "with nil values" do
|
92
|
-
subject { Shoes::Point.new(nil, nil) }
|
93
|
-
|
94
|
-
it "looks like (nil,nil)" do
|
95
|
-
expect(subject.to_s).to eq("(_,_)")
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
data/spec/shoes/progress_spec.rb
DELETED
@@ -1,54 +0,0 @@
|
|
1
|
-
require '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 '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,40 +0,0 @@
|
|
1
|
-
require '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
|
-
it_behaves_like "object with hover"
|
40
|
-
end
|
@@ -1,69 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe RenamedDelegate do
|
4
|
-
class ToDelegate
|
5
|
-
def method_key
|
6
|
-
end
|
7
|
-
|
8
|
-
def abcd
|
9
|
-
end
|
10
|
-
|
11
|
-
def key
|
12
|
-
end
|
13
|
-
|
14
|
-
def bla_key
|
15
|
-
end
|
16
|
-
|
17
|
-
def method_something
|
18
|
-
end
|
19
|
-
|
20
|
-
def key_something
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
class TestClass
|
25
|
-
extend RenamedDelegate
|
26
|
-
|
27
|
-
attr_reader :delegate
|
28
|
-
|
29
|
-
def initialize(delegate)
|
30
|
-
@delegate = delegate
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
TestClass.renamed_delegate_to :delegate,
|
35
|
-
ToDelegate.public_instance_methods(false),
|
36
|
-
'key' => 'shoes', 'something' => 'awesome'
|
37
|
-
|
38
|
-
let(:delegate) { double('delegate').as_null_object }
|
39
|
-
subject { TestClass.new delegate }
|
40
|
-
|
41
|
-
def test_renaming(new_name, old_name)
|
42
|
-
subject.public_send new_name
|
43
|
-
expect(delegate).to have_received old_name
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'delegates method_shoes to method_key' do
|
47
|
-
test_renaming :method_shoes, :method_key
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'delegates shoes to key' do
|
51
|
-
test_renaming :shoes, :key
|
52
|
-
end
|
53
|
-
|
54
|
-
it 'delegates bla_shoes to bla_key' do
|
55
|
-
test_renaming :bla_shoes, :bla_key
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'delegates method_awesome to method_something' do
|
59
|
-
test_renaming :method_awesome, :method_something
|
60
|
-
end
|
61
|
-
|
62
|
-
it 'also applies multiple renamings' do
|
63
|
-
test_renaming :shoes_awesome, :key_something
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'does not define a method for methods without renamings' do
|
67
|
-
expect(subject).not_to respond_to :abcd
|
68
|
-
end
|
69
|
-
end
|
data/spec/shoes/shape_spec.rb
DELETED
@@ -1,119 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Shoes::Shape do
|
4
|
-
include_context "dsl app"
|
5
|
-
|
6
|
-
let(:left) { 0 }
|
7
|
-
let(:top) { 0 }
|
8
|
-
let(:style) { {translate_left: 0, translate_top: 0, left: left, top: top} }
|
9
|
-
let(:draw) { proc {} }
|
10
|
-
|
11
|
-
subject { Shoes::Shape.new app, parent, style, draw }
|
12
|
-
|
13
|
-
it_behaves_like "object with style" do
|
14
|
-
let(:subject_without_style) { Shoes::Shape.new(app, parent) }
|
15
|
-
let(:subject_with_style) { Shoes::Shape.new(app, parent, arg_styles) }
|
16
|
-
end
|
17
|
-
|
18
|
-
it_behaves_like "movable object"
|
19
|
-
it_behaves_like "clickable object"
|
20
|
-
|
21
|
-
describe "octagon" do
|
22
|
-
let(:draw) do
|
23
|
-
proc do
|
24
|
-
xs = [200, 300, 370, 370, 300, 200, 130, 130]
|
25
|
-
ys = [100, 100, 170, 270, 340, 340, 270, 170]
|
26
|
-
move_to xs.first, ys.first
|
27
|
-
xs.zip(ys).each do |x, y|
|
28
|
-
line_to(x, y)
|
29
|
-
end
|
30
|
-
line_to xs.first, ys.first
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
its(:left) { should eq(0) }
|
35
|
-
its(:top) { should eq(0) }
|
36
|
-
its(:left_bound) { should eq(130) }
|
37
|
-
its(:top_bound) { should eq(100) }
|
38
|
-
its(:right_bound) { should eq(370) }
|
39
|
-
its(:bottom_bound) { should eq(340) }
|
40
|
-
its(:width) { should eq(app.width) }
|
41
|
-
its(:height) { should eq app.height }
|
42
|
-
|
43
|
-
it_behaves_like "movable object"
|
44
|
-
|
45
|
-
describe "when created without left and top values" do
|
46
|
-
let(:left) { nil }
|
47
|
-
let(:top) { nil }
|
48
|
-
|
49
|
-
its(:left) { should eq(nil) }
|
50
|
-
its(:top) { should eq(nil) }
|
51
|
-
end
|
52
|
-
|
53
|
-
describe "when created with left and top values" do
|
54
|
-
let(:left) { 10 }
|
55
|
-
let(:top) { 100 }
|
56
|
-
|
57
|
-
its(:left) { should eq(10) }
|
58
|
-
its(:top) { should eq(100) }
|
59
|
-
its(:left_bound) { should eq(130) }
|
60
|
-
its(:top_bound) { should eq(100) }
|
61
|
-
its(:right_bound) { should eq(370) }
|
62
|
-
its(:bottom_bound) { should eq(340) }
|
63
|
-
its(:width) { should eq(app.width) }
|
64
|
-
its(:height) { should eq app.height }
|
65
|
-
end
|
66
|
-
end
|
67
|
-
|
68
|
-
describe "curve" do
|
69
|
-
let(:draw) do
|
70
|
-
proc do
|
71
|
-
move_to 10, 10
|
72
|
-
curve_to 20, 30, 100, 200, 50, 50
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
its(:left_bound) { should eq(10) }
|
77
|
-
its(:top_bound) { should eq(10) }
|
78
|
-
its(:right_bound) { should eq(100) }
|
79
|
-
its(:bottom_bound) { should eq(200) }
|
80
|
-
its(:width) { should eq(app.width) }
|
81
|
-
its(:height) { should eq app.height }
|
82
|
-
|
83
|
-
it_behaves_like "movable object"
|
84
|
-
end
|
85
|
-
|
86
|
-
describe "arc" do
|
87
|
-
let(:draw) do
|
88
|
-
proc do
|
89
|
-
arc_to 10, 10, 100, 100, Shoes::PI, Shoes::TWO_PI
|
90
|
-
end
|
91
|
-
end
|
92
|
-
|
93
|
-
it_behaves_like "movable object"
|
94
|
-
end
|
95
|
-
|
96
|
-
describe "in_bounds?" do
|
97
|
-
let(:draw) { proc { line_to 100, 100 } }
|
98
|
-
|
99
|
-
it "is in bounds" do
|
100
|
-
expect(subject.in_bounds?(10, 10)).to be true
|
101
|
-
end
|
102
|
-
|
103
|
-
it "is out of bounds" do
|
104
|
-
expect(subject.in_bounds?(101, 101)).to be false
|
105
|
-
end
|
106
|
-
end
|
107
|
-
|
108
|
-
describe "accesses app" do
|
109
|
-
let(:draw) do
|
110
|
-
proc do
|
111
|
-
background Shoes::COLORS[:red]
|
112
|
-
stroke Shoes::COLORS[:blue]
|
113
|
-
rect 10, 10, 100, 100
|
114
|
-
end
|
115
|
-
end
|
116
|
-
|
117
|
-
it_behaves_like "movable object"
|
118
|
-
end
|
119
|
-
end
|
@@ -1,26 +0,0 @@
|
|
1
|
-
shared_examples "an element that can respond to change" do
|
2
|
-
describe "when passing a block to the constructor" do
|
3
|
-
it "should notify the block of change events" do
|
4
|
-
expect(input_block).to receive(:call).with(subject)
|
5
|
-
subject.call_change_listeners
|
6
|
-
end
|
7
|
-
end
|
8
|
-
|
9
|
-
describe "when setting up a callback with #change" do
|
10
|
-
it "should notify the callback of change events" do
|
11
|
-
called = false
|
12
|
-
subject.change do
|
13
|
-
called = true
|
14
|
-
end
|
15
|
-
subject.call_change_listeners
|
16
|
-
expect(called).to be_truthy
|
17
|
-
end
|
18
|
-
|
19
|
-
it "should pass the element itself to the callback" do
|
20
|
-
subject.change do |element|
|
21
|
-
expect(element).to eq(subject)
|
22
|
-
end
|
23
|
-
subject.call_change_listeners
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|