rad_core 0.2.6 → 0.2.7
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.
- data/Rakefile +2 -2
- data/bin/rad +20 -25
- data/lib/components/config.rb +1 -1
- data/lib/components/configurators.rb +2 -2
- data/lib/components/controller.rb +2 -2
- data/lib/components/conveyors.rb +2 -2
- data/lib/components/environment.rb +1 -1
- data/lib/components/environment.yml +28 -28
- data/lib/components/flash.rb +1 -1
- data/lib/components/html.rb +1 -1
- data/lib/components/http.rb +1 -1
- data/lib/components/http.yml +1 -1
- data/lib/components/logger.rb +2 -2
- data/lib/components/mailer.rb +2 -2
- data/lib/components/remote.rb +1 -1
- data/lib/components/router.rb +3 -3
- data/lib/components/template.rb +2 -2
- data/lib/components/web.rb +3 -3
- data/lib/rad.rb +1 -1
- data/lib/rad/_support/active_support.rb +7 -7
- data/lib/rad/_support/active_support/locales/ru/actionview.yml +8 -8
- data/lib/rad/_support/active_support/locales/ru/activesupport.yml +4 -4
- data/lib/rad/_support/active_support/locales/ru/datetime.yml +5 -5
- data/lib/rad/_support/active_support/time.rb +2 -2
- data/lib/rad/_support/addressable.rb +6 -6
- data/lib/rad/_support/class_loader.rb +1 -1
- data/lib/rad/_support/extensions.rb +5 -5
- data/lib/rad/_support/filters.rb +13 -13
- data/lib/rad/_support/hacks_and_fixes.rb +5 -5
- data/lib/rad/_support/mime.rb +4 -4
- data/lib/rad/_support/module.rb +11 -11
- data/lib/rad/_support/require.rb +5 -5
- data/lib/rad/_support/rson.rb +4 -4
- data/lib/rad/_support/string.rb +9 -9
- data/lib/rad/cli/helper.rb +5 -5
- data/lib/rad/configurators/_require.rb +2 -2
- data/lib/rad/configurators/abstract.rb +5 -5
- data/lib/rad/configurators/web.rb +8 -8
- data/lib/rad/controller/_abstract.rb +15 -14
- data/lib/rad/controller/_abstract/miscellaneous.rb +5 -5
- data/lib/rad/controller/_abstract/render.rb +40 -40
- data/lib/rad/controller/_abstract/responder.rb +1 -1
- data/lib/rad/controller/_context.rb +1 -1
- data/lib/rad/controller/_http.rb +11 -11
- data/lib/rad/controller/_require.rb +6 -6
- data/lib/rad/controller/processors/controller_caller.rb +3 -3
- data/lib/rad/controller/processors/controller_error_handling.rb +14 -14
- data/lib/rad/controller/processors/controller_logger.rb +1 -1
- data/lib/rad/conveyors/_conveyor.rb +9 -9
- data/lib/rad/conveyors/_conveyors.rb +4 -4
- data/lib/rad/conveyors/_params.rb +5 -5
- data/lib/rad/conveyors/_processor.rb +2 -2
- data/lib/rad/conveyors/_workspace.rb +5 -5
- data/lib/rad/conveyors/processors/conveyor_logger.rb +3 -3
- data/lib/rad/environment/_config.rb +4 -4
- data/lib/rad/environment/_environment.rb +10 -10
- data/lib/rad/environment/_files_helper.rb +5 -5
- data/lib/rad/environment/_logger.rb +9 -9
- data/lib/rad/environment/_require.rb +4 -4
- data/lib/rad/gems.rb +14 -14
- data/lib/rad/html/_flash.rb +5 -5
- data/lib/rad/html/_helpers/basic_html_helper.rb +12 -12
- data/lib/rad/html/_helpers/form_helper.rb +19 -19
- data/lib/rad/html/_helpers/javascript_helper.rb +6 -6
- data/lib/rad/html/_helpers/model_helper.rb +17 -17
- data/lib/rad/html/_require.rb +1 -1
- data/lib/rad/html/processors/prepare_flash.rb +3 -3
- data/lib/rad/html/processors/scoped_params.rb +4 -4
- data/lib/rad/http/_http.rb +4 -4
- data/lib/rad/http/_http_adapter.rb +5 -5
- data/lib/rad/http/_request.rb +11 -11
- data/lib/rad/http/_require.rb +8 -8
- data/lib/rad/http/_response.rb +5 -5
- data/lib/rad/http/_support/rack/fixes.rb +3 -3
- data/lib/rad/http/_support/rack/rack_adapter.rb +5 -5
- data/lib/rad/http/processors/evaluate_format.rb +4 -4
- data/lib/rad/http/processors/http_logger.rb +3 -3
- data/lib/rad/http/processors/http_writer.rb +7 -7
- data/lib/rad/http/processors/prepare_params.rb +5 -5
- data/lib/rad/mailer/_letter.rb +1 -1
- data/lib/rad/mailer/_mailer.rb +1 -1
- data/lib/rad/mailer/_mailer_controller.rb +6 -6
- data/lib/rad/mailer/_require.rb +1 -1
- data/lib/rad/mailer/processors/letter_builder.rb +6 -6
- data/lib/rad/profiles/mailer.rb +2 -2
- data/lib/rad/profiles/web.rb +13 -13
- data/lib/rad/remote/processors/remote_caller.rb +10 -10
- data/lib/rad/remote/processors/remote_logger.rb +1 -1
- data/lib/rad/router/_abstract_router.rb +9 -9
- data/lib/rad/router/_alias_router.rb +34 -34
- data/lib/rad/router/_basic_router.rb +12 -12
- data/lib/rad/router/_configurator.rb +6 -6
- data/lib/rad/router/_core_routing_helper.rb +4 -4
- data/lib/rad/router/_object_router.rb +45 -45
- data/lib/rad/router/_require.rb +8 -8
- data/lib/rad/router/_restful_router.rb +25 -25
- data/lib/rad/router/_router.rb +78 -78
- data/lib/rad/router/_simple_router.rb +5 -5
- data/lib/rad/router/processors/router.rb +6 -6
- data/lib/rad/spec/controller.rb +9 -9
- data/lib/rad/spec/environment.rb +7 -7
- data/lib/rad/spec/http.rb +2 -2
- data/lib/rad/spec/http_controller.rb +22 -22
- data/lib/rad/spec/mailer.rb +4 -4
- data/lib/rad/spec/remote.rb +1 -1
- data/lib/rad/spec/router.rb +4 -4
- data/lib/rad/spec/template.rb +2 -2
- data/lib/rad/tasks.rb +2 -2
- data/lib/rad/template/_context.rb +15 -15
- data/lib/rad/template/_relative_path_resolver.rb +1 -1
- data/lib/rad/template/_support/tilt.rb +17 -17
- data/lib/rad/template/_support/tilt_fixes.rb +3 -3
- data/lib/rad/template/_template.rb +47 -47
- data/lib/rad/web/_ajax_helper.rb +4 -4
- data/lib/rad/web/_controller_miscellaneous_helper.rb +5 -5
- data/lib/rad/web/_ensure_no_www.rb +5 -5
- data/lib/rad/web/_protect_from_forgery.rb +18 -18
- data/lib/rad/web/_require.rb +7 -7
- data/lib/rad/web/_router/abstract_routing_helper.rb +4 -4
- data/lib/rad/web/_router/controller_routing_helper.rb +15 -15
- data/lib/rad/web/_router/view_routing_helper.rb +12 -12
- data/readme.md +5 -5
- data/spec/controller/abstract_spec.rb +29 -29
- data/spec/controller/context_spec.rb +32 -32
- data/spec/controller/error_handling_spec.rb +31 -31
- data/spec/controller/helper_spec.rb +13 -13
- data/spec/controller/http_spec.rb +32 -32
- data/spec/controller/render_spec.rb +59 -59
- data/spec/conveyors/conveyors_spec.rb +32 -32
- data/spec/environment/config_spec.rb +6 -6
- data/spec/environment/environment_spec.rb +7 -7
- data/spec/environment/minimal_app_spec.rb +4 -4
- data/spec/environment/standard_app_spec.rb +10 -10
- data/spec/html/basic_html_helper_spec.rb +6 -6
- data/spec/html/form_helper_spec.rb +5 -5
- data/spec/html/javascript_helper_spec.rb +4 -4
- data/spec/html/model_helper_spec.rb +12 -12
- data/spec/html/scoped_params_spec.rb +2 -2
- data/spec/html/spec_helper.rb +3 -3
- data/spec/http/http_spec.rb +9 -9
- data/spec/http/miscellaneous_spec.rb +2 -2
- data/spec/mailer/mail_controller_spec.rb +23 -23
- data/spec/remote/remote_spec.rb +26 -26
- data/spec/router/alias_router_spec.rb +22 -22
- data/spec/router/basic_router_spec.rb +8 -8
- data/spec/router/configurator_spec.rb +4 -4
- data/spec/router/integration_spec.rb +17 -17
- data/spec/router/object_router_spec.rb +47 -47
- data/spec/router/persistent_params_spec.rb +18 -18
- data/spec/router/restful_router_spec.rb +39 -39
- data/spec/router/router_spec.rb +37 -37
- data/spec/router/routing_helper_spec.rb +18 -18
- data/spec/support/filters_spec.rb +11 -13
- data/spec/template/template_spec.rb +43 -45
- data/spec/template/template_spec/views/layout/content_for/content.erb +3 -1
- data/spec/template/template_spec/views/layout/content_for/layout.erb +1 -1
- data/spec/template/tilt_spec.rb +24 -24
- data/spec/web/basic_spec.rb +25 -25
- data/spec/web/controller_routing_helper_spec.rb +26 -26
- data/spec/web/flash_spec.rb +31 -31
- data/spec/web/protect_from_forgery_spec.rb +44 -44
- data/spec/web/spec_helper_spec.rb +16 -16
- data/spec/web/view_routing_helper_spec.rb +31 -31
- metadata +46 -49
- data/lib/rad/_support/callbacks.rb +0 -166
- data/lib/rad/_support/ruby_ext_with_active_support.rb +0 -4
- data/spec/support/callbacks_spec.rb +0 -157
|
@@ -2,8 +2,8 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe "Controller render" do
|
|
4
4
|
with_view_path "#{spec_dir}/views"
|
|
5
|
-
with_abstract_controller
|
|
6
|
-
|
|
5
|
+
with_abstract_controller
|
|
6
|
+
|
|
7
7
|
after :all do
|
|
8
8
|
remove_constants %w(
|
|
9
9
|
LayoutFiltersSpec
|
|
@@ -16,91 +16,91 @@ describe "Controller render" do
|
|
|
16
16
|
AlreadyRenderedSpec
|
|
17
17
|
SpecialFormatSpec
|
|
18
18
|
AnotherActionSpec
|
|
19
|
-
InlineRenderSpec
|
|
19
|
+
InlineRenderSpec
|
|
20
20
|
InlineWithLayoutSpec
|
|
21
21
|
MultipleActions
|
|
22
22
|
RelativeSpec
|
|
23
23
|
)
|
|
24
24
|
end
|
|
25
|
-
|
|
26
|
-
describe 'layout' do
|
|
25
|
+
|
|
26
|
+
describe 'layout' do
|
|
27
27
|
it "should use :except and :only in layout" do
|
|
28
28
|
class ::LayoutFiltersSpec
|
|
29
29
|
inherit Rad::Controller::Abstract
|
|
30
30
|
layout '/layouts/app', only: :action_with_layout
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
def action_with_layout; end
|
|
33
33
|
def action_without_layout; end
|
|
34
34
|
end
|
|
35
|
-
|
|
36
|
-
ccall(LayoutFiltersSpec, :action_with_layout, format: 'html').should == "Layout html, content"
|
|
35
|
+
|
|
36
|
+
ccall(LayoutFiltersSpec, :action_with_layout, format: 'html').should == "Layout html, content"
|
|
37
37
|
ccall(LayoutFiltersSpec, :action_without_layout).should == "content"
|
|
38
38
|
end
|
|
39
|
-
|
|
39
|
+
|
|
40
40
|
it "should apply formats to layout" do
|
|
41
41
|
class LayoutSpec
|
|
42
42
|
inherit Rad::Controller::Abstract
|
|
43
43
|
layout '/layouts/app'
|
|
44
|
-
|
|
45
|
-
def action; end
|
|
44
|
+
|
|
45
|
+
def action; end
|
|
46
46
|
end
|
|
47
|
-
|
|
48
|
-
ccall(LayoutSpec, :action, format: 'html').should == "Layout html, content"
|
|
47
|
+
|
|
48
|
+
ccall(LayoutSpec, :action, format: 'html').should == "Layout html, content"
|
|
49
49
|
ccall(LayoutSpec, :action, format: 'js').should == "Layout js, content"
|
|
50
|
-
end
|
|
51
|
-
|
|
50
|
+
end
|
|
51
|
+
|
|
52
52
|
it "should take layout: false or layout: '/another_layout'" do
|
|
53
53
|
class AnotherLayout
|
|
54
54
|
inherit Rad::Controller::Abstract
|
|
55
55
|
layout '/layout/app'
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
def action; end
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
def without_layout
|
|
60
60
|
render action: :action, layout: false
|
|
61
61
|
end
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
def another_layout
|
|
64
64
|
render action: :action, layout: '/layouts/admin'
|
|
65
|
-
end
|
|
65
|
+
end
|
|
66
66
|
end
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
ccall(AnotherLayout, :without_layout).should == "action"
|
|
69
69
|
ccall(AnotherLayout, :another_layout).should == "Admin layout, action"
|
|
70
70
|
end
|
|
71
|
-
|
|
72
|
-
|
|
71
|
+
|
|
72
|
+
|
|
73
73
|
it "should take into account :layout when rendering template" do
|
|
74
74
|
class ::ExplicitRenderSpec
|
|
75
75
|
inherit Rad::Controller::Abstract
|
|
76
76
|
layout '/layouts/app'
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
def with_layout
|
|
79
79
|
render '/some_template'
|
|
80
80
|
end
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
def without_layout
|
|
83
83
|
render '/some_template', layout: false
|
|
84
84
|
end
|
|
85
85
|
end
|
|
86
|
-
|
|
86
|
+
|
|
87
87
|
ccall(ExplicitRenderSpec, :with_layout, format: 'html').should == "Layout html, some template"
|
|
88
88
|
ccall(ExplicitRenderSpec, :without_layout, format: 'html').should == "some template"
|
|
89
|
-
end
|
|
89
|
+
end
|
|
90
90
|
end
|
|
91
|
-
|
|
91
|
+
|
|
92
92
|
it "should render template inside of controller" do
|
|
93
93
|
class ::RenderInsideOfControllerSpec
|
|
94
94
|
inherit Rad::Controller::Abstract
|
|
95
95
|
|
|
96
96
|
def some_action
|
|
97
97
|
render '/some_template'
|
|
98
|
-
end
|
|
98
|
+
end
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
ccall(RenderInsideOfControllerSpec,
|
|
101
|
+
ccall(RenderInsideOfControllerSpec, :some_action).should == "some template"
|
|
102
102
|
end
|
|
103
|
-
|
|
103
|
+
|
|
104
104
|
it "should not allow to render partials as actions" do
|
|
105
105
|
class ::ForbidPartialAsActionSpec
|
|
106
106
|
inherit Rad::Controller::Abstract
|
|
@@ -109,21 +109,21 @@ describe "Controller render" do
|
|
|
109
109
|
|
|
110
110
|
ccall(ForbidPartialAsActionSpec, :action).should == ''
|
|
111
111
|
end
|
|
112
|
-
|
|
112
|
+
|
|
113
113
|
it "should render view with right format" do
|
|
114
114
|
class FormatSpec
|
|
115
115
|
inherit Rad::Controller::Abstract
|
|
116
116
|
def action; end
|
|
117
117
|
end
|
|
118
118
|
|
|
119
|
-
ccall(FormatSpec, :action, format: 'html').should == "html format"
|
|
119
|
+
ccall(FormatSpec, :action, format: 'html').should == "html format"
|
|
120
120
|
ccall(FormatSpec, :action, format: 'js').should == "js format"
|
|
121
121
|
end
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
it "should be able to use rad.template.render for different purposes (mail for example)" do
|
|
124
124
|
rad.template.render("/standalone", locals: {a: 'a'}).should == 'standalone usage, a'
|
|
125
125
|
end
|
|
126
|
-
|
|
126
|
+
|
|
127
127
|
it "should not rener if already rendered in controller" do
|
|
128
128
|
class ::AlreadyRenderedSpec
|
|
129
129
|
inherit Rad::Controller::Abstract
|
|
@@ -135,93 +135,93 @@ describe "Controller render" do
|
|
|
135
135
|
|
|
136
136
|
ccall(AlreadyRenderedSpec, :action).should == 'custom content'
|
|
137
137
|
end
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
it "should handle serialization obj ('xml', 'json')" do
|
|
140
140
|
class ::SpecialFormatSpec
|
|
141
141
|
inherit Rad::Controller::Abstract
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
def json_action
|
|
144
144
|
render json: {a: "b"}
|
|
145
145
|
end
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
def xml_action
|
|
148
148
|
render xml: {a: "b"}
|
|
149
149
|
end
|
|
150
150
|
end
|
|
151
|
-
|
|
152
|
-
ccall(SpecialFormatSpec, :json_action, format: 'json').should == %({"a":"b"})
|
|
153
|
-
ccall(SpecialFormatSpec, :xml_action, format: 'xml').should =~ /<a>b<\/a>/
|
|
151
|
+
|
|
152
|
+
ccall(SpecialFormatSpec, :json_action, format: 'json').should == %({"a":"b"})
|
|
153
|
+
ccall(SpecialFormatSpec, :xml_action, format: 'xml').should =~ /<a>b<\/a>/
|
|
154
154
|
-> {
|
|
155
155
|
ccall(SpecialFormatSpec, :json_action, format: 'xml')
|
|
156
156
|
}.should raise_error(/responing with 'json' to the 'xml'/)
|
|
157
157
|
end
|
|
158
|
-
|
|
158
|
+
|
|
159
159
|
it "should render another action via action: :action_name" do
|
|
160
160
|
class ::AnotherActionSpec
|
|
161
161
|
inherit Rad::Controller::Abstract
|
|
162
|
-
|
|
162
|
+
|
|
163
163
|
def another_action; end
|
|
164
|
-
|
|
165
|
-
def action
|
|
164
|
+
|
|
165
|
+
def action
|
|
166
166
|
render action: :another_action
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
|
-
|
|
169
|
+
|
|
170
170
|
ccall(AnotherActionSpec, :action).should == "another action (action_name: another_action)"
|
|
171
171
|
end
|
|
172
|
-
|
|
172
|
+
|
|
173
173
|
it "should take :inline option" do
|
|
174
174
|
class ::InlineRenderSpec
|
|
175
175
|
inherit Rad::Controller::Abstract
|
|
176
|
-
|
|
176
|
+
|
|
177
177
|
def action
|
|
178
178
|
render inline: "content"
|
|
179
179
|
end
|
|
180
180
|
end
|
|
181
|
-
|
|
181
|
+
|
|
182
182
|
ccall(InlineRenderSpec, :action).should == "content"
|
|
183
183
|
end
|
|
184
|
-
|
|
184
|
+
|
|
185
185
|
# it ":inline option should render without layout" do
|
|
186
186
|
# class ::InlineWithLayoutSpec
|
|
187
187
|
# inherit Rad::Controller::Abstract
|
|
188
|
-
#
|
|
188
|
+
#
|
|
189
189
|
# layout '/layouts/app'
|
|
190
|
-
#
|
|
190
|
+
#
|
|
191
191
|
# def action
|
|
192
192
|
# render inline: "content"
|
|
193
193
|
# end
|
|
194
194
|
# end
|
|
195
|
-
#
|
|
195
|
+
#
|
|
196
196
|
# ccall(InlineWithLayoutSpec, :action).should == "content"
|
|
197
197
|
# end
|
|
198
|
-
|
|
198
|
+
|
|
199
199
|
it "should render correct action inside of special 'actions.xxx' template file" do
|
|
200
200
|
class ::MultipleActions
|
|
201
201
|
inherit Rad::Controller::Abstract
|
|
202
|
-
|
|
202
|
+
|
|
203
203
|
def increase; end
|
|
204
204
|
def decrease; end
|
|
205
205
|
def action_without_template; end
|
|
206
206
|
end
|
|
207
|
-
|
|
207
|
+
|
|
208
208
|
ccall(MultipleActions, :increase).should == "plus\n"
|
|
209
209
|
ccall(MultipleActions, :decrease).should == "minus\n"
|
|
210
210
|
ccall(MultipleActions, :action_without_template).should == ''
|
|
211
211
|
end
|
|
212
|
-
|
|
212
|
+
|
|
213
213
|
it "relative templates should be searched as: CurrentClass -> SuperClass -> SameDir" do
|
|
214
214
|
module ::RelativeSpec
|
|
215
215
|
class A
|
|
216
216
|
inherit Rad::Controller::Abstract
|
|
217
|
-
|
|
217
|
+
|
|
218
218
|
def show; end
|
|
219
219
|
end
|
|
220
|
-
|
|
220
|
+
|
|
221
221
|
class B < A
|
|
222
222
|
end
|
|
223
223
|
end
|
|
224
|
-
|
|
224
|
+
|
|
225
225
|
ccall(RelativeSpec::B, :show).should == 'form b'
|
|
226
226
|
end
|
|
227
227
|
end
|
|
@@ -2,12 +2,12 @@ require "spec_helper"
|
|
|
2
2
|
|
|
3
3
|
describe "Conveyor" do
|
|
4
4
|
inject conveyors: :conveyors
|
|
5
|
-
|
|
5
|
+
|
|
6
6
|
def call_conveyor
|
|
7
7
|
r = conveyors.web.call(result: [])
|
|
8
8
|
r.result
|
|
9
9
|
end
|
|
10
|
-
|
|
10
|
+
|
|
11
11
|
after :all do
|
|
12
12
|
remove_constants %w(
|
|
13
13
|
SmokeTestASpec
|
|
@@ -21,65 +21,65 @@ describe "Conveyor" do
|
|
|
21
21
|
ErrorBubblingBSpec
|
|
22
22
|
)
|
|
23
23
|
end
|
|
24
|
-
|
|
24
|
+
|
|
25
25
|
isolate :conveyors
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
before :all do
|
|
28
28
|
rad.mode = :development, true
|
|
29
29
|
end
|
|
30
|
-
|
|
30
|
+
|
|
31
31
|
after :all do
|
|
32
32
|
rad.mode = :test, true
|
|
33
33
|
end
|
|
34
|
-
|
|
34
|
+
|
|
35
35
|
it "smoke test" do
|
|
36
|
-
class SmokeTestASpec < Rad::Conveyors::Processor
|
|
36
|
+
class SmokeTestASpec < Rad::Conveyors::Processor
|
|
37
37
|
def call
|
|
38
|
-
workspace.result << :a_before
|
|
38
|
+
workspace.result << :a_before
|
|
39
39
|
next_processor.call
|
|
40
40
|
workspace.result << :a_after
|
|
41
41
|
end
|
|
42
42
|
end
|
|
43
43
|
|
|
44
|
-
class SmokeTestBSpec < Rad::Conveyors::Processor
|
|
45
|
-
def call
|
|
46
|
-
rad.workspace.result << :b_before
|
|
44
|
+
class SmokeTestBSpec < Rad::Conveyors::Processor
|
|
45
|
+
def call
|
|
46
|
+
rad.workspace.result << :b_before
|
|
47
47
|
next_processor.call
|
|
48
48
|
rad.workspace.result << :b_after
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
conveyors.web.use SmokeTestASpec
|
|
53
53
|
conveyors.web.use SmokeTestBSpec
|
|
54
54
|
call_conveyor.should == [:a_before, :b_before, :b_after, :a_after]
|
|
55
55
|
end
|
|
56
|
-
|
|
56
|
+
|
|
57
57
|
describe "error handling" do
|
|
58
58
|
it "common case" do
|
|
59
59
|
class CommonCaseASpec < Rad::Conveyors::Processor
|
|
60
60
|
def call
|
|
61
61
|
workspace.result << :a_before
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
begin
|
|
64
64
|
next_processor.call
|
|
65
65
|
rescue StandardError => e
|
|
66
66
|
workspace.result << e.message
|
|
67
67
|
end
|
|
68
68
|
end
|
|
69
|
-
end
|
|
70
|
-
|
|
69
|
+
end
|
|
70
|
+
|
|
71
71
|
class CommonCaseBSpec < Rad::Conveyors::Processor
|
|
72
72
|
def call
|
|
73
73
|
workspace.result << :b_before
|
|
74
74
|
raise 'error before'
|
|
75
75
|
end
|
|
76
76
|
end
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
conveyors.web.use CommonCaseASpec
|
|
79
79
|
conveyors.web.use CommonCaseBSpec
|
|
80
80
|
call_conveyor.should == [:a_before, :b_before, "error before"]
|
|
81
81
|
end
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
it "should raise error if not catched" do
|
|
84
84
|
class NotCatchedErrorSpec < Rad::Conveyors::Processor
|
|
85
85
|
def call
|
|
@@ -87,39 +87,39 @@ describe "Conveyor" do
|
|
|
87
87
|
raise 'error before'
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
conveyors.web.use NotCatchedErrorSpec
|
|
92
92
|
lambda{call_conveyor}.should raise_error(/error before/)
|
|
93
93
|
end
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
it "in after block" do
|
|
96
96
|
class ErrorInAfterBlockASpec < Rad::Conveyors::Processor
|
|
97
97
|
def call
|
|
98
98
|
workspace.result << :a_before
|
|
99
|
-
|
|
99
|
+
|
|
100
100
|
begin
|
|
101
101
|
next_processor.call
|
|
102
102
|
rescue StandardError => e
|
|
103
103
|
workspace.result << e.message
|
|
104
104
|
end
|
|
105
105
|
end
|
|
106
|
-
end
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
|
|
109
109
|
class ErrorInAfterBlockBSpec < Rad::Conveyors::Processor
|
|
110
110
|
def call
|
|
111
111
|
workspace.result << :b_before
|
|
112
112
|
next_processor.call
|
|
113
|
-
raise 'error after'
|
|
113
|
+
raise 'error after'
|
|
114
114
|
end
|
|
115
115
|
end
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
|
|
117
|
+
|
|
118
118
|
conveyors.web.use ErrorInAfterBlockASpec
|
|
119
119
|
conveyors.web.use ErrorInAfterBlockBSpec
|
|
120
120
|
call_conveyor.should == [:a_before, :b_before, "error after"]
|
|
121
121
|
end
|
|
122
|
-
|
|
122
|
+
|
|
123
123
|
it "bubbling (from error)" do
|
|
124
124
|
class ErrorBubblingASpec < Rad::Conveyors::Processor
|
|
125
125
|
def call
|
|
@@ -130,16 +130,16 @@ describe "Conveyor" do
|
|
|
130
130
|
end
|
|
131
131
|
end
|
|
132
132
|
end
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
class ErrorBubblingBSpec < Rad::Conveyors::Processor
|
|
135
135
|
def call
|
|
136
136
|
raise 'error'
|
|
137
137
|
end
|
|
138
|
-
end
|
|
139
|
-
|
|
138
|
+
end
|
|
139
|
+
|
|
140
140
|
conveyors.web.use ErrorBubblingASpec
|
|
141
141
|
conveyors.web.use ErrorBubblingBSpec
|
|
142
|
-
|
|
142
|
+
|
|
143
143
|
call_conveyor.should == ['error']
|
|
144
144
|
end
|
|
145
145
|
end
|
|
@@ -3,20 +3,20 @@ require 'spec_helper'
|
|
|
3
3
|
require 'rad'
|
|
4
4
|
require 'rad/spec/environment'
|
|
5
5
|
|
|
6
|
-
describe 'Config' do
|
|
6
|
+
describe 'Config' do
|
|
7
7
|
before do
|
|
8
8
|
rad.mode = :development, true
|
|
9
|
-
@c = Rad::Config.new key: 'value', key2: 'value2'
|
|
9
|
+
@c = Rad::Config.new key: 'value', key2: 'value2'
|
|
10
10
|
end
|
|
11
11
|
after{rad.mode = :test, true}
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
it "clone" do
|
|
14
14
|
c = Rad::Config.new a: {b: :c}
|
|
15
|
-
|
|
16
|
-
c2 = c.clone
|
|
15
|
+
|
|
16
|
+
c2 = c.clone
|
|
17
17
|
c.a.delete :b
|
|
18
18
|
c.delete :a
|
|
19
|
-
|
|
19
|
+
|
|
20
20
|
c2.a[:b].should == :c
|
|
21
21
|
end
|
|
22
22
|
end
|