shoes-core 4.0.0.pre4 → 4.0.0.pre5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Guardfile +5 -0
- data/bin/shoes +1 -1
- data/bin/shoes-stub +1 -1
- data/ext/install/Rakefile +15 -5
- data/ext/install/shoes.bat +1 -1
- data/lib/shoes/animation.rb +2 -2
- data/lib/shoes/arc.rb +1 -0
- data/lib/shoes/builtin_methods.rb +5 -18
- data/lib/shoes/button.rb +1 -5
- data/lib/shoes/check_button.rb +1 -5
- data/lib/shoes/color.rb +5 -274
- data/lib/shoes/color/dsl.rb +166 -0
- data/lib/shoes/color/dsl_helpers.rb +84 -0
- data/lib/shoes/color/hex_converter.rb +32 -0
- data/lib/shoes/common/background_element.rb +5 -0
- data/lib/shoes/common/hover.rb +87 -0
- data/lib/shoes/common/initialization.rb +21 -8
- data/lib/shoes/common/remove.rb +2 -0
- data/lib/shoes/common/state.rb +17 -3
- data/lib/shoes/common/style.rb +8 -0
- data/lib/shoes/configuration.rb +18 -15
- data/lib/shoes/core/version.rb +1 -1
- data/lib/shoes/dimension.rb +6 -19
- data/lib/shoes/dimensions.rb +8 -0
- data/lib/shoes/download.rb +5 -3
- data/lib/shoes/dsl.rb +3 -3
- data/lib/shoes/image.rb +1 -0
- data/lib/shoes/image_pattern.rb +1 -1
- data/lib/shoes/input_box.rb +2 -5
- data/lib/shoes/internal_app.rb +13 -2
- data/lib/shoes/line.rb +1 -0
- data/lib/shoes/link.rb +8 -0
- data/lib/shoes/list_box.rb +2 -5
- data/lib/shoes/mock/check.rb +3 -0
- data/lib/shoes/mock/image.rb +6 -0
- data/lib/shoes/mock/progress.rb +6 -0
- data/lib/shoes/mock/radio.rb +3 -0
- data/lib/shoes/mock/sound.rb +1 -1
- data/lib/shoes/oval.rb +1 -0
- data/lib/shoes/packager.rb +1 -1
- data/lib/shoes/rect.rb +1 -0
- data/lib/shoes/shape.rb +4 -0
- data/lib/shoes/slot.rb +75 -38
- data/lib/shoes/slot_contents.rb +4 -0
- data/lib/shoes/sound.rb +3 -2
- data/lib/shoes/star.rb +1 -0
- data/lib/shoes/text_block.rb +18 -2
- data/lib/shoes/text_block_dimensions.rb +19 -3
- data/lib/shoes/timer.rb +2 -2
- data/lib/shoes/ui/picker.rb +4 -4
- data/lib/shoes/version.rb +1 -1
- data/shoes-core.gemspec +1 -1
- data/spec/shoes/animation_spec.rb +2 -2
- data/spec/shoes/app_spec.rb +6 -17
- data/spec/shoes/arc_spec.rb +2 -1
- data/spec/shoes/background_spec.rb +2 -2
- data/spec/shoes/border_spec.rb +2 -2
- data/spec/shoes/builtin_methods_spec.rb +68 -56
- data/spec/shoes/button_spec.rb +3 -3
- data/spec/shoes/check_spec.rb +3 -2
- data/spec/shoes/color_spec.rb +9 -3
- data/spec/shoes/common/remove_spec.rb +0 -1
- data/spec/shoes/common/rotate_spec.rb +13 -0
- data/spec/shoes/common/style_spec.rb +12 -3
- data/spec/shoes/configuration_spec.rb +18 -3
- data/spec/shoes/constants_spec.rb +1 -0
- data/spec/shoes/dialog_spec.rb +1 -3
- data/spec/shoes/dimension_spec.rb +33 -24
- data/spec/shoes/dimensions_spec.rb +21 -31
- data/spec/shoes/download_spec.rb +14 -3
- data/spec/shoes/flow_spec.rb +6 -7
- data/spec/shoes/font_spec.rb +2 -3
- data/spec/shoes/framework_learning_spec.rb +1 -2
- data/spec/shoes/gradient_spec.rb +1 -2
- data/spec/shoes/helpers/fake_absolute_element.rb +30 -0
- data/spec/shoes/helpers/sample17_helper.rb +0 -1
- data/spec/shoes/image_spec.rb +2 -1
- data/spec/shoes/input_box_spec.rb +2 -2
- data/spec/shoes/integration_spec.rb +0 -1
- data/spec/shoes/internal_app_spec.rb +4 -5
- data/spec/shoes/keypress_spec.rb +1 -1
- data/spec/shoes/keyrelease_spec.rb +1 -2
- data/spec/shoes/line_spec.rb +3 -2
- data/spec/shoes/link_spec.rb +26 -6
- data/spec/shoes/list_box_spec.rb +2 -2
- data/spec/shoes/oval_spec.rb +2 -1
- data/spec/shoes/packager_spec.rb +1 -1
- data/spec/shoes/point_spec.rb +1 -1
- data/spec/shoes/progress_spec.rb +1 -1
- data/spec/shoes/radio_spec.rb +1 -1
- data/spec/shoes/rect_spec.rb +2 -1
- data/spec/shoes/renamed_delegate_spec.rb +0 -1
- data/spec/shoes/shape_spec.rb +1 -1
- data/spec/shoes/shared_examples/common_methods.rb +1 -1
- data/spec/shoes/shared_examples/dsl/animate.rb +1 -1
- data/spec/shoes/shared_examples/dsl/background.rb +2 -2
- data/spec/shoes/shared_examples/dsl/rgb.rb +4 -2
- data/spec/shoes/shared_examples/dsl/star.rb +0 -1
- data/spec/shoes/shared_examples/dsl/style.rb +1 -1
- data/spec/shoes/shared_examples/dsl/text_elements.rb +2 -2
- data/spec/shoes/shared_examples/dsl/video.rb +1 -1
- data/spec/shoes/shared_examples/dsl_app_context.rb +4 -1
- data/spec/shoes/shared_examples/hover.rb +78 -0
- data/spec/shoes/shared_examples/slot.rb +34 -4
- data/spec/shoes/shared_examples/state.rb +9 -2
- data/spec/shoes/shared_examples/style.rb +0 -5
- data/spec/shoes/slot_spec.rb +11 -38
- data/spec/shoes/sound_spec.rb +3 -2
- data/spec/shoes/span_spec.rb +2 -2
- data/spec/shoes/spec_helper.rb +1 -1
- data/spec/shoes/stack_spec.rb +6 -6
- data/spec/shoes/star_spec.rb +2 -1
- data/spec/shoes/text_block_dimensions_spec.rb +3 -4
- data/spec/shoes/text_block_spec.rb +16 -11
- data/spec/shoes/ui/picker_spec.rb +5 -6
- data/spec/shoes/url_spec.rb +1 -2
- data/spec/shoes/widget_spec.rb +11 -3
- data/spec/shoes_spec.rb +1 -4
- data/spec/spec_helper.rb +2 -1
- metadata +16 -9
- data/bin/shoes-guard +0 -8
- data/lib/shoes/link_hover.rb +0 -5
- data/spec/shoes/shared_examples/hover_leave.rb +0 -11
@@ -1,5 +1,4 @@
|
|
1
1
|
shared_examples_for "object with style" do
|
2
|
-
|
3
2
|
def uses_app_default?(key)
|
4
3
|
if defined? self.class::STYLES
|
5
4
|
subject.style[key] && !subject.class::STYLES[key]
|
@@ -9,7 +8,6 @@ shared_examples_for "object with style" do
|
|
9
8
|
end
|
10
9
|
|
11
10
|
describe 'using app-level styles' do
|
12
|
-
|
13
11
|
it 'initially uses app defaults' do
|
14
12
|
app.style.each do |key, value|
|
15
13
|
expect(subject.style[key]).to eq(value) if uses_app_default? key
|
@@ -37,7 +35,6 @@ shared_examples_for "object with style" do
|
|
37
35
|
end
|
38
36
|
|
39
37
|
describe 'using the style method' do
|
40
|
-
|
41
38
|
it "merges new styles" do
|
42
39
|
old_style = subject.style
|
43
40
|
subject.style(left: 100, top: 50)
|
@@ -65,7 +62,6 @@ shared_examples_for "object with style" do
|
|
65
62
|
end
|
66
63
|
|
67
64
|
describe 'using setters and getters' do
|
68
|
-
|
69
65
|
it 'has a style setter for all styles' do
|
70
66
|
subject.supported_styles.each do |style|
|
71
67
|
expect(subject).to respond_to("#{style}=".to_sym)
|
@@ -78,5 +74,4 @@ shared_examples_for "object with style" do
|
|
78
74
|
end
|
79
75
|
end
|
80
76
|
end
|
81
|
-
|
82
77
|
end
|
data/spec/shoes/slot_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Slot do
|
4
4
|
include_context "dsl app"
|
@@ -11,7 +11,16 @@ describe Shoes::Slot do
|
|
11
11
|
let(:input_opts) { {left: left, top: top, width: width, height: height} }
|
12
12
|
subject(:slot) { Shoes::Slot.new(app, parent, input_opts) }
|
13
13
|
|
14
|
+
before do
|
15
|
+
# In production this is filled in by Stack and Flow, but we don't want to
|
16
|
+
# trip it in our tests against Slot directly.
|
17
|
+
allow(slot).to receive(:position_element) do |element, current_position|
|
18
|
+
slot.send(:move_to_next_line, element, current_position)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
14
22
|
it_behaves_like "object with dimensions"
|
23
|
+
it_behaves_like "object with hover"
|
15
24
|
|
16
25
|
it_behaves_like "object with style" do
|
17
26
|
let(:subject_without_style) { Shoes::Slot.new(app, parent) }
|
@@ -29,9 +38,8 @@ describe Shoes::Slot do
|
|
29
38
|
end
|
30
39
|
|
31
40
|
describe '#clear' do
|
32
|
-
|
33
41
|
def add_text_block
|
34
|
-
Shoes::
|
42
|
+
Shoes::Para.new app, slot, ['text']
|
35
43
|
end
|
36
44
|
|
37
45
|
before :each do
|
@@ -61,7 +69,6 @@ describe Shoes::Slot do
|
|
61
69
|
expect(subject.contents.size).to eq 1
|
62
70
|
end
|
63
71
|
end
|
64
|
-
|
65
72
|
end
|
66
73
|
|
67
74
|
describe '#remove_child' do
|
@@ -94,40 +101,6 @@ describe Shoes::Slot do
|
|
94
101
|
end
|
95
102
|
end
|
96
103
|
|
97
|
-
describe "hover" do
|
98
|
-
let(:callable) { double("block", call: nil) }
|
99
|
-
let(:block) { Proc.new { callable.call } }
|
100
|
-
|
101
|
-
it "doesn't need hover proc to be called" do
|
102
|
-
expect(callable).to_not receive(:call)
|
103
|
-
subject.mouse_hovered
|
104
|
-
end
|
105
|
-
|
106
|
-
it "calls block on mouse_hovered" do
|
107
|
-
expect(callable).to receive(:call)
|
108
|
-
|
109
|
-
subject.hover(block)
|
110
|
-
subject.mouse_hovered
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe "leave" do
|
115
|
-
let(:callable) { double("block", call: nil) }
|
116
|
-
let(:block) { Proc.new { callable.call } }
|
117
|
-
|
118
|
-
it "doesn't need leave proc to be called" do
|
119
|
-
expect(callable).to_not receive(:call)
|
120
|
-
subject.mouse_left
|
121
|
-
end
|
122
|
-
|
123
|
-
it "calls block on mouse_left" do
|
124
|
-
expect(callable).to receive(:call)
|
125
|
-
|
126
|
-
subject.leave(block)
|
127
|
-
subject.mouse_left
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
104
|
describe "create_bound_block" do
|
132
105
|
let(:callable) { double("block", call: nil) }
|
133
106
|
let(:block) { Proc.new { callable.call(self) } }
|
data/spec/shoes/sound_spec.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Sound do
|
4
|
-
let(:
|
4
|
+
let(:app_gui) { double("app gui") }
|
5
|
+
let(:parent) { double("parent", gui: app_gui) }
|
5
6
|
let(:filepath) { "../../samples/sounds/61847__simon-rue__boink-v3.wav" }
|
6
7
|
subject { Shoes::Sound.new(parent, filepath) }
|
7
8
|
|
data/spec/shoes/span_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::Span do
|
4
4
|
let(:app) { Shoes::App.new }
|
@@ -34,7 +34,7 @@ describe Shoes::Span do
|
|
34
34
|
it 'does not try to merge with parent style when there are none' do
|
35
35
|
parent = double 'parent'
|
36
36
|
span.parent = parent
|
37
|
-
expect {span.style}.to_not raise_error
|
37
|
+
expect {span.style}.to_not raise_error
|
38
38
|
end
|
39
39
|
|
40
40
|
it 'merges with the styles of the parent text' do
|
data/spec/shoes/spec_helper.rb
CHANGED
@@ -9,7 +9,7 @@ def unpack_styles(styles)
|
|
9
9
|
supported_styles = []
|
10
10
|
styles.each do |style|
|
11
11
|
if Shoes::Common::Style::STYLE_GROUPS[style]
|
12
|
-
Shoes::Common::Style::STYLE_GROUPS[style].each{|s| supported_styles << s}
|
12
|
+
Shoes::Common::Style::STYLE_GROUPS[style].each {|s| supported_styles << s}
|
13
13
|
else
|
14
14
|
supported_styles << style
|
15
15
|
end
|
data/spec/shoes/stack_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'shoes/helpers/fake_element'
|
3
3
|
|
4
4
|
describe Shoes::Stack do
|
@@ -7,9 +7,9 @@ describe Shoes::Stack do
|
|
7
7
|
subject(:stack) { Shoes::Stack.new(app, app, input_opts) }
|
8
8
|
|
9
9
|
it_behaves_like "Slot"
|
10
|
+
it_behaves_like "object with hover"
|
10
11
|
|
11
12
|
describe 'Context' do
|
12
|
-
|
13
13
|
class ContextObject
|
14
14
|
def initialize(app)
|
15
15
|
@app = app
|
@@ -23,7 +23,7 @@ describe Shoes::Stack do
|
|
23
23
|
end
|
24
24
|
|
25
25
|
it 'does not change the context' do
|
26
|
-
app = Shoes.app do
|
26
|
+
app = Shoes.app do; end
|
27
27
|
context_object = ContextObject.new app
|
28
28
|
inside_stack = context_object.check_self_inside_stack
|
29
29
|
expect(inside_stack).to be context_object
|
@@ -36,17 +36,17 @@ describe Shoes::Stack do
|
|
36
36
|
it_behaves_like 'arranges elements underneath each other'
|
37
37
|
|
38
38
|
describe 'small stack height' do
|
39
|
-
let(:input_opts){{height: element.height + 10}}
|
39
|
+
let(:input_opts) {{height: element.height + 10}}
|
40
40
|
it_behaves_like 'set height and contents alignment'
|
41
41
|
end
|
42
42
|
|
43
43
|
describe 'big stack height' do
|
44
|
-
let(:input_opts){{height: 1000}}
|
44
|
+
let(:input_opts) {{height: 1000}}
|
45
45
|
it_behaves_like 'set height and contents alignment'
|
46
46
|
end
|
47
47
|
|
48
48
|
describe 'with margin' do
|
49
|
-
let(:input_opts){{margin: 27}}
|
49
|
+
let(:input_opts) {{margin: 27}}
|
50
50
|
it_behaves_like 'taking care of margin'
|
51
51
|
end
|
52
52
|
end
|
data/spec/shoes/star_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
shared_examples_for "basic star" do
|
4
4
|
it "retains app" do
|
@@ -29,6 +29,7 @@ describe Shoes::Star do
|
|
29
29
|
it_behaves_like "object with dimensions"
|
30
30
|
it_behaves_like "movable object"
|
31
31
|
it_behaves_like 'object with parent'
|
32
|
+
it_behaves_like "object with hover"
|
32
33
|
|
33
34
|
describe "in_bounds?" do
|
34
35
|
before do
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Shoes::TextBlockDimensions do
|
4
4
|
let(:left) { 0 }
|
@@ -62,14 +62,13 @@ describe Shoes::TextBlockDimensions do
|
|
62
62
|
|
63
63
|
describe "with parent" do
|
64
64
|
let(:parent) { double('parent', element_width: 100,
|
65
|
-
|
66
|
-
|
65
|
+
x_dimension: double("x"),
|
66
|
+
y_dimension: double("y")) }
|
67
67
|
subject { Shoes::TextBlockDimensions.new(parent, left, top, nil, height) }
|
68
68
|
|
69
69
|
it "delegates to parent if no width of its own" do
|
70
70
|
expect(subject.containing_width).to eq(100)
|
71
71
|
end
|
72
72
|
end
|
73
|
-
|
74
73
|
end
|
75
74
|
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'shoes/helpers/sample17_helper'
|
3
3
|
|
4
4
|
describe Shoes::TextBlock do
|
@@ -6,13 +6,15 @@ describe Shoes::TextBlock do
|
|
6
6
|
|
7
7
|
let(:text_link) { Shoes::Link.new(app, ['Hello']) }
|
8
8
|
let(:text) { [text_link, ", world!"] }
|
9
|
-
subject(:text_block) { Shoes::
|
9
|
+
subject(:text_block) { Shoes::Para.new(app, parent, text, app: app) }
|
10
10
|
|
11
11
|
it_behaves_like "object with style" do
|
12
|
-
let(:subject_without_style) { Shoes::
|
13
|
-
let(:subject_with_style) { Shoes::
|
12
|
+
let(:subject_without_style) { Shoes::Para.new(app, parent, text) }
|
13
|
+
let(:subject_with_style) { Shoes::Para.new(app, parent, text, arg_styles) }
|
14
14
|
end
|
15
15
|
|
16
|
+
it_behaves_like "object with hover"
|
17
|
+
|
16
18
|
describe "initialize" do
|
17
19
|
it "creates gui object" do
|
18
20
|
expect(text_block.gui).not_to be_nil
|
@@ -92,7 +94,7 @@ describe Shoes::TextBlock do
|
|
92
94
|
end
|
93
95
|
|
94
96
|
describe "font" do
|
95
|
-
let(:text_block) { Shoes::
|
97
|
+
let(:text_block) { Shoes::Para.new(app, parent, ["Hello, world!"], style) }
|
96
98
|
|
97
99
|
context "with defaults" do
|
98
100
|
let(:style) { Hash.new }
|
@@ -149,7 +151,7 @@ describe Shoes::TextBlock do
|
|
149
151
|
|
150
152
|
describe "stroke" do
|
151
153
|
it "should accept a hex code" do
|
152
|
-
s = Shoes::
|
154
|
+
s = Shoes::Para.new(app, parent, ["Hello, world!"], stroke: "#fda", app: app)
|
153
155
|
color = s.style[:stroke]
|
154
156
|
expect(color.red).to eql 255
|
155
157
|
expect(color.green).to eql 221
|
@@ -164,7 +166,7 @@ describe Shoes::TextBlock do
|
|
164
166
|
end
|
165
167
|
|
166
168
|
context "when not explicitly set" do
|
167
|
-
subject(:text_block) { Shoes::
|
169
|
+
subject(:text_block) { Shoes::Para.new(app, parent, ["text"]) }
|
168
170
|
|
169
171
|
it "delegates to calculated width" do
|
170
172
|
subject.calculated_width = 240
|
@@ -194,18 +196,21 @@ describe Shoes::TextBlock do
|
|
194
196
|
end
|
195
197
|
|
196
198
|
context "when explicitly set" do
|
197
|
-
subject(:text_block) { Shoes::
|
199
|
+
subject(:text_block) { Shoes::Para.new(app, parent, ["text"], width: 120) }
|
198
200
|
|
199
201
|
it "gets returned" do
|
200
202
|
expect(subject.width).to eql 120
|
201
203
|
end
|
202
204
|
|
203
205
|
it "is used for desired width" do
|
204
|
-
subject.
|
205
|
-
expect(subject.desired_width).to eql 100
|
206
|
+
expect(subject.desired_width).to eql 120
|
206
207
|
end
|
207
|
-
end
|
208
208
|
|
209
|
+
it "factors in if parent space is too small" do
|
210
|
+
subject.absolute_left = parent.element_width - 100
|
211
|
+
expect(subject.desired_width).to eql(100)
|
212
|
+
end
|
213
|
+
end
|
209
214
|
end
|
210
215
|
|
211
216
|
context "cursor management" do
|
@@ -1,8 +1,7 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
require 'shoes/ui/picker'
|
3
3
|
|
4
4
|
describe Shoes::UI::Picker do
|
5
|
-
|
6
5
|
let(:swt_backend) { "/gems/lib/shoes/swt/generate-backend.rb" }
|
7
6
|
let(:faux_backend) { "/gems/lib/shoes/faux/generate-backend.rb" }
|
8
7
|
|
@@ -12,13 +11,13 @@ describe Shoes::UI::Picker do
|
|
12
11
|
subject { Shoes::UI::Picker.new(input, output) }
|
13
12
|
|
14
13
|
it "selects single backend generator" do
|
15
|
-
allow(Gem).to receive(:find_files) { [
|
14
|
+
allow(Gem).to receive(:find_files) { [swt_backend] }
|
16
15
|
expect(subject.select_generator).to eq(swt_backend)
|
17
16
|
end
|
18
17
|
|
19
18
|
describe "with multiple backend generators" do
|
20
19
|
before do
|
21
|
-
allow(Gem).to receive(:find_files) { [
|
20
|
+
allow(Gem).to receive(:find_files) { [faux_backend, swt_backend] }
|
22
21
|
end
|
23
22
|
|
24
23
|
it "prompts with multiple backend generators" do
|
@@ -53,12 +52,12 @@ describe Shoes::UI::Picker do
|
|
53
52
|
end
|
54
53
|
|
55
54
|
it "fails if no matches" do
|
56
|
-
allow(Gem).to receive(:find_files) { [
|
55
|
+
allow(Gem).to receive(:find_files) { [] }
|
57
56
|
expect { subject.select_generator }.to raise_error(ArgumentError)
|
58
57
|
end
|
59
58
|
|
60
59
|
it "selects by name" do
|
61
|
-
allow(Gem).to receive(:find_files) { [
|
60
|
+
allow(Gem).to receive(:find_files) { [swt_backend] }
|
62
61
|
expect(subject.select_generator("swt")).to eq(swt_backend)
|
63
62
|
end
|
64
63
|
|
data/spec/shoes/url_spec.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
describe 'Shoes.url' do
|
4
4
|
let(:klazz) do
|
@@ -64,5 +64,4 @@ describe 'Shoes.url' do
|
|
64
64
|
it 'instances report class as klazz (regression, do not ask...)' do
|
65
65
|
expect(klazz.new.class).to eq klazz
|
66
66
|
end
|
67
|
-
|
68
67
|
end
|
data/spec/shoes/widget_spec.rb
CHANGED
@@ -1,7 +1,11 @@
|
|
1
|
-
require '
|
1
|
+
require 'spec_helper'
|
2
2
|
|
3
3
|
class Smile < Shoes::Widget
|
4
4
|
def initialize(caption)
|
5
|
+
smile_magic caption
|
6
|
+
end
|
7
|
+
|
8
|
+
def smile_magic(caption)
|
5
9
|
banner caption
|
6
10
|
end
|
7
11
|
end
|
@@ -50,11 +54,15 @@ describe Shoes::Widget do
|
|
50
54
|
include RSpec::Matchers
|
51
55
|
|
52
56
|
url '/', :check_smile
|
53
|
-
url '/smile', :
|
57
|
+
url '/smile', :smile_little_one
|
54
58
|
|
55
59
|
def check_smile
|
56
60
|
expect(self).to respond_to :smile
|
57
61
|
end
|
62
|
+
|
63
|
+
def smile_little_one
|
64
|
+
smile 'little one'
|
65
|
+
end
|
58
66
|
end
|
59
67
|
end
|
60
68
|
|
@@ -63,7 +71,7 @@ describe Shoes::Widget do
|
|
63
71
|
end
|
64
72
|
|
65
73
|
it 'really smiles' do
|
66
|
-
expect_any_instance_of(Smile).to receive(:
|
74
|
+
expect_any_instance_of(Smile).to receive(:smile_magic)
|
67
75
|
Shoes.app do visit '/smile' end
|
68
76
|
end
|
69
77
|
end
|
data/spec/shoes_spec.rb
CHANGED
@@ -2,18 +2,16 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Shoes, 'load_backend' do
|
4
4
|
it "raises ArgumentError on bad input" do
|
5
|
-
expect { Shoes.load_backend :bogus }.to raise_error
|
5
|
+
expect { Shoes.load_backend :bogus }.to raise_error(ArgumentError)
|
6
6
|
end
|
7
7
|
end
|
8
8
|
|
9
9
|
describe Shoes, 'setup' do
|
10
|
-
|
11
10
|
it 'knows this method' do
|
12
11
|
expect(Shoes).to respond_to :setup
|
13
12
|
end
|
14
13
|
|
15
14
|
describe 'outputting on standard error' do
|
16
|
-
|
17
15
|
def expect_stderr_puts(regex)
|
18
16
|
expect($stderr).to receive(:puts).with(regex)
|
19
17
|
end
|
@@ -40,5 +38,4 @@ describe Shoes, 'setup' do
|
|
40
38
|
end
|
41
39
|
end
|
42
40
|
end
|
43
|
-
|
44
41
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -10,10 +10,11 @@ require 'shoes/core'
|
|
10
10
|
require 'shoes/ui/cli'
|
11
11
|
require 'fileutils'
|
12
12
|
require 'shoes/helpers/fake_element'
|
13
|
+
require 'shoes/helpers/fake_absolute_element'
|
13
14
|
require 'shoes/helpers/inspect_helpers'
|
14
15
|
|
15
16
|
require 'webmock/rspec'
|
16
|
-
WebMock.disable_net_connect!(:
|
17
|
+
WebMock.disable_net_connect!(allow: "codeclimate.com")
|
17
18
|
|
18
19
|
shared_examples = File.expand_path('../shoes/shared_examples/**/*.rb', __FILE__)
|
19
20
|
Dir[shared_examples].each { |f| require f }
|