rad_core 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +4 -3
- data/lib/components/config.rb +6 -0
- data/lib/components/controller.rb +5 -0
- data/lib/components/controller.yml +3 -0
- data/lib/components/conveyors.rb +7 -0
- data/lib/components/environment.rb +5 -0
- data/lib/components/environment.yml +3 -0
- data/lib/components/flash.rb +5 -0
- data/lib/components/html.rb +4 -0
- data/lib/components/html.yml +3 -0
- data/lib/components/http.rb +6 -0
- data/lib/components/http.yml +13 -0
- data/lib/components/logger.rb +5 -0
- data/lib/components/mailer.rb +9 -0
- data/lib/components/remote.rb +4 -0
- data/lib/components/router.rb +13 -0
- data/lib/components/router.yml +2 -0
- data/lib/components/template.rb +8 -0
- data/lib/components/template.yml +1 -0
- data/lib/components/web.rb +8 -0
- data/lib/components/workspace.rb +1 -0
- data/lib/rad/{support → _support}/active_support/locales/en/actionpack.yml +0 -0
- data/lib/rad/{support → _support}/active_support/locales/en/activesupport.yml +0 -0
- data/lib/rad/_support/active_support/locales/ru/actionview.yml +162 -0
- data/lib/rad/_support/active_support/locales/ru/activesupport.yml +16 -0
- data/lib/rad/_support/active_support/locales/ru/datetime.yml +49 -0
- data/lib/rad/{support → _support}/active_support/micelaneous.rb +0 -0
- data/lib/rad/{support → _support}/active_support/time.rb +0 -0
- data/lib/rad/{support → _support}/active_support.rb +14 -2
- data/lib/rad/{support → _support}/addressable.rb +0 -0
- data/lib/rad/_support/callbacks.rb +166 -0
- data/lib/rad/_support/class_loader.rb +9 -0
- data/lib/rad/_support/encoding.rb +3 -0
- data/lib/rad/_support/exception.rb +45 -0
- data/lib/rad/_support/extensions.rb +20 -0
- data/lib/rad/_support/filters.rb +32 -0
- data/lib/rad/{support → _support}/hacks_and_fixes.rb +0 -0
- data/lib/rad/{support → _support}/mime.rb +6 -0
- data/lib/rad/{support → _support}/module.rb +7 -9
- data/lib/rad/_support/require.rb +62 -0
- data/lib/rad/{support → _support}/rson.rb +0 -0
- data/lib/rad/{support → _support}/ruby_ext_with_active_support.rb +0 -0
- data/lib/rad/{support → _support}/string.rb +9 -1
- data/lib/rad/controller/_abstract/micelaneous.rb +27 -0
- data/lib/rad/controller/_abstract/render.rb +159 -0
- data/lib/rad/controller/_abstract/responder.rb +13 -0
- data/lib/rad/controller/_abstract.rb +37 -0
- data/lib/rad/controller/_context.rb +15 -0
- data/lib/rad/controller/_http.rb +50 -0
- data/lib/rad/controller/_require.rb +19 -0
- data/lib/rad/controller/abstract.rb +1 -0
- data/lib/rad/controller/context.rb +1 -0
- data/lib/rad/controller/http.rb +1 -0
- data/lib/rad/controller/processors/controller_caller.rb +22 -24
- data/lib/rad/controller/processors/controller_error_handling.rb +46 -48
- data/lib/rad/controller/processors/controller_logger.rb +7 -9
- data/lib/rad/controller.rb +1 -28
- data/lib/rad/conveyors/_conveyor.rb +73 -0
- data/lib/rad/conveyors/_conveyors.rb +19 -0
- data/lib/rad/conveyors/_params.rb +10 -0
- data/lib/rad/conveyors/_processor.rb +13 -0
- data/lib/rad/conveyors/_require.rb +10 -0
- data/lib/rad/conveyors/_workspace.rb +34 -0
- data/lib/rad/conveyors/params.rb +1 -0
- data/lib/rad/conveyors/processor.rb +1 -0
- data/lib/rad/conveyors/processors/conveyor_logger.rb +23 -0
- data/lib/rad/conveyors/workspace.rb +1 -0
- data/lib/rad/conveyors.rb +1 -0
- data/lib/rad/core_web/_controller_micelaneous_helper.rb +17 -0
- data/lib/rad/core_web/_require.rb +25 -0
- data/lib/rad/core_web/_router/abstract_routing_helper.rb +20 -0
- data/lib/rad/core_web/_router/controller_routing_helper.rb +56 -0
- data/lib/rad/core_web/_router/view_routing_helper.rb +57 -0
- data/lib/rad/environment/_config.rb +27 -0
- data/lib/rad/environment/_environment.rb +17 -0
- data/lib/rad/environment/_files_helper.rb +55 -0
- data/lib/rad/environment/_logger.rb +53 -0
- data/lib/rad/environment/_require.rb +24 -0
- data/lib/rad/environment/config.rb +1 -111
- data/lib/rad/environment.rb +1 -55
- data/lib/{rad_core → rad}/gems.rb +2 -3
- data/lib/rad/html/_flash.rb +40 -0
- data/lib/rad/html/_helpers/basic_html_helper.rb +72 -0
- data/lib/rad/html/_helpers/flash_helper.rb +3 -0
- data/lib/rad/html/_helpers/form_helper.rb +114 -0
- data/lib/rad/html/_helpers/html_helper.rb +3 -0
- data/lib/rad/html/_helpers/javascript_helper.rb +27 -0
- data/lib/rad/html/_helpers/model_helper.rb +143 -0
- data/lib/rad/html/_require.rb +15 -0
- data/lib/rad/html/processors/prepare_flash.rb +22 -23
- data/lib/rad/html/processors/scoped_params.rb +18 -21
- data/lib/rad/html.rb +1 -26
- data/lib/rad/http/_http.rb +11 -0
- data/lib/rad/http/_http_adapter.rb +44 -0
- data/lib/rad/http/_request.rb +50 -0
- data/lib/rad/http/_require.rb +33 -0
- data/lib/rad/http/_response.rb +84 -0
- data/lib/rad/http/{support → _support}/rack/fixes.rb +0 -0
- data/lib/rad/http/_support/rack/rack_adapter.rb +57 -0
- data/lib/rad/http/processors/evaluate_format.rb +16 -19
- data/lib/rad/http/processors/http_logger.rb +10 -12
- data/lib/rad/http/processors/http_writer.rb +24 -26
- data/lib/rad/http/processors/prepare_params.rb +19 -18
- data/lib/rad/http/request.rb +1 -0
- data/lib/rad/http/response.rb +1 -0
- data/lib/rad/http.rb +1 -48
- data/lib/rad/mailer/_letter.rb +28 -0
- data/lib/rad/mailer/_mailer.rb +13 -0
- data/lib/rad/mailer/_mailer_controller.rb +38 -0
- data/lib/rad/mailer/_require.rb +7 -0
- data/lib/rad/mailer/mailer_controller.rb +1 -0
- data/lib/rad/mailer/processors/letter_builder.rb +34 -0
- data/lib/rad/mailer.rb +1 -0
- data/lib/rad/profiles/mailer.rb +5 -0
- data/lib/rad/profiles/web.rb +29 -52
- data/lib/rad/remote/_remote_controller.rb +9 -0
- data/lib/rad/remote/_require.rb +6 -0
- data/lib/rad/remote/processors/remote_caller.rb +44 -46
- data/lib/rad/remote/processors/remote_logger.rb +8 -10
- data/lib/rad/remote/remote_controller.rb +1 -0
- data/lib/rad/remote.rb +1 -9
- data/lib/rad/router/_abstract_router.rb +50 -0
- data/lib/rad/router/_alias_router.rb +124 -0
- data/lib/rad/router/_basic_router.rb +72 -0
- data/lib/rad/router/_configurator.rb +19 -0
- data/lib/rad/router/_core_routing_helper.rb +39 -0
- data/lib/rad/router/_default_format_processor.rb +10 -0
- data/lib/rad/router/_object_router.rb +184 -0
- data/lib/rad/router/_require.rb +31 -0
- data/lib/rad/router/_restful_router.rb +124 -0
- data/lib/rad/router/_router.rb +294 -0
- data/lib/rad/router/_simple_router.rb +21 -0
- data/lib/rad/router/abstract_router.rb +1 -0
- data/lib/rad/router/alias_router.rb +1 -0
- data/lib/rad/router/configurator.rb +1 -0
- data/lib/rad/router/micelaneous_router.rb +1 -0
- data/lib/rad/router/object_router.rb +1 -0
- data/lib/rad/router/processors/router.rb +23 -0
- data/lib/rad/router/restful_router.rb +1 -0
- data/lib/rad/{html/include_into_controller.rb → router/simple_router.rb} +0 -0
- data/lib/rad/router.rb +1 -29
- data/lib/rad/spec/controller.rb +20 -11
- data/lib/rad/spec/environment.rb +22 -38
- data/lib/rad/spec/http.rb +13 -86
- data/lib/rad/spec/http_controller.rb +105 -0
- data/lib/rad/spec/mailer.rb +27 -0
- data/lib/rad/spec/remote.rb +2 -2
- data/lib/rad/spec/router.rb +9 -11
- data/lib/rad/spec/template.rb +8 -2
- data/lib/rad/spec/xhtml.rb +0 -2
- data/lib/rad/spec.rb +4 -2
- data/lib/rad/template/_context.rb +92 -0
- data/lib/rad/template/_relative_path_resolver.rb +8 -0
- data/lib/rad/template/_require.rb +15 -0
- data/lib/rad/template/{support → _support}/tilt.rb +0 -0
- data/lib/rad/template/{support → _support}/tilt_fixes.rb +0 -0
- data/lib/rad/template/_template.rb +175 -0
- data/lib/rad/template/template_context.rb +1 -62
- data/lib/rad/template.rb +1 -25
- data/lib/rad.rb +8 -0
- data/readme.md +40 -12
- data/spec/controller/{abstract_controller_spec → abstract_spec}/views/OperationsOrderSpec/action.erb +0 -0
- data/spec/controller/{abstract_controller_spec → abstract_spec}/views/ViewVariablesSpec/action.erb +0 -0
- data/spec/controller/abstract_spec.rb +126 -0
- data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/NamespaceSpec/ClassSpec}/show.erb +0 -0
- data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/item_spec}/actions.erb +0 -0
- data/spec/controller/{controller_context_spec/views/NamespaceSpec/ClassSpec → context_spec/views/item_spec}/show.erb +0 -0
- data/spec/controller/{controller_context_spec/views/ItemSpec → context_spec/views/item_spec}/update.erb +0 -0
- data/spec/controller/{controller_context_spec → context_spec}/views/namespace_spec/class_spec/update.erb +0 -0
- data/spec/controller/{controller_context_spec/views/PageSpec → context_spec/views/page_spec}/actions.erb +0 -0
- data/spec/controller/{controller_context_spec/views/PageSpec → context_spec/views/page_spec}/show.erb +0 -0
- data/spec/controller/context_spec.rb +123 -0
- data/spec/controller/error_handling_spec.rb +21 -27
- data/spec/controller/{controller_helper_spec → helper_spec}/views/HelperMethodSpec/action.erb +0 -0
- data/spec/controller/{controller_helper_spec → helper_spec}/views/HelperSpec/action.erb +0 -0
- data/spec/controller/{controller_helper_spec.rb → helper_spec.rb} +7 -13
- data/spec/controller/{http_controller_spec.rb → http_spec.rb} +17 -23
- data/spec/controller/{controller_render_spec/views/AlreadyRenderedSpec → render_spec/views/already_rendered_spec}/action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/AlreadyRenderedSpec → render_spec/views/already_rendered_spec}/custom_template.erb +0 -0
- data/spec/controller/{controller_render_spec/views/AnotherActionSpec → render_spec/views/another_action_spec}/another_action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/AnotherLayout → render_spec/views/another_layout}/action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/ForbidPartialAsActionSpec → render_spec/views/forbid_partial_as_action_spec}/_action.erb +0 -0
- data/spec/controller/{controller_render_spec/views/FormatSpec → render_spec/views/format_spec}/action.html.erb +0 -0
- data/spec/controller/{controller_render_spec/views/FormatSpec → render_spec/views/format_spec}/action.js.erb +0 -0
- data/spec/controller/{controller_render_spec/views/LayoutFiltersSpec → render_spec/views/layout_filters_spec}/action_with_layout.erb +0 -0
- data/spec/controller/{controller_render_spec/views/LayoutFiltersSpec → render_spec/views/layout_filters_spec}/action_without_layout.erb +0 -0
- data/spec/controller/{controller_render_spec/views/LayoutSpec → render_spec/views/layout_spec}/action.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/layouts/admin.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/layouts/app.html.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/layouts/app.js.erb +0 -0
- data/spec/controller/{controller_render_spec/views/MultipleActions → render_spec/views/multiple_actions}/actions.haml +0 -0
- data/spec/controller/render_spec/views/relative_spec/a/form.erb +1 -0
- data/spec/controller/render_spec/views/relative_spec/a/show.erb +1 -0
- data/spec/controller/render_spec/views/relative_spec/b/form.erb +1 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/some_template.erb +0 -0
- data/spec/controller/{controller_render_spec → render_spec}/views/standalone.html.erb +0 -0
- data/spec/controller/{controller_render_spec.rb → render_spec.rb} +37 -27
- data/spec/{conveyor/conveyor_spec.rb → conveyors/conveyors_spec.rb} +36 -14
- data/spec/environment/config_spec.rb +13 -21
- data/spec/environment/environment_spec.rb +14 -41
- data/spec/environment/logger_spec.rb +4 -13
- data/spec/environment/minimal_app_spec/app.rb +1 -1
- data/spec/environment/minimal_app_spec.rb +12 -14
- data/spec/environment/standard_app_spec/app/lib/app/init.rb +1 -1
- data/spec/environment/standard_app_spec/plugin_a/lib/plugin_a/init.rb +1 -1
- data/spec/environment/standard_app_spec.rb +17 -25
- data/spec/html/basic_html_helper_spec.rb +7 -4
- data/spec/html/form_helper_spec.rb +5 -5
- data/spec/html/javascript_helper_spec.rb +9 -5
- data/spec/html/model_helper_spec.rb +9 -6
- data/spec/html/scoped_params_spec.rb +2 -2
- data/spec/html/spec_helper.rb +16 -24
- data/spec/http/http_spec.rb +14 -35
- data/spec/http/micelaneous_spec.rb +3 -3
- data/spec/{mail → mailer}/mail_controller_spec/views/body_template_spec/signup.erb +0 -0
- data/spec/{mail → mailer}/mail_controller_spec.rb +36 -12
- data/spec/mailer/spec_helper.rb +5 -0
- data/spec/remote/remote_spec.rb +23 -8
- data/spec/router/alias_router_spec.rb +29 -30
- data/spec/router/basic_router_spec.rb +44 -0
- data/spec/router/configurator_spec.rb +9 -6
- data/spec/router/integration_spec.rb +10 -7
- data/spec/router/object_router_spec.rb +186 -0
- data/spec/router/persistent_params_spec.rb +4 -4
- data/spec/router/restful_router_spec.rb +61 -53
- data/spec/router/{basic_spec.rb → router_spec.rb} +26 -23
- data/spec/router/routing_helper_spec.rb +5 -6
- data/spec/spec_helper.rb +4 -0
- data/spec/support/callbacks_spec.rb +1 -1
- data/spec/support/filters_spec.rb +2 -2
- data/spec/support/spec_helper.rb +1 -1
- data/spec/template/template_spec/views/format_for_partials/dialog.js.erb +1 -1
- data/spec/template/template_spec/views/nested/format/a.erb +1 -1
- data/spec/template/template_spec/views/nested/format/b.js.erb +1 -0
- data/spec/template/template_spec/views/nesting_format/dialog.js.erb +1 -1
- data/spec/template/template_spec.rb +62 -48
- data/spec/template/tilt_spec/views/concat_and_capture.erb +1 -1
- data/spec/template/tilt_spec/views/concat_and_capture.haml +1 -1
- data/spec/template/tilt_spec.rb +17 -19
- data/spec/{integration → web}/basic_spec/views/smoke_test_spec/action.erb +0 -0
- data/spec/{integration → web}/basic_spec.rb +31 -12
- data/spec/{integration → web}/controller_routing_helper_spec.rb +13 -11
- data/spec/{integration → web}/flash_spec.rb +57 -42
- data/spec/{integration → web}/spec_helper_spec.rb +11 -10
- data/spec/{integration → web}/view_routing_helper_spec.rb +44 -36
- metadata +338 -318
- data/lib/rad/controller/abstract_controller/micelaneous.rb +0 -31
- data/lib/rad/controller/abstract_controller/render.rb +0 -160
- data/lib/rad/controller/abstract_controller/responder.rb +0 -17
- data/lib/rad/controller/abstract_controller.rb +0 -64
- data/lib/rad/controller/controller_context.rb +0 -15
- data/lib/rad/controller/http_controller.rb +0 -48
- data/lib/rad/conveyor/conveyor.rb +0 -74
- data/lib/rad/conveyor/conveyors.rb +0 -20
- data/lib/rad/conveyor/params.rb +0 -14
- data/lib/rad/conveyor/processor.rb +0 -68
- data/lib/rad/conveyor/processors/conveyor_logger.rb +0 -25
- data/lib/rad/conveyor/workspace.rb +0 -36
- data/lib/rad/conveyor.rb +0 -29
- data/lib/rad/environment/dependency_resolver.rb +0 -107
- data/lib/rad/environment/environment.rb +0 -29
- data/lib/rad/environment/files_helper.rb +0 -55
- data/lib/rad/environment/logger.rb +0 -21
- data/lib/rad/html/flash.rb +0 -42
- data/lib/rad/html/helpers/basic_html_helper.rb +0 -83
- data/lib/rad/html/helpers/flash_helper.rb +0 -5
- data/lib/rad/html/helpers/form_helper.rb +0 -115
- data/lib/rad/html/helpers/html_helper.rb +0 -5
- data/lib/rad/html/helpers/javascript_helper.rb +0 -18
- data/lib/rad/html/helpers/model_helper.rb +0 -135
- data/lib/rad/http/http.rb +0 -21
- data/lib/rad/http/http_adapter.rb +0 -36
- data/lib/rad/http/middleware/static_files.rb +0 -21
- data/lib/rad/http/support/rack/rack_adapter.rb +0 -67
- data/lib/rad/http/support/rack/request.rb +0 -42
- data/lib/rad/http/support/rack/response.rb +0 -86
- data/lib/rad/integration/controller_micelaneous_helper.rb +0 -19
- data/lib/rad/integration/router/abstract_routing_helper.rb +0 -22
- data/lib/rad/integration/router/controller_routing_helper.rb +0 -58
- data/lib/rad/integration/router/view_routing_helper.rb +0 -104
- data/lib/rad/integration.rb +0 -30
- data/lib/rad/mail/letter.rb +0 -30
- data/lib/rad/mail/mail_controller.rb +0 -31
- data/lib/rad/mail/mailer.rb +0 -23
- data/lib/rad/mail/processors/letter_builder.rb +0 -36
- data/lib/rad/mail.rb +0 -15
- data/lib/rad/profiles/mail.rb +0 -16
- data/lib/rad/profiles/web_require.rb +0 -5
- data/lib/rad/remote/remote.rb +0 -15
- data/lib/rad/router/core/configurator.rb +0 -25
- data/lib/rad/router/core/core_routing_helper.rb +0 -41
- data/lib/rad/router/core/default_format_processor.rb +0 -12
- data/lib/rad/router/core/processors/router.rb +0 -29
- data/lib/rad/router/core/router.rb +0 -271
- data/lib/rad/router/core/simple_router.rb +0 -23
- data/lib/rad/router/routers/abstract_router.rb +0 -62
- data/lib/rad/router/routers/alias_router.rb +0 -113
- data/lib/rad/router/routers/restful_router.rb +0 -113
- data/lib/rad/spec/mail.rb +0 -31
- data/lib/rad/spec/view.rb +0 -10
- data/lib/rad/support/buffered_logger.rb +0 -44
- data/lib/rad/support/callbacks.rb +0 -168
- data/lib/rad/support/exception.rb +0 -31
- data/lib/rad/support/filters.rb +0 -34
- data/lib/rad/support/format.rb +0 -17
- data/lib/rad/support/micon.rb +0 -13
- data/lib/rad/support.rb +0 -63
- data/lib/rad/template/template.rb +0 -250
- data/spec/controller/abstract_controller_spec.rb +0 -132
- data/spec/controller/controller_context_spec.rb +0 -123
- data/spec/controller/controller_render_spec/views/rem ExplicitRenderSpec/action.erb +0 -1
- data/spec/controller/controller_render_spec/views/rem ExplicitRenderSpec/another_action.erb +0 -1
- data/spec/controller/spec_helper.rb +0 -19
- data/spec/conveyor/spec_helper.rb +0 -3
- data/spec/environment/config_spec/config.default.yml +0 -3
- data/spec/environment/config_spec/config.development.yml +0 -3
- data/spec/environment/config_spec/config.yml +0 -5
- data/spec/environment/spec_helper.rb +0 -1
- data/spec/http/http_spec/app/lib/app/init.rb +0 -10
- data/spec/http/http_spec/app/runtime/public/emptygit +0 -0
- data/spec/http/http_spec/plugin_a/lib/plugin_a/init.rb +0 -0
- data/spec/http/http_spec/plugin_b/lib/plugin_b/init.rb +0 -5
- data/spec/http/http_spec/plugin_b/static/emptygit +0 -0
- data/spec/http/spec_helper.rb +0 -5
- data/spec/integration/spec_helper.rb +0 -5
- data/spec/mail/spec_helper.rb +0 -7
- data/spec/remote/spec_helper.rb +0 -17
- data/spec/router/spec_helper.rb +0 -20
- data/spec/template/spec_helper.rb +0 -6
- data/spec/template/template_spec/views/nested/format/b.erb +0 -1
data/lib/rad/router.rb
CHANGED
@@ -1,29 +1 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
%w(
|
4
|
-
configurator
|
5
|
-
simple_router
|
6
|
-
router
|
7
|
-
default_format_processor
|
8
|
-
|
9
|
-
core_routing_helper
|
10
|
-
|
11
|
-
processors/router
|
12
|
-
).each{|f| require "rad/router/core/#{f}"}
|
13
|
-
|
14
|
-
# {AliasRouter: 'alias_router', RestfulRouter: 'restful_router'}.each do |klass, path|
|
15
|
-
# Rad.autoload klass, "rad/router/routers/#{path}"
|
16
|
-
# end
|
17
|
-
%w(
|
18
|
-
abstract_router
|
19
|
-
alias_router
|
20
|
-
restful_router
|
21
|
-
).each{|f| require "rad/router/routers/#{f}"}
|
22
|
-
|
23
|
-
Rad::Config::DEFAULTS.merge!(
|
24
|
-
default_path: '/'
|
25
|
-
)
|
26
|
-
|
27
|
-
Rad.metaclass do
|
28
|
-
delegate :routes, to: Rad::Routes::Configurator
|
29
|
-
end
|
1
|
+
rad.router
|
data/lib/rad/spec/controller.rb
CHANGED
@@ -1,18 +1,16 @@
|
|
1
|
-
|
1
|
+
Rspec.configure do |config|
|
2
|
+
config.before :all do |context|
|
3
|
+
self.response, self.workspace = nil
|
4
|
+
end
|
5
|
+
end
|
2
6
|
|
3
7
|
rspec do
|
4
8
|
attr_accessor :response, :workspace
|
5
|
-
|
6
|
-
def self.with_controller
|
7
|
-
before :each do
|
8
|
-
self.response = nil
|
9
|
-
end
|
10
|
-
end
|
11
9
|
|
12
10
|
def ccall klass, method, params = {}, workspace_variables = {}, &block
|
13
|
-
self.response = Rad::Response.new
|
11
|
+
self.response = Rad::Http::Response.new
|
14
12
|
workspace_variables = {
|
15
|
-
class: klass, method_name: method, params: Rad::Params.new(params), response: response
|
13
|
+
class: klass, method_name: method, params: Rad::Conveyors::Params.new(params), response: response
|
16
14
|
}.merge(workspace_variables)
|
17
15
|
|
18
16
|
if block
|
@@ -25,16 +23,27 @@ rspec do
|
|
25
23
|
self.workspace = rad.conveyors.web.call workspace_variables
|
26
24
|
end
|
27
25
|
|
28
|
-
if
|
26
|
+
if klass and klass.name =~ /Http/
|
29
27
|
response.content_type.must_be.present
|
30
28
|
response.status.must_be.present
|
31
29
|
end
|
32
30
|
|
33
31
|
workspace.content
|
34
32
|
end
|
33
|
+
|
34
|
+
def self.with_abstract_controller
|
35
|
+
before do
|
36
|
+
rad.controller
|
37
|
+
|
38
|
+
rad.conveyors.web do |web|
|
39
|
+
web.use Rad::Controller::Processors::ControllerCaller
|
40
|
+
end
|
41
|
+
end
|
42
|
+
after{rad.reset :conveyors}
|
43
|
+
end
|
35
44
|
end
|
36
45
|
|
37
|
-
Rad::
|
46
|
+
Rad::Controller::Abstract.class_eval do
|
38
47
|
def render_ok
|
39
48
|
render inline: 'ok'
|
40
49
|
end
|
data/lib/rad/spec/environment.rb
CHANGED
@@ -1,51 +1,35 @@
|
|
1
1
|
require 'rspec_ext'
|
2
|
+
require 'micon/spec'
|
3
|
+
|
4
|
+
rad.mode = :test
|
5
|
+
rad.logger = Logger.new nil
|
6
|
+
rad.runtime_path = 'tmp', true
|
2
7
|
|
3
8
|
rspec do
|
4
|
-
def self.
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
old_metadata = Micon.metadata
|
9
|
-
Micon.swap_metadata old_metadata.deep_clone
|
10
|
-
end
|
9
|
+
def self.isolate *args
|
10
|
+
options = args.extract_options!
|
11
|
+
scope = options[:before] || :each
|
12
|
+
components = args.first.is_a?(Array) ? args.first : args
|
11
13
|
|
12
|
-
|
13
|
-
|
14
|
+
old = {}
|
15
|
+
before :all do
|
16
|
+
components.each do |name|
|
17
|
+
old[name] = rad[name]
|
18
|
+
end
|
14
19
|
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def self.with_environment options = {}, &block
|
18
|
-
options = options.to_openobject
|
19
|
-
runtime_dir = options.delete(:runtime_dir) || './tmp'
|
20
|
-
scope = options.delete(:before) || :each
|
21
|
-
environment = options.delete(:environment) || :test
|
22
|
-
raise "Invalid options :#{options.to_hash.keys.join(', :')}!" unless options.empty?
|
23
|
-
|
24
|
-
swap_metadata
|
25
20
|
|
26
21
|
before scope do
|
27
|
-
|
28
|
-
|
29
|
-
config.set! environment: environment, runtime_dir: runtime_dir
|
22
|
+
components.each do |name|
|
23
|
+
rad[name] = old[name].deep_clone
|
30
24
|
end
|
31
|
-
|
32
|
-
block.call if block
|
33
|
-
|
34
|
-
silence_logger!
|
35
|
-
# Rad.initialize_plugin runtime_dir, environment
|
36
25
|
end
|
37
|
-
|
26
|
+
|
38
27
|
after scope do
|
39
|
-
|
40
|
-
|
28
|
+
components.each do |name|
|
29
|
+
rad[name] = old[name].deep_clone
|
30
|
+
end
|
31
|
+
end
|
41
32
|
end
|
42
33
|
|
43
|
-
inject
|
44
|
-
config: :config,
|
45
|
-
logger: :logger
|
46
|
-
)
|
47
|
-
|
48
|
-
def silence_logger!
|
49
|
-
self.logger = Logger.new nil
|
50
|
-
end
|
34
|
+
inject environment: :environment, logger: :logger
|
51
35
|
end
|
data/lib/rad/spec/http.rb
CHANGED
@@ -1,93 +1,20 @@
|
|
1
|
-
require 'rad/spec/controller'
|
2
|
-
|
3
1
|
rspec do
|
4
|
-
def
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
def self.with_http
|
9
|
-
with_controller
|
10
|
-
|
11
|
-
before :all do
|
12
|
-
rad.before_scope :cycle do
|
13
|
-
if defined?(Rad::Processors) and defined?(Rad::Processors::PrepareParams)
|
14
|
-
rad.conveyors.web do |web|
|
15
|
-
web.definitions.delete_if{|pdef, args| pdef == Rad::Processors::PrepareParams}
|
16
|
-
web.build!
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
2
|
+
def self.with_prepare_params
|
3
|
+
before do
|
4
|
+
$with_prepare_params = true
|
20
5
|
end
|
21
|
-
end
|
22
|
-
|
23
|
-
WCALL_OPTIONS = [:controller]
|
24
|
-
attr_writer :wcall_options
|
25
|
-
def wcall_options; @wcall_options ||= {} end
|
26
|
-
|
27
|
-
def set_wcall options
|
28
|
-
invalid_options = options.keys - WCALL_OPTIONS
|
29
|
-
raise "Unsupported options #{invalid_options}!" unless invalid_options.empty?
|
30
6
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
def set_controller controller_class
|
35
|
-
set_wcall controller: controller_class
|
36
|
-
end
|
37
|
-
|
38
|
-
def self.set_controller &block
|
39
|
-
block.must_be.defined
|
40
|
-
before(:each){set_controller block.call}
|
41
|
-
end
|
42
|
-
|
43
|
-
def wcall *args, &block
|
44
|
-
workspace_variables, params = parse_wcall_arguments *args
|
45
|
-
ccall nil, nil, params, workspace_variables, &block
|
46
|
-
end
|
47
|
-
|
48
|
-
def post_wcall *args, &block
|
49
|
-
params = args.extract_options!
|
50
|
-
raise "_method variable already set!" if params.include?(:_method) or params.include?('_method')
|
51
|
-
wcall(*(args << params.merge(_method: 'post')), &block)
|
7
|
+
after do
|
8
|
+
$with_prepare_params = false
|
9
|
+
end
|
52
10
|
end
|
53
|
-
|
54
|
-
protected
|
55
|
-
def parse_wcall_arguments *args
|
56
|
-
# parsing params
|
57
|
-
params = args.extract_options!
|
58
|
-
first = args.first
|
11
|
+
end
|
59
12
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
workspace_variables[:class] = wcall_options[:controller] || raise("not defined wcall controller (use set_wcall controller: SomeController)!")
|
66
|
-
workspace_variables[:method_name] = first
|
67
|
-
workspace_variables.merge! args[1] if args.size > 1
|
68
|
-
elsif first.is_a?(Class) and args.size <= 3
|
69
|
-
workspace_variables[:path] = '/'
|
70
|
-
workspace_variables[:class] = args[0]
|
71
|
-
workspace_variables[:method_name] = args[1]
|
72
|
-
workspace_variables.merge! args[2] if args.size > 2
|
73
|
-
else
|
74
|
-
raise "Invalid input!"
|
75
|
-
end
|
76
|
-
|
77
|
-
# preparing environment
|
78
|
-
workspace_variables[:env] ||= {}
|
79
|
-
workspace_variables[:env].reverse_merge! Rad::HTTPAdapter.mock_environment
|
80
|
-
|
81
|
-
# setting request method
|
82
|
-
if request_method = params.delete(:_method) || params.delete('_method')
|
83
|
-
request_method = request_method.to_s.upcase
|
84
|
-
raise "invalid request method :#{request}" unless %w(GET POST PUT DELETE).include? request_method.
|
85
|
-
raise "REQUEST_METHOD variable already set!" if workspace_variables[:env].include? 'REQUEST_METHOD'
|
86
|
-
workspace_variables[:env]['REQUEST_METHOD'] = request_method
|
87
|
-
end
|
88
|
-
|
89
|
-
workspace_variables[:request] = Rad::Request.new(workspace_variables[:env])
|
90
|
-
|
91
|
-
return workspace_variables, params
|
13
|
+
rad.before_scope :cycle do
|
14
|
+
unless $with_prepare_params
|
15
|
+
rad.conveyors.web do |web|
|
16
|
+
web.definitions.delete_if{|pdef, args| pdef.name =~ /PrepareParams/}
|
17
|
+
web.build!
|
92
18
|
end
|
19
|
+
end
|
93
20
|
end
|
@@ -0,0 +1,105 @@
|
|
1
|
+
require 'rad/spec/controller'
|
2
|
+
|
3
|
+
Rspec.configure do |config|
|
4
|
+
config.after :all do |context|
|
5
|
+
context.wcall_options = {}
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
rspec do
|
10
|
+
def request
|
11
|
+
rad.workspace.request
|
12
|
+
end
|
13
|
+
|
14
|
+
# def self.with_http_controller options = {}
|
15
|
+
# scope = options[:before] || :all
|
16
|
+
# prepare_params = options[:prepare_params]
|
17
|
+
#
|
18
|
+
# with_controller options
|
19
|
+
#
|
20
|
+
# unless prepare_params
|
21
|
+
# before scope do
|
22
|
+
#
|
23
|
+
# end
|
24
|
+
# end
|
25
|
+
# end
|
26
|
+
|
27
|
+
WCALL_OPTIONS = [:controller]
|
28
|
+
attr_writer :wcall_options
|
29
|
+
def wcall_options; @wcall_options ||= {} end
|
30
|
+
|
31
|
+
def set_wcall options
|
32
|
+
invalid_options = options.keys - WCALL_OPTIONS
|
33
|
+
raise "Unsupported options #{invalid_options}!" unless invalid_options.empty?
|
34
|
+
|
35
|
+
self.wcall_options = options
|
36
|
+
end
|
37
|
+
|
38
|
+
def set_controller controller_class
|
39
|
+
@controller_class = controller_class
|
40
|
+
set_wcall controller: controller_class
|
41
|
+
end
|
42
|
+
|
43
|
+
def self.set_controller controller_class
|
44
|
+
before{set_controller controller_class}
|
45
|
+
end
|
46
|
+
|
47
|
+
def wcall *args, &block
|
48
|
+
workspace_variables, params = parse_wcall_arguments *args
|
49
|
+
ccall nil, nil, params, workspace_variables, &block
|
50
|
+
end
|
51
|
+
|
52
|
+
def post_wcall *args, &block
|
53
|
+
params = args.extract_options!
|
54
|
+
raise "_method variable already set!" if params.include?(:_method) or params.include?('_method')
|
55
|
+
wcall(*(args << params.merge(_method: 'post')), &block)
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
def parse_wcall_arguments *args
|
60
|
+
|
61
|
+
# parsing params
|
62
|
+
params = args.extract_options!
|
63
|
+
first = args.first
|
64
|
+
|
65
|
+
workspace_variables = {}
|
66
|
+
if args.size == 1 and first.is_a?(String) and first =~ /^\/|^http:/
|
67
|
+
if first =~ /^\//
|
68
|
+
workspace_variables[:path] = first
|
69
|
+
else
|
70
|
+
uri = Uri.parse first
|
71
|
+
workspace_variables[:path] = uri.path
|
72
|
+
workspace_variables[:params] = uri.query_values
|
73
|
+
workspace_variables[:env] = rad.http.mock_environment(first)
|
74
|
+
end
|
75
|
+
elsif (first.is_a?(String) or first.is_a?(Symbol)) and args.size <= 2
|
76
|
+
workspace_variables[:path] = '/'
|
77
|
+
workspace_variables[:class] = wcall_options[:controller] || raise("not defined wcall controller (use set_wcall controller: SomeController)!")
|
78
|
+
workspace_variables[:method_name] = first
|
79
|
+
workspace_variables.merge! args[1] if args.size > 1
|
80
|
+
elsif first.is_a?(Class) and args.size <= 3
|
81
|
+
workspace_variables[:path] = '/'
|
82
|
+
workspace_variables[:class] = args[0]
|
83
|
+
workspace_variables[:method_name] = args[1]
|
84
|
+
workspace_variables.merge! args[2] if args.size > 2
|
85
|
+
else
|
86
|
+
raise "Invalid input!"
|
87
|
+
end
|
88
|
+
|
89
|
+
# preparing environment
|
90
|
+
workspace_variables[:env] ||= {}
|
91
|
+
workspace_variables[:env].reverse_merge! rad.http.mock_environment
|
92
|
+
|
93
|
+
# setting request method
|
94
|
+
if request_method = params.delete(:_method) || params.delete('_method')
|
95
|
+
request_method = request_method.to_s.upcase
|
96
|
+
raise "invalid request method :#{request}" unless %w(GET POST PUT DELETE).include? request_method.
|
97
|
+
raise "REQUEST_METHOD variable already set!" if workspace_variables[:env].include? 'REQUEST_METHOD'
|
98
|
+
workspace_variables[:env]['REQUEST_METHOD'] = request_method
|
99
|
+
end
|
100
|
+
|
101
|
+
workspace_variables[:request] = Rad::Http::Request.new(workspace_variables[:env])
|
102
|
+
|
103
|
+
return workspace_variables, params
|
104
|
+
end
|
105
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Rad::MailerSpecHelper
|
2
|
+
def sent_letters
|
3
|
+
Rad::MailerSpecHelper.sent_letters
|
4
|
+
end
|
5
|
+
|
6
|
+
class << self
|
7
|
+
attr_accessor :sent_letters
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
rspec.include Rad::MailerSpecHelper
|
12
|
+
|
13
|
+
Rspec.configure do |config|
|
14
|
+
config.before do
|
15
|
+
Rad::MailerSpecHelper.sent_letters = []
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Rad::Mailer.class_eval do
|
20
|
+
def deliver letter
|
21
|
+
Rad::MailerSpecHelper.sent_letters << letter
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Mail.defaults do
|
26
|
+
delivery_method :test
|
27
|
+
end
|
data/lib/rad/spec/remote.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
require 'rad
|
1
|
+
require 'rad'
|
2
2
|
|
3
3
|
rspec do
|
4
4
|
def rcall klass, method, params = {}
|
5
5
|
rad.conveyors.services.call(
|
6
|
-
class: klass, method_name: method, params: Rad::Params.new(params)
|
6
|
+
class: klass, method_name: method, params: Rad::Conveyors::Params.new(params)
|
7
7
|
)
|
8
8
|
end
|
9
9
|
end
|
data/lib/rad/spec/router.rb
CHANGED
@@ -1,15 +1,13 @@
|
|
1
|
-
|
1
|
+
rspec.include Rad::Router::CoreRoutingHelper
|
2
2
|
|
3
|
-
rspec do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
#
|
10
|
-
#
|
11
|
-
# headers['Location'].blank?
|
12
|
-
# end
|
3
|
+
# rspec do
|
4
|
+
# def self.with_router options = {}
|
5
|
+
# scope = options[:before] || :all
|
6
|
+
#
|
7
|
+
# before scope do
|
8
|
+
#
|
9
|
+
# end
|
10
|
+
# end
|
13
11
|
# end
|
14
12
|
|
15
13
|
rspec.define_matcher :redirect_to do |actual, expected|
|
data/lib/rad/spec/template.rb
CHANGED
@@ -6,7 +6,13 @@ rspec do
|
|
6
6
|
args
|
7
7
|
end
|
8
8
|
|
9
|
-
before
|
10
|
-
|
9
|
+
before do
|
10
|
+
rad.template
|
11
|
+
list.each{|path| rad.template.paths << path}
|
12
|
+
end
|
13
|
+
|
14
|
+
after do
|
15
|
+
list.each{|path| rad.template.paths.delete path}
|
16
|
+
end
|
11
17
|
end
|
12
18
|
end
|
data/lib/rad/spec/xhtml.rb
CHANGED
data/lib/rad/spec.rb
CHANGED
@@ -0,0 +1,92 @@
|
|
1
|
+
class Rad::Template::Context
|
2
|
+
include Tilt::CompileSite, Tilt::ContextExt
|
3
|
+
|
4
|
+
#
|
5
|
+
# System
|
6
|
+
#
|
7
|
+
attr_accessor :_tilt_template
|
8
|
+
|
9
|
+
def initialize instance_variables = nil
|
10
|
+
set_instance_variables! instance_variables if instance_variables
|
11
|
+
end
|
12
|
+
|
13
|
+
# for saving :format, :current_dir and others
|
14
|
+
attr_accessor :scope_variables
|
15
|
+
|
16
|
+
|
17
|
+
#
|
18
|
+
# Helpers
|
19
|
+
#
|
20
|
+
inject(
|
21
|
+
workspace: :workspace,
|
22
|
+
router: :router,
|
23
|
+
template: :template,
|
24
|
+
logger: :logger
|
25
|
+
)
|
26
|
+
|
27
|
+
delegate :render, to: :template
|
28
|
+
delegate :url_for, to: :router
|
29
|
+
|
30
|
+
|
31
|
+
def j obj
|
32
|
+
obj.to_s.json_escape
|
33
|
+
end
|
34
|
+
|
35
|
+
def blank? obj
|
36
|
+
obj.is_a?(String) ? !!(obj =~ /\A\s*\z/) : obj.blank?
|
37
|
+
end
|
38
|
+
def present? obj
|
39
|
+
!blank?(obj)
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
#
|
44
|
+
# Content Variables
|
45
|
+
#
|
46
|
+
attr_accessor :content_block
|
47
|
+
def content_variables; @content_variables ||= {}.to_openobject end
|
48
|
+
def content_for name, content = nil, &block
|
49
|
+
content ||= capture(&block)
|
50
|
+
(content_variables[name.to_s] ||= "") << content
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
def prepend_to name, content = nil, &block
|
54
|
+
content ||= capture(&block)
|
55
|
+
(content_variables[name.to_s] ||= "").insert 0, content
|
56
|
+
nil
|
57
|
+
end
|
58
|
+
def wrap_content_for name, &block
|
59
|
+
block.must_be.defined
|
60
|
+
content = capture((content_variables[name.to_s] || ""), &block)
|
61
|
+
content_variables[name.to_s] ||= content
|
62
|
+
nil
|
63
|
+
end
|
64
|
+
def has_content_for? name
|
65
|
+
content_variables.include? name.to_s
|
66
|
+
end
|
67
|
+
|
68
|
+
def params
|
69
|
+
workspace.params
|
70
|
+
end
|
71
|
+
|
72
|
+
def find_relative_template *args
|
73
|
+
self.class.find_relative_template *args
|
74
|
+
end
|
75
|
+
|
76
|
+
protected
|
77
|
+
def set_instance_variables! instance_variables
|
78
|
+
instance_variables = [instance_variables] unless instance_variables.is_a? Array
|
79
|
+
instance_variables.each do |container|
|
80
|
+
if container.is_a? Hash
|
81
|
+
container.each do |name, value|
|
82
|
+
instance_variable_set("@#{name}", value)
|
83
|
+
end
|
84
|
+
else
|
85
|
+
container.instance_variables.each do |ivname|
|
86
|
+
iv = container.instance_variable_get(ivname)
|
87
|
+
instance_variable_set(ivname, iv)
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
class Rad::Template::RelativePathResolver
|
2
|
+
def find_relative_template tname, prefixes, format, exact_format, current_dir
|
3
|
+
raise "You can't use relative template path '#{tname}' without :current_dir!" unless current_dir
|
4
|
+
prefixes = prefixes || rad.template.prefixes
|
5
|
+
rad.template.find_file("/#{tname}", prefixes, format, exact_format, [current_dir])
|
6
|
+
end
|
7
|
+
cache_method_with_params_in_production :find_relative_template
|
8
|
+
end
|
File without changes
|
File without changes
|