merb-core 0.9.7 → 0.9.8
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +136 -2
- data/CONTRIBUTORS +6 -0
- data/PUBLIC_CHANGELOG +38 -0
- data/Rakefile +38 -30
- data/lib/merb-core.rb +88 -23
- data/lib/merb-core/bootloader.rb +235 -51
- data/lib/merb-core/config.rb +121 -36
- data/lib/merb-core/controller/abstract_controller.rb +59 -36
- data/lib/merb-core/controller/exceptions.rb +2 -15
- data/lib/merb-core/controller/merb_controller.rb +44 -1
- data/lib/merb-core/controller/mime.rb +4 -0
- data/lib/merb-core/controller/mixins/controller.rb +38 -21
- data/lib/merb-core/controller/mixins/render.rb +44 -29
- data/lib/merb-core/controller/mixins/responder.rb +3 -31
- data/lib/merb-core/controller/template.rb +45 -21
- data/lib/merb-core/core_ext/kernel.rb +60 -32
- data/lib/merb-core/dispatch/default_exception/default_exception.rb +2 -2
- data/lib/merb-core/dispatch/default_exception/views/_css.html.erb +3 -1
- data/lib/merb-core/dispatch/default_exception/views/_javascript.html.erb +71 -67
- data/lib/merb-core/dispatch/default_exception/views/index.html.erb +7 -3
- data/lib/merb-core/dispatch/dispatcher.rb +3 -3
- data/lib/merb-core/dispatch/request.rb +56 -9
- data/lib/merb-core/dispatch/router.rb +159 -133
- data/lib/merb-core/dispatch/router/behavior.rb +462 -703
- data/lib/merb-core/dispatch/router/cached_proc.rb +3 -3
- data/lib/merb-core/dispatch/router/resources.rb +289 -0
- data/lib/merb-core/dispatch/router/route.rb +514 -294
- data/lib/merb-core/dispatch/session.rb +4 -2
- data/lib/merb-core/logger.rb +213 -202
- data/lib/merb-core/plugins.rb +9 -1
- data/lib/merb-core/rack.rb +3 -1
- data/lib/merb-core/rack/adapter.rb +7 -4
- data/lib/merb-core/rack/adapter/abstract.rb +188 -0
- data/lib/merb-core/rack/adapter/ebb.rb +12 -13
- data/lib/merb-core/rack/adapter/evented_mongrel.rb +2 -15
- data/lib/merb-core/rack/adapter/irb.rb +3 -2
- data/lib/merb-core/rack/adapter/mongrel.rb +22 -15
- data/lib/merb-core/rack/adapter/swiftiplied_mongrel.rb +4 -16
- data/lib/merb-core/rack/adapter/thin.rb +21 -22
- data/lib/merb-core/rack/adapter/thin_turbo.rb +4 -11
- data/lib/merb-core/rack/adapter/webrick.rb +54 -18
- data/lib/merb-core/rack/application.rb +4 -4
- data/lib/merb-core/rack/handler/mongrel.rb +12 -13
- data/lib/merb-core/rack/middleware/csrf.rb +1 -1
- data/lib/merb-core/rack/stream_wrapper.rb +41 -0
- data/lib/merb-core/server.rb +157 -90
- data/lib/merb-core/tasks/gem_management.rb +267 -0
- data/lib/merb-core/tasks/merb.rb +1 -0
- data/lib/merb-core/tasks/merb_rake_helper.rb +48 -34
- data/lib/merb-core/tasks/stats.rake +1 -1
- data/lib/merb-core/test.rb +9 -3
- data/lib/merb-core/test/helpers.rb +1 -0
- data/lib/merb-core/test/helpers/mock_request_helper.rb +393 -0
- data/lib/merb-core/test/helpers/multipart_request_helper.rb +3 -2
- data/lib/merb-core/test/helpers/request_helper.rb +40 -372
- data/lib/merb-core/test/helpers/route_helper.rb +16 -2
- data/lib/merb-core/test/matchers.rb +1 -0
- data/lib/merb-core/test/matchers/controller_matchers.rb +4 -247
- data/lib/merb-core/test/matchers/request_matchers.rb +140 -0
- data/lib/merb-core/test/matchers/view_matchers.rb +22 -4
- data/lib/merb-core/test/run_specs.rb +118 -26
- data/lib/merb-core/test/test_ext/rspec.rb +181 -0
- data/lib/merb-core/version.rb +1 -9
- metadata +10 -342
- data/docs/bootloading.dox +0 -58
- data/docs/documentation_standards +0 -40
- data/docs/merb-core-call-stack-diagram.mmap +0 -0
- data/docs/merb-core-call-stack-diagram.pdf +0 -0
- data/docs/merb-core-call-stack-diagram.png +0 -0
- data/docs/new_render_api +0 -51
- data/lib/merb-core/vendor/facets.rb +0 -2
- data/lib/merb-core/vendor/facets/dictionary.rb +0 -433
- data/lib/merb-core/vendor/facets/inflect.rb +0 -342
- data/spec/private/config/adapter_spec.rb +0 -32
- data/spec/private/config/config_spec.rb +0 -202
- data/spec/private/config/environment_spec.rb +0 -13
- data/spec/private/config/merb_spec.rb +0 -34
- data/spec/private/config/spec_helper.rb +0 -1
- data/spec/private/core_ext/kernel_spec.rb +0 -159
- data/spec/private/dispatch/bootloader_spec.rb +0 -24
- data/spec/private/dispatch/fixture/app/controllers/application.rb +0 -4
- data/spec/private/dispatch/fixture/app/controllers/exceptions.rb +0 -25
- data/spec/private/dispatch/fixture/app/controllers/foo.rb +0 -19
- data/spec/private/dispatch/fixture/app/helpers/global_helpers.rb +0 -8
- data/spec/private/dispatch/fixture/app/views/exeptions/client_error.html.erb +0 -37
- data/spec/private/dispatch/fixture/app/views/exeptions/internal_server_error.html.erb +0 -216
- data/spec/private/dispatch/fixture/app/views/exeptions/not_acceptable.html.erb +0 -38
- data/spec/private/dispatch/fixture/app/views/exeptions/not_found.html.erb +0 -40
- data/spec/private/dispatch/fixture/app/views/foo/bar.html.erb +0 -0
- data/spec/private/dispatch/fixture/app/views/layout/application.html.erb +0 -11
- data/spec/private/dispatch/fixture/config/black_hole.rb +0 -12
- data/spec/private/dispatch/fixture/config/environments/development.rb +0 -6
- data/spec/private/dispatch/fixture/config/environments/production.rb +0 -5
- data/spec/private/dispatch/fixture/config/environments/test.rb +0 -6
- data/spec/private/dispatch/fixture/config/init.rb +0 -45
- data/spec/private/dispatch/fixture/config/rack.rb +0 -11
- data/spec/private/dispatch/fixture/config/router.rb +0 -35
- data/spec/private/dispatch/fixture/log/merb_test.log +0 -8839
- data/spec/private/dispatch/fixture/public/images/merb.jpg +0 -0
- data/spec/private/dispatch/fixture/public/merb.fcgi +0 -4
- data/spec/private/dispatch/fixture/public/stylesheets/master.css +0 -119
- data/spec/private/dispatch/route_params_spec.rb +0 -23
- data/spec/private/dispatch/spec_helper.rb +0 -1
- data/spec/private/router/behavior_spec.rb +0 -60
- data/spec/private/router/fixture/log/merb_test.log +0 -35
- data/spec/private/router/route_spec.rb +0 -418
- data/spec/private/router/router_spec.rb +0 -183
- data/spec/private/vendor/facets/plural_spec.rb +0 -564
- data/spec/private/vendor/facets/singular_spec.rb +0 -489
- data/spec/public/DEFINITIONS +0 -11
- data/spec/public/abstract_controller/controllers/alt_views/layout/application.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_string_controller_layout.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/layout/merb/test/fixtures/abstract/render_template_controller_layout.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/display_object_with_multiple_roots/show.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/partial/basic_partial_with_multiple_roots/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_and_custom_location/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/alt_views/render_template_multiple_roots_inherited/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/cousins.rb +0 -41
- data/spec/public/abstract_controller/controllers/display.rb +0 -60
- data/spec/public/abstract_controller/controllers/filters.rb +0 -260
- data/spec/public/abstract_controller/controllers/helpers.rb +0 -41
- data/spec/public/abstract_controller/controllers/partial.rb +0 -121
- data/spec/public/abstract_controller/controllers/render.rb +0 -113
- data/spec/public/abstract_controller/controllers/views/helpers/capture/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/capture_eq/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/capture_with_args/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/helpers/concat/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/layout/alt.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/layout/custom.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/display_object_with_action/new.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_app_layout/index.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_custom_layout/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_template_multiple_roots/show.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/merb/test/fixtures/abstract/render_two_throw_contents/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/another_directory/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/basic_partial_with_multiple_roots/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_first.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/_second.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/nested_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_in_another_directory/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_both/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_as/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/_collection.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_collections_and_counter/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/_variables.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_locals/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/_both.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/partial_with_with_and_locals/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_absolute_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_as_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_nil_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/_with_partial.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/partial/with_partial/index.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/test_display/foo.html.erb +0 -1
- data/spec/public/abstract_controller/controllers/views/test_render/foo.html.erb +0 -0
- data/spec/public/abstract_controller/controllers/views/wonderful/index.erb +0 -1
- data/spec/public/abstract_controller/display_spec.rb +0 -37
- data/spec/public/abstract_controller/filter_spec.rb +0 -136
- data/spec/public/abstract_controller/helper_spec.rb +0 -21
- data/spec/public/abstract_controller/partial_spec.rb +0 -61
- data/spec/public/abstract_controller/render_spec.rb +0 -90
- data/spec/public/abstract_controller/spec_helper.rb +0 -31
- data/spec/public/boot_loader/boot_loader_spec.rb +0 -33
- data/spec/public/boot_loader/spec_helper.rb +0 -1
- data/spec/public/controller/authentication_spec.rb +0 -174
- data/spec/public/controller/base_spec.rb +0 -88
- data/spec/public/controller/conditional_get_spec.rb +0 -100
- data/spec/public/controller/config/init.rb +0 -6
- data/spec/public/controller/controllers/authentication.rb +0 -74
- data/spec/public/controller/controllers/base.rb +0 -65
- data/spec/public/controller/controllers/conditional_get.rb +0 -35
- data/spec/public/controller/controllers/cookies.rb +0 -36
- data/spec/public/controller/controllers/dispatcher.rb +0 -35
- data/spec/public/controller/controllers/display.rb +0 -118
- data/spec/public/controller/controllers/redirect.rb +0 -36
- data/spec/public/controller/controllers/responder.rb +0 -93
- data/spec/public/controller/controllers/url.rb +0 -7
- data/spec/public/controller/controllers/views/layout/custom.html.erb +0 -1
- data/spec/public/controller/controllers/views/layout/custom_arg.html.erb +0 -1
- data/spec/public/controller/controllers/views/layout/custom_arg.json.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_and_local_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/class_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template/no_layout.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/display_with_template_argument/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/html_default/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/layout/custom.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/local_provides/index.xml.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.html.erb +0 -1
- data/spec/public/controller/controllers/views/merb/test/fixtures/controllers/multi_provides/index.js.erb +0 -1
- data/spec/public/controller/cookies_spec.rb +0 -95
- data/spec/public/controller/dispatcher_spec.rb +0 -410
- data/spec/public/controller/display_spec.rb +0 -84
- data/spec/public/controller/redirect_spec.rb +0 -33
- data/spec/public/controller/responder_spec.rb +0 -169
- data/spec/public/controller/spec_helper.rb +0 -13
- data/spec/public/controller/url_spec.rb +0 -255
- data/spec/public/core/merb_core_spec.rb +0 -45
- data/spec/public/core_ext/fixtures/core_ext_dependency.rb +0 -2
- data/spec/public/core_ext/kernel_spec.rb +0 -88
- data/spec/public/core_ext/spec_helper.rb +0 -1
- data/spec/public/directory_structure/directory/app/controllers/application.rb +0 -3
- data/spec/public/directory_structure/directory/app/controllers/base.rb +0 -13
- data/spec/public/directory_structure/directory/app/controllers/custom.rb +0 -19
- data/spec/public/directory_structure/directory/app/views/base/template.html.erb +0 -1
- data/spec/public/directory_structure/directory/app/views/wonderful/template.erb +0 -1
- data/spec/public/directory_structure/directory/config/router.rb +0 -3
- data/spec/public/directory_structure/directory/log/merb_test.log +0 -4588
- data/spec/public/directory_structure/directory_spec.rb +0 -43
- data/spec/public/logger/logger_spec.rb +0 -181
- data/spec/public/logger/spec_helper.rb +0 -1
- data/spec/public/rack/conditinal_get_middleware_spec.rb +0 -127
- data/spec/public/rack/csrf_middleware_spec.rb +0 -70
- data/spec/public/rack/rack_middleware_spec.rb +0 -99
- data/spec/public/rack/shared_example_groups.rb +0 -35
- data/spec/public/reloading/directory/app/controllers/application.rb +0 -3
- data/spec/public/reloading/directory/app/controllers/reload.rb +0 -6
- data/spec/public/reloading/directory/config/init.rb +0 -2
- data/spec/public/reloading/directory/log/merb_test.log +0 -288231
- data/spec/public/reloading/reload_spec.rb +0 -103
- data/spec/public/request/multipart_spec.rb +0 -41
- data/spec/public/request/request_spec.rb +0 -250
- data/spec/public/router/default_spec.rb +0 -21
- data/spec/public/router/deferred_spec.rb +0 -22
- data/spec/public/router/fixation_spec.rb +0 -49
- data/spec/public/router/fixture/log/merb_test.log +0 -524
- data/spec/public/router/namespace_spec.rb +0 -113
- data/spec/public/router/nested_matches_spec.rb +0 -97
- data/spec/public/router/nested_resources_spec.rb +0 -41
- data/spec/public/router/resource_spec.rb +0 -37
- data/spec/public/router/resources_spec.rb +0 -82
- data/spec/public/router/spec_helper.rb +0 -90
- data/spec/public/router/special_spec.rb +0 -61
- data/spec/public/router/string_spec.rb +0 -61
- data/spec/public/session/controllers/sessions.rb +0 -56
- data/spec/public/session/cookie_session_spec.rb +0 -73
- data/spec/public/session/memcached_session_spec.rb +0 -31
- data/spec/public/session/memory_session_spec.rb +0 -28
- data/spec/public/session/multiple_sessions_spec.rb +0 -74
- data/spec/public/session/no_session_spec.rb +0 -12
- data/spec/public/session/session_spec.rb +0 -106
- data/spec/public/template/template_spec.rb +0 -104
- data/spec/public/template/templates/error.html.erb +0 -2
- data/spec/public/template/templates/template.html.erb +0 -1
- data/spec/public/template/templates/template.html.myt +0 -1
- data/spec/public/test/controller_matchers_spec.rb +0 -412
- data/spec/public/test/controllers/controller_assertion_mock.rb +0 -7
- data/spec/public/test/controllers/dispatch_controller.rb +0 -11
- data/spec/public/test/controllers/spec_helper_controller.rb +0 -39
- data/spec/public/test/multipart_request_helper_spec.rb +0 -159
- data/spec/public/test/multipart_upload_text_file.txt +0 -1
- data/spec/public/test/request_helper_spec.rb +0 -269
- data/spec/public/test/route_helper_spec.rb +0 -78
- data/spec/public/test/route_matchers_spec.rb +0 -166
- data/spec/public/test/view_helper_spec.rb +0 -96
- data/spec/public/test/view_matchers_spec.rb +0 -183
- data/spec/spec_helper.rb +0 -121
@@ -1,103 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
|
2
|
-
|
3
|
-
class MockTimedExecutor
|
4
|
-
def self.every(seconds, &block)
|
5
|
-
@@scheduled_action = block
|
6
|
-
end
|
7
|
-
def self.run_task
|
8
|
-
@@scheduled_action.call
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
RealTimedExecutor = Merb::BootLoader::ReloadClasses::TimedExecutor
|
13
|
-
Merb::BootLoader::ReloadClasses::TimedExecutor = MockTimedExecutor
|
14
|
-
|
15
|
-
Merb.start :environment => 'test',
|
16
|
-
:merb_root => File.dirname(__FILE__) / "directory"
|
17
|
-
|
18
|
-
describe "TimedExecutor" do
|
19
|
-
it "should call a block of code repeatedly in the background" do
|
20
|
-
list_of_things = []
|
21
|
-
|
22
|
-
RealTimedExecutor.every(0.1) do
|
23
|
-
list_of_things << "Something"
|
24
|
-
end
|
25
|
-
|
26
|
-
sleep 0.5
|
27
|
-
|
28
|
-
list_of_things.should_not be_empty
|
29
|
-
list_of_things.size.should > 1
|
30
|
-
end
|
31
|
-
|
32
|
-
end
|
33
|
-
|
34
|
-
describe "The reloader" do
|
35
|
-
|
36
|
-
before :all do
|
37
|
-
@reload_file = File.dirname(__FILE__) / "directory" / "app" / "controllers" / "reload.rb"
|
38
|
-
@text = <<-END
|
39
|
-
|
40
|
-
class Reloader < Application
|
41
|
-
end
|
42
|
-
|
43
|
-
class Hello < Application
|
44
|
-
end
|
45
|
-
END
|
46
|
-
update_file @text
|
47
|
-
MockTimedExecutor.run_task
|
48
|
-
end
|
49
|
-
|
50
|
-
def update_file(contents)
|
51
|
-
mtime = File.mtime(@reload_file)
|
52
|
-
f = File.open(@reload_file, "w") do |f|
|
53
|
-
f.puts contents
|
54
|
-
end
|
55
|
-
File.utime(mtime+30, mtime+30, @reload_file)
|
56
|
-
end
|
57
|
-
|
58
|
-
it "should reload files that were changed" do
|
59
|
-
defined?(Hello).should_not be_nil
|
60
|
-
defined?(Reloader).should_not be_nil
|
61
|
-
defined?(Reloader2).should be_nil
|
62
|
-
|
63
|
-
update_file <<-END
|
64
|
-
|
65
|
-
class Reloader < Application
|
66
|
-
end
|
67
|
-
|
68
|
-
class Reloader2
|
69
|
-
end
|
70
|
-
END
|
71
|
-
|
72
|
-
MockTimedExecutor.run_task
|
73
|
-
|
74
|
-
defined?(Hello).should be_nil
|
75
|
-
defined?(Reloader).should_not be_nil
|
76
|
-
defined?(Reloader2).should_not be_nil
|
77
|
-
end
|
78
|
-
|
79
|
-
it "should remove classes for _abstract_subclasses" do
|
80
|
-
|
81
|
-
update_file <<-END
|
82
|
-
|
83
|
-
class Reloader < Application
|
84
|
-
end
|
85
|
-
|
86
|
-
class Reloader2 < Application
|
87
|
-
end
|
88
|
-
END
|
89
|
-
|
90
|
-
MockTimedExecutor.run_task
|
91
|
-
|
92
|
-
Merb::AbstractController._abstract_subclasses.should include("Reloader")
|
93
|
-
Merb::AbstractController._abstract_subclasses.should include("Reloader2")
|
94
|
-
defined?(Hello).should be_nil
|
95
|
-
defined?(Reloader).should_not be_nil
|
96
|
-
defined?(Reloader2).should_not be_nil
|
97
|
-
end
|
98
|
-
|
99
|
-
after :each do
|
100
|
-
update_file @text
|
101
|
-
MockTimedExecutor.run_task
|
102
|
-
end
|
103
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
|
2
|
-
require "mongrel"
|
3
|
-
|
4
|
-
describe Merb::Request do
|
5
|
-
it "should handle file upload for multipart/form-data posts" do
|
6
|
-
file = Struct.new(:read, :filename, :path).
|
7
|
-
new("This is a text file with some small content in it.", "sample.txt", "sample.txt")
|
8
|
-
m = Merb::Test::MultipartRequestHelper::Post.new :file => file
|
9
|
-
body, head = m.to_multipart
|
10
|
-
request = fake_request({:request_method => "POST", :content_type => head, :content_length => body.length}, :req => body)
|
11
|
-
request.params[:file].should_not be_nil
|
12
|
-
request.params[:file][:tempfile].class.should == Tempfile
|
13
|
-
request.params[:file][:content_type].should == 'text/plain'
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should accept env['rack.input'] as IO object (instead of StringIO)" do
|
17
|
-
file = Struct.new(:read, :filename, :path).
|
18
|
-
new("This is a text file with some small content in it.", "sample.txt", "sample.txt")
|
19
|
-
m = Merb::Test::MultipartRequestHelper::Post.new :file => file
|
20
|
-
body, head = m.to_multipart
|
21
|
-
|
22
|
-
t = Tempfile.new("io")
|
23
|
-
t.write(body)
|
24
|
-
t.close
|
25
|
-
|
26
|
-
fd = IO.sysopen(t.path)
|
27
|
-
io = IO.for_fd(fd,"r")
|
28
|
-
request = Merb::Test::RequestHelper::FakeRequest.new({:request_method => "POST", :content_type => 'multipart/form-data, boundary=----------0xKhTmLbOuNdArY', :content_length => body.length},io)
|
29
|
-
|
30
|
-
running {request.params}.should_not raise_error
|
31
|
-
request.params[:file].should_not be_nil
|
32
|
-
request.params[:file][:tempfile].class.should == Tempfile
|
33
|
-
request.params[:file][:content_type].should == 'text/plain'
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should handle GET with a content_type but an empty body (happens in some browsers such as safari after redirect)" do
|
37
|
-
request = fake_request({:request_method => "GET", :content_type => 'multipart/form-data, boundary=----------0xKhTmLbOuNdArY', :content_length => 0}, :req => '')
|
38
|
-
running {request.params}.should_not raise_error
|
39
|
-
end
|
40
|
-
|
41
|
-
end
|
@@ -1,250 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
|
2
|
-
require "mongrel"
|
3
|
-
|
4
|
-
describe Merb::Request, "#method" do
|
5
|
-
|
6
|
-
[:get, :head, :put, :delete].each do |method|
|
7
|
-
it "should use the HTTP if it was a #{method.to_s.upcase}" do
|
8
|
-
fake_request(:request_method => method.to_s).method.should == method
|
9
|
-
end
|
10
|
-
|
11
|
-
it "should use the _method body params for #{method.to_s.upcase} when it came in as a POST" do
|
12
|
-
request = fake_request({:request_method => "POST"}, :post_body => "_method=#{method}")
|
13
|
-
request.method.should == method
|
14
|
-
end
|
15
|
-
|
16
|
-
it "should use the _method query params for #{method.to_s.upcase} when it came in as a POST" do
|
17
|
-
Merb::Request.parse_multipart_params = false
|
18
|
-
request = fake_request(:request_method => "POST", :query_string => "_method=#{method}")
|
19
|
-
request.method.should == method
|
20
|
-
end
|
21
|
-
|
22
|
-
[:get, :head, :put, :delete].each do |meth|
|
23
|
-
it "should return #{method == meth} when calling #{meth}? and the method is :#{method}" do
|
24
|
-
request = fake_request({:request_method => method.to_s})
|
25
|
-
request.send("#{meth}?").should == (method == meth)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
it "should not try to parse the request body as JSON on GET" do
|
31
|
-
request = fake_request({:request_method => "GET", :content_type => "application/json"}, :req => "")
|
32
|
-
lambda { request.params }.should_not raise_error(JSON::ParserError)
|
33
|
-
request.params.should == {}
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should return an empty hash when XML is not parsable" do
|
37
|
-
request = fake_request({:content_type => "application/xml"}, :req => '')
|
38
|
-
lambda { request.params }.should_not raise_error
|
39
|
-
request.params.should == {}
|
40
|
-
end
|
41
|
-
|
42
|
-
it "should default to POST if the _method is not defined" do
|
43
|
-
request = fake_request({:request_method => "POST"}, :post_body => "_method=zed")
|
44
|
-
request.method.should == :post
|
45
|
-
end
|
46
|
-
|
47
|
-
it "should raise an error if an unknown method is used" do
|
48
|
-
request = fake_request({:request_method => "foo"})
|
49
|
-
running {request.method}.should raise_error
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
describe Merb::Request, " query and body params" do
|
55
|
-
|
56
|
-
before(:all) { Merb::BootLoader::Dependencies.enable_json_gem }
|
57
|
-
|
58
|
-
TEST_PARAMS = {
|
59
|
-
"foo=bar&baz=bat" => {"foo" => "bar", "baz" => "bat"},
|
60
|
-
"foo=bar&foo=baz" => {"foo" => "baz"},
|
61
|
-
"foo[]=bar&foo[]=baz" => {"foo" => ["bar", "baz"]},
|
62
|
-
"foo[][bar]=1&foo[][bar]=2" => {"foo" => [{"bar" => "1"},{"bar" => "2"}]},
|
63
|
-
"foo[bar][][baz]=1&foo[bar][][baz]=2" => {"foo" => {"bar" => [{"baz" => "1"},{"baz" => "2"}]}},
|
64
|
-
"foo[1]=bar&foo[2]=baz" => {"foo" => {"1" => "bar", "2" => "baz"}},
|
65
|
-
|
66
|
-
"foo[bar][baz]=1&foo[bar][zot]=2&foo[bar][zip]=3&foo[bar][buz]=4" => {"foo" => {"bar" => {"baz" => "1", "zot" => "2", "zip" => "3", "buz" => "4"}}},
|
67
|
-
"foo[bar][][baz]=1&foo[bar][][zot]=2&foo[bar][][zip]=3&foo[bar][][buz]=4" => {"foo" => {"bar" => [{"baz" => "1", "zot" => "2", "zip" => "3", "buz" => "4"}]}},
|
68
|
-
"foo[bar][][baz]=1&foo[bar][][zot]=2&foo[bar][][baz]=3&foo[bar][][zot]=4" => {"foo" => {"bar" => [{"baz" => "1", "zot" => "2"},{"baz" => "3", "zot" => "4"}]}},
|
69
|
-
"foo[bar][][baz]=1&foo[bar][][zot]=2&foo[bar][][fuz]=A&foo[bar][][baz]=3&foo[bar][][zot]=4&foo[bar][][fuz]=B" => {"foo" => {"bar" => [{"baz" => "1", "zot" => "2", "fuz" => "A"},{"baz" => "3", "zot" => "4", "fuz" => "B"}]}},
|
70
|
-
"foo[bar][][baz]=1&foo[bar][][zot]=2&foo[bar][][fuz]=A&foo[bar][][baz]=3&foo[bar][][zot]=4&foo[bar][][foz]=C" => {"foo" => {"bar" => [{"baz" => "1", "zot" => "2", "fuz" => "A"},{"baz" => "3", "zot" => "4", "foz" => "C"}]}},
|
71
|
-
"foo[bar][][baz]=1&foo[bar][][zot]=2&foo[bar][][fuz]=A&foo[bar][][baz]=3&foo[bar][][zot]=4" => {"foo" => {"bar" => [{"baz" => "1", "zot" => "2", "fuz" => "A"},{"baz" => "3", "zot" => "4"}]}},
|
72
|
-
"foo[bar][][baz]=1&foo[bar][][zot]=2&foo[bar][][fuz]=A&foo[bar][][baz]=3&foo[bar][][zot]=4&foo[bar][][fuz]=B&foo[bar][][foz]=C" => {"foo" => {"bar" => [{"baz" => "1", "zot" => "2", "fuz" => "A"},{"baz" => "3", "zot" => "4", "fuz" => "B", "foz" => "C"}]}},
|
73
|
-
"foo[][bar][][baz]=1&foo[][bar][][zot]=2&foo[][bar][][fuz]=A&foo[][bar][][baz]=3&foo[][bar][][zot]=4&foo[][bar][][fuz]=B&foo[][bar][][foz]=C" => {"foo" => {"bar" => [{"baz" => "1", "zot" => "2", "fuz" => "A"},{"baz" => "3", "zot" => "4", "fuz" => "B", "foz" => "C"}]}}
|
74
|
-
}
|
75
|
-
|
76
|
-
TEST_PARAMS.each do |query, parse|
|
77
|
-
|
78
|
-
it "should convert #{query.inspect} to #{parse.inspect} in the query string" do
|
79
|
-
request = fake_request({:query_string => query})
|
80
|
-
request.params.should == parse
|
81
|
-
end
|
82
|
-
|
83
|
-
it "should convert #{query.inspect} to #{parse.inspect} in the post body" do
|
84
|
-
request = fake_request({}, :post_body => query)
|
85
|
-
request.params.should == parse
|
86
|
-
end
|
87
|
-
|
88
|
-
end
|
89
|
-
|
90
|
-
it "should support JSON params" do
|
91
|
-
request = fake_request({:content_type => "application/json"}, :req => %{{"foo": "bar"}})
|
92
|
-
request.params.should == {"foo" => "bar"}
|
93
|
-
end
|
94
|
-
|
95
|
-
it "should populated the inflated_object parameter if JSON params do not inflate to a hash" do
|
96
|
-
request = fake_request({:content_type => "application/json"}, :req => %{["foo", "bar"]})
|
97
|
-
request.params.should have_key(:inflated_object)
|
98
|
-
request.params[:inflated_object].should eql(["foo", "bar"])
|
99
|
-
end
|
100
|
-
|
101
|
-
it "should support XML params" do
|
102
|
-
request = fake_request({:content_type => "application/xml"}, :req => %{<foo bar="baz"><baz/></foo>})
|
103
|
-
request.params.should == {"foo" => {"baz" => nil, "bar" => "baz"}}
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
|
108
|
-
describe Merb::Request, "#remote_ip" do
|
109
|
-
it "should be able to get the remote IP of a request with X_FORWARDED_FOR" do
|
110
|
-
request = fake_request({:http_x_forwarded_for => "www.example.com"})
|
111
|
-
request.remote_ip.should == "www.example.com"
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should be able to get the remote IP when some of the X_FORWARDED_FOR are local" do
|
115
|
-
request = fake_request({:http_x_forwarded_for => "192.168.2.1,127.0.0.1,www.example.com"})
|
116
|
-
request.remote_ip.should == "www.example.com"
|
117
|
-
end
|
118
|
-
|
119
|
-
it "should be able to get the remote IP when it's in REMOTE_ADDR" do
|
120
|
-
request = fake_request({:remote_addr => "www.example.com"})
|
121
|
-
request.remote_ip.should == "www.example.com"
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
describe Merb::Request, "#cookies" do
|
126
|
-
|
127
|
-
it "should take cookies in the HTTP_COOKIE environment variable" do
|
128
|
-
request = fake_request({:http_cookie => "merb=canhascookie; version=1"})
|
129
|
-
request.cookies.should == {"merb" => "canhascookie", "version" => "1"}
|
130
|
-
end
|
131
|
-
|
132
|
-
it "should handle badly formatted cookies" do
|
133
|
-
request = fake_request({:http_cookie => "merb=; ; also=hats"})
|
134
|
-
request.cookies.should == {"merb" => "", "also" => "hats", "" => nil}
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
138
|
-
|
139
|
-
describe Merb::Request, " misc" do
|
140
|
-
|
141
|
-
it "should know if a request is an XHR" do
|
142
|
-
request = fake_request({:http_x_requested_with => "XMLHttpRequest"})
|
143
|
-
request.should be_xhr
|
144
|
-
end
|
145
|
-
|
146
|
-
it "should know if the protocol is http or https (when HTTPS is on)" do
|
147
|
-
request = fake_request({:https => "on"})
|
148
|
-
request.protocol.should == "https://"
|
149
|
-
request.should be_ssl
|
150
|
-
end
|
151
|
-
|
152
|
-
it "should know if the protocol is http or https (when HTTP_X_FORWARDED_PROTO is https)" do
|
153
|
-
request = fake_request({:http_x_forwarded_proto => "https"})
|
154
|
-
request.protocol.should == "https://"
|
155
|
-
request.should be_ssl
|
156
|
-
end
|
157
|
-
|
158
|
-
it "should know if the protocol is http or https (when it's regular HTTP)" do
|
159
|
-
request = fake_request({})
|
160
|
-
request.protocol.should == "http://"
|
161
|
-
end
|
162
|
-
|
163
|
-
it "should get the content-length" do
|
164
|
-
request = fake_request({:content_length => "300"})
|
165
|
-
request.content_length.should == 300
|
166
|
-
end
|
167
|
-
|
168
|
-
it "should be able to get the path from the URI (stripping trailing /)" do
|
169
|
-
request = fake_request({:request_uri => "foo/bar/baz/?bat"})
|
170
|
-
request.path.should == "foo/bar/baz"
|
171
|
-
end
|
172
|
-
|
173
|
-
it "should be able to get the path from the URI (joining multiple //)" do
|
174
|
-
request = fake_request({:request_uri => "foo/bar//baz/?bat"})
|
175
|
-
request.path.should == "foo/bar/baz"
|
176
|
-
end
|
177
|
-
|
178
|
-
it "should get the remote port" do
|
179
|
-
request = fake_request({:server_port => "80"})
|
180
|
-
request.port.should == 80
|
181
|
-
end
|
182
|
-
|
183
|
-
it "should get the parts of the remote subdomain" do
|
184
|
-
request = fake_request({:http_host => "zoo.boom.foo.com"})
|
185
|
-
request.subdomains.should == ["zoo", "boom"]
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should get the parts of the remote subdomain when there's an irregular TLD number" do
|
189
|
-
request = fake_request({:http_host => "foo.bar.co.uk"})
|
190
|
-
request.subdomains(2).should == ["foo"]
|
191
|
-
end
|
192
|
-
|
193
|
-
it "should get the full domain (not including subdomains and not including the port)" do
|
194
|
-
request = fake_request({:http_host => "www.foo.com:80"})
|
195
|
-
request.domain.should == "foo.com"
|
196
|
-
end
|
197
|
-
|
198
|
-
it "should get the full domain from an irregular TLD" do
|
199
|
-
request = fake_request({:http_host => "www.foo.co.uk:80"})
|
200
|
-
request.domain(2).should == "foo.co.uk"
|
201
|
-
end
|
202
|
-
|
203
|
-
it "should get the host (with X_FORWARDED_HOST)" do
|
204
|
-
request = fake_request({:http_x_forwarded_host => "www.example.com"})
|
205
|
-
request.host.should == "www.example.com"
|
206
|
-
end
|
207
|
-
|
208
|
-
it "should get the host (without X_FORWARDED_HOST)" do
|
209
|
-
request = fake_request({:http_host => "www.example.com"})
|
210
|
-
request.host.should == "www.example.com"
|
211
|
-
end
|
212
|
-
|
213
|
-
{:http_referer => ["referer", "http://referer.com"],
|
214
|
-
:request_uri => ["uri", "http://uri.com/uri"],
|
215
|
-
:http_user_agent => ["user_agent", "mozilla"],
|
216
|
-
:server_name => ["server_name", "apache"],
|
217
|
-
:http_accept_encoding => ["accept_encoding", "application/json"],
|
218
|
-
:script_name => ["script_name", "foo"],
|
219
|
-
:http_cache_control => ["cache_control", "no-cache"],
|
220
|
-
:http_accept_language => ["accept_language", "en"],
|
221
|
-
:server_software => ["server_software", "apache"],
|
222
|
-
:http_keep_alive => ["keep_alive", "300"],
|
223
|
-
:http_accept_charset => ["accept_charset", "UTF-8"],
|
224
|
-
:http_version => ["version", "1.1"],
|
225
|
-
:gateway_interface => ["gateway", "CGI/1.2"],
|
226
|
-
:http_connection => ["connection", "keep-alive"],
|
227
|
-
:path_info => ["path_info", "foo/bar/baz"],
|
228
|
-
}.each do |env, vars|
|
229
|
-
|
230
|
-
it "should be able to get the #{env.to_s.upcase}" do
|
231
|
-
request = fake_request({env => vars[1]})
|
232
|
-
request.send(vars[0]).should == vars[1]
|
233
|
-
end
|
234
|
-
|
235
|
-
end
|
236
|
-
|
237
|
-
end
|
238
|
-
|
239
|
-
describe Merb::Request, "#if_none_match" do
|
240
|
-
it 'returns value of If-None-Match request header' do
|
241
|
-
fake_request(Merb::Const::HTTP_IF_NONE_MATCH => "dc1562a133").if_none_match.should == "dc1562a133"
|
242
|
-
end
|
243
|
-
end
|
244
|
-
|
245
|
-
describe Merb::Request, "#if_modified_since" do
|
246
|
-
it 'returns value of If-Modified-Since request header' do
|
247
|
-
t = '05 Sep 2008 22:00:27 GMT'
|
248
|
-
fake_request(Merb::Const::HTTP_IF_MODIFIED_SINCE => t).if_modified_since.should == Time.rfc2822(t)
|
249
|
-
end
|
250
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
-
|
3
|
-
describe "The default routes" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
Merb::Router.prepare {|r| r.default_routes}
|
7
|
-
end
|
8
|
-
|
9
|
-
it "should match /foo to the Foo controller and index action" do
|
10
|
-
route_to("/foo").should have_route(:controller => "foo", :action => "index", :id => nil)
|
11
|
-
end
|
12
|
-
|
13
|
-
it "should match /foo/bar to the Foo controller and the bar action" do
|
14
|
-
route_to("/foo/bar").should have_route(:controller => "foo", :action => "bar", :id => nil)
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should match /foo/bar/12 to the Foo controller, the bar action, and id of 12" do
|
18
|
-
route_to("/foo/bar/12").should have_route(:controller => "foo", :action => "bar", :id => "12")
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
-
|
3
|
-
describe "Deferred routes" do
|
4
|
-
|
5
|
-
before :each do
|
6
|
-
Merb::Router.prepare do |r|
|
7
|
-
r.match("/deferred/:zoo").defer_to do |request, params|
|
8
|
-
params.merge(:controller => "w00t") if params[:zoo]
|
9
|
-
end
|
10
|
-
r.default_routes
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
it "should match routes based on the incoming params" do
|
15
|
-
route_to("/deferred/baz", :boo => "12").should have_route(:controller => "w00t", :zoo => "baz")
|
16
|
-
end
|
17
|
-
|
18
|
-
it "should fall back to the default route if the deferred condition is not met" do
|
19
|
-
route_to("/deferred").should have_route(:controller => "deferred", :action => "index")
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "spec_helper")
|
2
|
-
|
3
|
-
module Merb::Test::Fixtures
|
4
|
-
module Controllers
|
5
|
-
class FixatableRoutes < Merb::Controller
|
6
|
-
|
7
|
-
def fixoid
|
8
|
-
end
|
9
|
-
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
describe "A route marked as fixatable" do
|
15
|
-
predicate_matchers[:allow_fixation] = :allow_fixation?
|
16
|
-
|
17
|
-
before do
|
18
|
-
Merb::Router.prepare do |r|
|
19
|
-
r.match("/hello/:action/:id").to(
|
20
|
-
:controller => "merb/test/fixtures/controllers/fixatable_routes",
|
21
|
-
:action => "fixoid").fixatable
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
it "allows fixation" do
|
26
|
-
matched_route_for("/hello/goodbye/tagging").should allow_fixation
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should store a cookie with the session_id" do
|
30
|
-
session_id = Merb::SessionMixin.rand_uuid
|
31
|
-
request = fake_request(:request_uri => "/hello/goodbye/tagging",
|
32
|
-
:query_string => "_session_id=#{session_id}")
|
33
|
-
controller = ::Merb::Dispatcher.handle(request)
|
34
|
-
controller.params["_session_id"].should == session_id
|
35
|
-
controller.request.session_cookie_value.should == session_id
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "A route NOT marked as fixatable" do
|
40
|
-
predicate_matchers[:allow_fixation] = :allow_fixation?
|
41
|
-
|
42
|
-
it "DOES NOT allow fixation" do
|
43
|
-
Merb::Router.prepare do |r|
|
44
|
-
r.match("/hello/:action/:id").to(:controller => "foo", :action => "fixoid")
|
45
|
-
end
|
46
|
-
|
47
|
-
matched_route_for("/hello/goodbye/tagging").should_not allow_fixation
|
48
|
-
end
|
49
|
-
end
|