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
|
@@ -1,18 +1,16 @@
|
|
|
1
1
|
require 'support/spec_helper'
|
|
2
|
-
|
|
3
|
-
require "rad/_support/callbacks"
|
|
4
2
|
require "rad/_support/filters"
|
|
5
3
|
|
|
6
4
|
describe "Filters" do
|
|
7
5
|
module ARemote
|
|
8
6
|
inherit Rad::Filters
|
|
9
7
|
end
|
|
10
|
-
|
|
8
|
+
|
|
11
9
|
class FiltersBasic
|
|
12
10
|
inherit ARemote
|
|
13
|
-
|
|
11
|
+
|
|
14
12
|
before :set_user
|
|
15
|
-
|
|
13
|
+
|
|
16
14
|
def action
|
|
17
15
|
'result'
|
|
18
16
|
end
|
|
@@ -22,39 +20,39 @@ describe "Filters" do
|
|
|
22
20
|
@user = 'some user'
|
|
23
21
|
end
|
|
24
22
|
end
|
|
25
|
-
|
|
23
|
+
|
|
26
24
|
class FilterInheritance < FiltersBasic
|
|
27
25
|
before :set_model
|
|
28
|
-
|
|
26
|
+
|
|
29
27
|
attr_reader :model
|
|
30
28
|
def set_model
|
|
31
29
|
@model = 'some model'
|
|
32
|
-
end
|
|
30
|
+
end
|
|
33
31
|
end
|
|
34
|
-
|
|
32
|
+
|
|
35
33
|
class FilterOverrideAction < FiltersBasic
|
|
36
34
|
def action
|
|
37
35
|
'overriden result'
|
|
38
36
|
end
|
|
39
37
|
end
|
|
40
|
-
|
|
38
|
+
|
|
41
39
|
it 'basic' do
|
|
42
40
|
r = FiltersBasic.new
|
|
43
41
|
r.run_callbacks(:action){r.send :action}.should == 'result'
|
|
44
42
|
r.user.should == 'some user'
|
|
45
43
|
end
|
|
46
|
-
|
|
44
|
+
|
|
47
45
|
it 'inheritance' do
|
|
48
46
|
r = FilterInheritance.new
|
|
49
47
|
r.run_callbacks(:action){r.send :action}.should == 'result'
|
|
50
48
|
r.user.should == 'some user'
|
|
51
49
|
r.model.should == 'some model'
|
|
52
50
|
end
|
|
53
|
-
|
|
51
|
+
|
|
54
52
|
it "overriding action" do
|
|
55
53
|
r = FilterOverrideAction.new
|
|
56
54
|
r.run_callbacks(:action){r.send :action}.should == 'overriden result'
|
|
57
55
|
r.user.should == 'some user'
|
|
58
56
|
end
|
|
59
|
-
|
|
57
|
+
|
|
60
58
|
end
|
|
@@ -2,64 +2,64 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
describe "Template" do
|
|
4
4
|
with_view_path "#{spec_dir}/views"
|
|
5
|
-
|
|
6
|
-
before :all do
|
|
5
|
+
|
|
6
|
+
before :all do
|
|
7
7
|
class ::SomeObject
|
|
8
|
-
attr_accessor :ivariable
|
|
8
|
+
attr_accessor :ivariable
|
|
9
9
|
end
|
|
10
|
-
end
|
|
10
|
+
end
|
|
11
11
|
after :all do
|
|
12
12
|
remove_constants %w(SomeObject)
|
|
13
13
|
end
|
|
14
|
-
|
|
14
|
+
|
|
15
15
|
before do
|
|
16
16
|
rad.mode = :development, true
|
|
17
17
|
$render_result = OpenObject.new
|
|
18
|
-
end
|
|
18
|
+
end
|
|
19
19
|
after{rad.mode = :test, true}
|
|
20
|
-
|
|
20
|
+
|
|
21
21
|
inject template: :template
|
|
22
|
-
|
|
22
|
+
|
|
23
23
|
def render *a, &b
|
|
24
24
|
template.render *a, &b
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
describe 'special' do
|
|
28
28
|
it "read" do
|
|
29
29
|
template.read('/other/template').should == %{<% "ruby code" %> content}
|
|
30
30
|
end
|
|
31
|
-
|
|
31
|
+
|
|
32
32
|
it "exist?" do
|
|
33
33
|
template.should exist('/other/template')
|
|
34
34
|
template.should_not exist('/other/non-existing-template')
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
it "template prefixes" do
|
|
38
38
|
template.exist?('/prefixes/underscored', prefixes: ['']).should be_false
|
|
39
39
|
render('/prefixes/underscored', prefixes: ['_', '']).should == "underscored"
|
|
40
40
|
render('/prefixes/underscored.erb', prefixes: ['_', '']).should == "underscored"
|
|
41
|
-
|
|
41
|
+
|
|
42
42
|
template.exist?('/prefixes/without_prefix', prefixes: ['_']).should be_false
|
|
43
43
|
render('/prefixes/without_prefix', prefixes: ['']).should == "whthout prefix"
|
|
44
44
|
end
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
it "should not use prefixes for :action" do
|
|
47
47
|
template.exist?('/prefixes/underscored').should be_true
|
|
48
48
|
template.exist?('/prefixes/underscored', prefixes: [''], exact_format: true).should be_false
|
|
49
49
|
end
|
|
50
50
|
end
|
|
51
|
-
|
|
51
|
+
|
|
52
52
|
describe 'basic' do
|
|
53
|
-
it "general" do
|
|
53
|
+
it "general" do
|
|
54
54
|
some_object = SomeObject.new
|
|
55
55
|
some_object.ivariable = "instance variable value"
|
|
56
56
|
options = {
|
|
57
57
|
instance_variables: [some_object, {ivariable2: "instance variable value 2"}],
|
|
58
|
-
object: OpenObject.new.update(value: 'object value'),
|
|
58
|
+
object: OpenObject.new.update(value: 'object value'),
|
|
59
59
|
locals: {lvariable: 'local value'},
|
|
60
60
|
format: 'html'
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
result = render("/basic/general", options){|content_name| "content for :#{content_name}"}
|
|
64
64
|
|
|
65
65
|
check = %{\
|
|
@@ -71,53 +71,53 @@ Yield: content for :content}
|
|
|
71
71
|
|
|
72
72
|
result.should == check
|
|
73
73
|
end
|
|
74
|
-
|
|
74
|
+
|
|
75
75
|
it "should not render wrong format if :action specified" do
|
|
76
76
|
template.exist?('/basic/non_existing_format', format: 'html', prefixes: [''], exact_format: true).should be_true
|
|
77
77
|
template.exist?('/basic/non_existing_format', format: :invalid, prefixes: [''], exact_format: true).should be_false
|
|
78
|
-
|
|
78
|
+
|
|
79
79
|
# from error
|
|
80
80
|
template.exist?('non_existing_format', format: :invalid, prefixes: [''], exact_format: true, current_dir: "#{spec_dir}/views/basic").should be_false
|
|
81
81
|
end
|
|
82
|
-
|
|
82
|
+
|
|
83
83
|
it "extension" do
|
|
84
84
|
render('/basic/extension').should == "some content"
|
|
85
85
|
render('/basic/extension.erb').should == "some content"
|
|
86
86
|
end
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
it "must support custom context_class" do
|
|
89
89
|
class CustomTemplateContext < Rad::Template::Context
|
|
90
90
|
def custom_helper
|
|
91
91
|
'custom helper'
|
|
92
92
|
end
|
|
93
93
|
end
|
|
94
|
-
|
|
94
|
+
|
|
95
95
|
render('/basic/custom_context', context: CustomTemplateContext.new).should == "content from custom helper"
|
|
96
96
|
end
|
|
97
|
-
|
|
97
|
+
|
|
98
98
|
# it "must support explicit context, and it should overtake context_class" do
|
|
99
99
|
# class CustomTemplateContext < Rad::Template::Context
|
|
100
100
|
# def custom_helper
|
|
101
101
|
# 'custom helper'
|
|
102
102
|
# end
|
|
103
103
|
# end
|
|
104
|
-
#
|
|
104
|
+
#
|
|
105
105
|
# render(
|
|
106
|
-
# '/basic/custom_context',
|
|
107
|
-
# context: CustomTemplateContext.new,
|
|
106
|
+
# '/basic/custom_context',
|
|
107
|
+
# context: CustomTemplateContext.new,
|
|
108
108
|
# context_class: Object
|
|
109
109
|
# ).should == "content from custom helper"
|
|
110
110
|
# end
|
|
111
|
-
|
|
111
|
+
|
|
112
112
|
it "no template" do
|
|
113
113
|
lambda{render('/non-existing-template')}.should raise_error(/no template/)
|
|
114
114
|
end
|
|
115
|
-
|
|
115
|
+
|
|
116
116
|
it "should render arbitrary file" do
|
|
117
117
|
render(file: "#{spec_dir}/file.erb").should == "file template"
|
|
118
118
|
end
|
|
119
119
|
end
|
|
120
|
-
|
|
120
|
+
|
|
121
121
|
describe 'format' do
|
|
122
122
|
it "basic" do
|
|
123
123
|
render('/format/format', format: 'html', prefixes: [''], exact_format: true).should == "html format"
|
|
@@ -126,16 +126,16 @@ Yield: content for :content}
|
|
|
126
126
|
render('/format/format.html', format: 'js', prefixes: [''], exact_format: true).should == "html format"
|
|
127
127
|
render('/format/format.html.erb', format: 'js', prefixes: [''], exact_format: true).should == "html format"
|
|
128
128
|
end
|
|
129
|
-
|
|
129
|
+
|
|
130
130
|
it "nesting different formats" do
|
|
131
131
|
render('/nesting_format/dialog', format: 'js', prefixes: [''], exact_format: true).should == %(rad.dialog().show("dialog, dialog form"))
|
|
132
132
|
end
|
|
133
|
-
|
|
133
|
+
|
|
134
134
|
it "should not force format for partials (if :action not specified)" do
|
|
135
135
|
render('/format_for_partials/dialog', format: 'js', prefixes: [''], exact_format: true).should == %(rad.dialog().show("dialog form"))
|
|
136
136
|
end
|
|
137
137
|
end
|
|
138
|
-
|
|
138
|
+
|
|
139
139
|
describe 'nested' do
|
|
140
140
|
it "should render relative templates" do
|
|
141
141
|
render('/nested/relative/a').should == "template a, template b"
|
|
@@ -143,17 +143,17 @@ Yield: content for :content}
|
|
|
143
143
|
current_dir = "#{spec_dir}/views/nested/relative"
|
|
144
144
|
render('b', current_dir: current_dir).should == "template b"
|
|
145
145
|
end
|
|
146
|
-
|
|
146
|
+
|
|
147
147
|
it "should render relative templates with complex path (../../xxx)" do
|
|
148
148
|
render('/nested/relative/c').should == "template c, shared template"
|
|
149
149
|
end
|
|
150
|
-
|
|
150
|
+
|
|
151
151
|
it "nested templates should use the same format" do
|
|
152
152
|
render('/nested/format/a', format: 'js').should == "b.js"
|
|
153
153
|
# render('/nested/format/a', format: 'html')
|
|
154
154
|
end
|
|
155
155
|
end
|
|
156
|
-
|
|
156
|
+
|
|
157
157
|
describe "layout" do
|
|
158
158
|
def render_with_layout path, options, layout
|
|
159
159
|
content, context = template.basic_render(template.parse_arguments(path, options))
|
|
@@ -168,23 +168,21 @@ Yield: content for :content}
|
|
|
168
168
|
end
|
|
169
169
|
end
|
|
170
170
|
end
|
|
171
|
-
|
|
171
|
+
|
|
172
172
|
it "templates and layout must share the same context" do
|
|
173
173
|
render_with_layout(
|
|
174
174
|
'/layout/same_context/a', {instance_variables: {ivariable: "ivariable"}},
|
|
175
175
|
'/layout/same_context/layout'
|
|
176
176
|
).should == "layout ivariable content a ivariable content b ivariable"
|
|
177
177
|
end
|
|
178
|
-
|
|
178
|
+
|
|
179
179
|
it "content_for" do
|
|
180
180
|
render_with_layout(
|
|
181
181
|
'/layout/content_for/content', {},
|
|
182
182
|
'/layout/content_for/layout'
|
|
183
183
|
).should == %{\
|
|
184
|
-
head
|
|
185
|
-
|
|
184
|
+
head
|
|
186
185
|
content
|
|
187
|
-
|
|
188
186
|
bottom}
|
|
189
187
|
end
|
|
190
188
|
|
|
@@ -194,7 +192,7 @@ bottom}
|
|
|
194
192
|
'/layout/basic/layout'
|
|
195
193
|
).should == "layotu begin content end"
|
|
196
194
|
end
|
|
197
|
-
|
|
195
|
+
|
|
198
196
|
it "layout with format" do
|
|
199
197
|
render_with_layout(
|
|
200
198
|
'/layout/format/content', {format: 'html'},
|
|
@@ -204,15 +202,15 @@ bottom}
|
|
|
204
202
|
render_with_layout(
|
|
205
203
|
'/layout/format/content', {format: 'js'},
|
|
206
204
|
'/layout/format/layout'
|
|
207
|
-
).should == "js layout begin js content end"
|
|
205
|
+
).should == "js layout begin js content end"
|
|
208
206
|
end
|
|
209
|
-
|
|
207
|
+
|
|
210
208
|
it "layout should support yield in partials (from error)" do
|
|
211
209
|
render_with_layout(
|
|
212
210
|
'/layout/nested_yield/a', {},
|
|
213
211
|
'/layout/nested_yield/layout'
|
|
214
212
|
).should == "some content"
|
|
215
|
-
end
|
|
213
|
+
end
|
|
216
214
|
end
|
|
217
|
-
|
|
215
|
+
|
|
218
216
|
end
|
data/spec/template/tilt_spec.rb
CHANGED
|
@@ -3,95 +3,95 @@ require 'spec_helper'
|
|
|
3
3
|
|
|
4
4
|
describe "Tilt" do
|
|
5
5
|
with_view_path "#{spec_dir}/views"
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
inject template: :template
|
|
8
|
-
|
|
8
|
+
|
|
9
9
|
def render *a, &b
|
|
10
10
|
template.render *a, &b
|
|
11
11
|
end
|
|
12
|
-
|
|
12
|
+
|
|
13
13
|
before :all do
|
|
14
14
|
class TemplateContextStub < Rad::Template::Context
|
|
15
|
-
def tag name, content = nil, &block
|
|
15
|
+
def tag name, content = nil, &block
|
|
16
16
|
if block_given?
|
|
17
17
|
content = capture(&block)
|
|
18
18
|
concat "<#{name}>#{content}</#{name}>"
|
|
19
19
|
else
|
|
20
20
|
content = content
|
|
21
21
|
"<#{name}>#{content}</#{name}>"
|
|
22
|
-
end
|
|
22
|
+
end
|
|
23
23
|
end
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
|
-
|
|
26
|
+
|
|
27
27
|
before do
|
|
28
28
|
$render_result = OpenObject.new
|
|
29
29
|
rad.mode = :development, true
|
|
30
30
|
end
|
|
31
31
|
after{rad.mode = :test, true}
|
|
32
|
-
|
|
32
|
+
|
|
33
33
|
it "haml should be ugly" do
|
|
34
34
|
render('/ugly.haml').should_not =~ /^\s/
|
|
35
35
|
end
|
|
36
|
-
|
|
36
|
+
|
|
37
37
|
it "should correctly show error lines" do
|
|
38
38
|
lambda{render('/errors.erb')}.should raise_error(/line with error/){|e| e.backtrace.first.should =~ /^.+errors\.erb:2.+$/}
|
|
39
39
|
lambda{render('/errors.haml')}.should raise_error(/line with error/){|e| e.backtrace.first.should =~ /^.+errors\.haml:2.+$/}
|
|
40
40
|
end
|
|
41
|
-
|
|
42
|
-
it "concat & capture" do
|
|
41
|
+
|
|
42
|
+
it "concat & capture" do
|
|
43
43
|
render('/concat_and_capture.erb').should =~ /^text for concatenation.?$/
|
|
44
44
|
$render_result.erb_capture.should =~ /^text for capturing.?$/
|
|
45
|
-
|
|
45
|
+
|
|
46
46
|
render('/concat_and_capture.haml').should =~ /^text for concatenation.?$/
|
|
47
47
|
$render_result.haml_capture.should =~ /^text for capturing.?$/
|
|
48
48
|
end
|
|
49
|
-
|
|
49
|
+
|
|
50
50
|
it "yield" do
|
|
51
51
|
render('/yield.erb'){|variable| "content for :#{variable}"}.should == "Layout, content for :content"
|
|
52
|
-
end
|
|
53
|
-
|
|
52
|
+
end
|
|
53
|
+
|
|
54
54
|
it "should render non-ASCII symbols (from error)" do
|
|
55
55
|
render('/encoding/erb').should =~ /»/
|
|
56
|
-
render('/encoding/haml').should =~ /»/
|
|
56
|
+
render('/encoding/haml').should =~ /»/
|
|
57
57
|
end
|
|
58
|
-
|
|
58
|
+
|
|
59
59
|
describe "mixed template types" do
|
|
60
60
|
it "broken haml concat (from error)" do
|
|
61
61
|
render(
|
|
62
62
|
'/mixed_templates/broken_haml_concat_haml',
|
|
63
63
|
context: TemplateContextStub.new
|
|
64
64
|
).gsub("\n", "").should == "<div>some content</div>"
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
render(
|
|
67
67
|
'/mixed_templates/broken_haml_concat_erb',
|
|
68
68
|
context: TemplateContextStub.new
|
|
69
69
|
).gsub("\n", "").should == "<div>some content</div>"
|
|
70
70
|
end
|
|
71
|
-
|
|
71
|
+
|
|
72
72
|
it "broken erb concat (from error)" do
|
|
73
73
|
render(
|
|
74
|
-
'/mixed_templates/broken_erb_concat_erb',
|
|
74
|
+
'/mixed_templates/broken_erb_concat_erb',
|
|
75
75
|
context: TemplateContextStub.new
|
|
76
76
|
).gsub("\n", "").should == "haml content<div>\tsome content</div>"
|
|
77
77
|
end
|
|
78
78
|
end
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
|
|
80
|
+
|
|
81
81
|
it "nested capture & concat (from error)" do
|
|
82
82
|
class TestTC < TemplateContextStub
|
|
83
83
|
def form_tag &block
|
|
84
84
|
html = capture &block
|
|
85
85
|
concat(tag(:form_tag, html))
|
|
86
86
|
end
|
|
87
|
-
|
|
87
|
+
|
|
88
88
|
def form_field &block
|
|
89
89
|
html = capture &block
|
|
90
90
|
concat(tag(:form_field, html))
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
|
-
|
|
94
|
-
render('/nested_capture_and_concat', context: TestTC.new).gsub("\n", '').should ==
|
|
93
|
+
|
|
94
|
+
render('/nested_capture_and_concat', context: TestTC.new).gsub("\n", '').should ==
|
|
95
95
|
"<form_tag><form_field>some field</form_field></form_tag>"
|
|
96
96
|
end
|
|
97
97
|
end
|
data/spec/web/basic_spec.rb
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
1
|
require 'spec_helper'
|
|
2
2
|
|
|
3
|
-
describe "Core" do
|
|
3
|
+
describe "Core" do
|
|
4
4
|
with_load_path spec_dir
|
|
5
5
|
isolate :conveyors, :router, before: :all
|
|
6
|
-
|
|
6
|
+
|
|
7
7
|
before :all do
|
|
8
8
|
rad.web
|
|
9
|
-
|
|
9
|
+
|
|
10
10
|
rad.router.routers = [
|
|
11
11
|
[:simple_router, Rad::Router::SimpleRouter.new]
|
|
12
12
|
]
|
|
13
13
|
end
|
|
14
|
-
|
|
15
|
-
after :all do
|
|
16
|
-
remove_constants %w(
|
|
14
|
+
|
|
15
|
+
after :all do
|
|
16
|
+
remove_constants %w(
|
|
17
17
|
SmokeTestSpec
|
|
18
18
|
JsonFormatSpec
|
|
19
19
|
RequestAndSessionSpec
|
|
20
20
|
FullUrl
|
|
21
21
|
)
|
|
22
22
|
end
|
|
23
|
-
|
|
24
|
-
it "smoke test" do
|
|
23
|
+
|
|
24
|
+
it "smoke test" do
|
|
25
25
|
class ::SmokeTestSpec
|
|
26
26
|
inherit Rad::Controller::Http
|
|
27
|
-
|
|
27
|
+
|
|
28
28
|
def action
|
|
29
29
|
respond_to do |format|
|
|
30
30
|
format.json{render json: {a: 'b'}}
|
|
@@ -32,24 +32,24 @@ describe "Core" do
|
|
|
32
32
|
end
|
|
33
33
|
end
|
|
34
34
|
end
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
wcall("/smoke_test_spec/action")
|
|
37
37
|
response.body.should == %(some content)
|
|
38
|
-
|
|
38
|
+
|
|
39
39
|
wcall("/smoke_test_spec/action", format: 'json')
|
|
40
|
-
response.body.should == %({"a":"b"})
|
|
40
|
+
response.body.should == %({"a":"b"})
|
|
41
41
|
end
|
|
42
|
-
|
|
42
|
+
|
|
43
43
|
it "full url (from error)" do
|
|
44
44
|
class ::FullUrl
|
|
45
45
|
inherit Rad::Controller::Http
|
|
46
|
-
|
|
46
|
+
|
|
47
47
|
def action
|
|
48
48
|
params.a.should == 'b'
|
|
49
49
|
render inline: 'ok'
|
|
50
50
|
end
|
|
51
51
|
end
|
|
52
|
-
|
|
52
|
+
|
|
53
53
|
wcall "http://localhost/full_url/action?a=b" do |c|
|
|
54
54
|
check = {
|
|
55
55
|
'PATH_INFO' => '/full_url/action',
|
|
@@ -60,42 +60,42 @@ describe "Core" do
|
|
|
60
60
|
end
|
|
61
61
|
response.body.should == %(ok)
|
|
62
62
|
end
|
|
63
|
-
|
|
63
|
+
|
|
64
64
|
it "json" do
|
|
65
65
|
class ::JsonFormatSpec
|
|
66
66
|
inherit Rad::Controller::Http
|
|
67
|
-
|
|
67
|
+
|
|
68
68
|
def action
|
|
69
69
|
render json: {a: 'b'}
|
|
70
70
|
end
|
|
71
71
|
end
|
|
72
|
-
|
|
72
|
+
|
|
73
73
|
wcall("/json_format_spec/action.json")
|
|
74
74
|
response.body.should == %({"a":"b"})
|
|
75
75
|
# response.rson.should == {'result' => 'value'}
|
|
76
76
|
end
|
|
77
|
-
|
|
77
|
+
|
|
78
78
|
it "should have workspace, request, env, and session" do
|
|
79
79
|
class ::RequestAndSessionSpec
|
|
80
80
|
inherit Rad::Controller::Http
|
|
81
|
-
|
|
81
|
+
|
|
82
82
|
inject workspace: :workspace
|
|
83
83
|
def action
|
|
84
84
|
workspace.should_not == nil
|
|
85
85
|
workspace.env.should_not == nil
|
|
86
86
|
request.should_not == nil
|
|
87
|
-
request.session.should_not == nil
|
|
88
|
-
|
|
87
|
+
request.session.should_not == nil
|
|
88
|
+
|
|
89
89
|
self.class.request_and_session_passed = true
|
|
90
|
-
|
|
90
|
+
|
|
91
91
|
render json: {a: 'b'}
|
|
92
92
|
end
|
|
93
|
-
|
|
93
|
+
|
|
94
94
|
class << self
|
|
95
95
|
attr_accessor :request_and_session_passed
|
|
96
96
|
end
|
|
97
97
|
end
|
|
98
|
-
|
|
98
|
+
|
|
99
99
|
wcall('/request_and_session_spec/action.json')
|
|
100
100
|
RequestAndSessionSpec.request_and_session_passed.should be_true
|
|
101
101
|
end
|