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,104 +0,0 @@
|
|
1
|
-
# ==== Public Template API
|
2
|
-
# Merb::Template.register_extensions(engine<Class>, extenstions<Array[String]>)
|
3
|
-
#
|
4
|
-
# ==== Semipublic Template API
|
5
|
-
# Merb::Template.engine_for(path<String>)
|
6
|
-
# Merb::Template.template_name(path<String>)
|
7
|
-
# Merb::Template.inline_template(path<String>, mod<Module>)
|
8
|
-
#
|
9
|
-
# ==== Requirements for a new Template Engine
|
10
|
-
# A Template Engine must have at least a single class method called compile_template
|
11
|
-
# with the following parameters:
|
12
|
-
# * path<String>:: the full path to the template being compiled
|
13
|
-
# * name<String>:: the name of the method that will be inlined
|
14
|
-
# * mod<Module>:: the module that the method will be inlined into
|
15
|
-
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
|
16
|
-
|
17
|
-
# A small structure to hold the templates so we can test the templating system in isolation
|
18
|
-
# from the framework
|
19
|
-
|
20
|
-
module Merb::Test::Fixtures
|
21
|
-
# This is a fake templating engine that just copies the text of the template
|
22
|
-
# exactly from the file
|
23
|
-
|
24
|
-
class MyTemplateEngine
|
25
|
-
|
26
|
-
def self.compile_template(io, name, mod)
|
27
|
-
text = io.read
|
28
|
-
table = { "\r"=>"\\r", "\n"=>"\\n", "\t"=>"\\t", '"'=>'\\"', "\\"=>"\\\\" }
|
29
|
-
text = (text.split("\n").map {|x| '"' + (x.gsub(/[\r\n\t"\\]/) { |m| table[m] }) + '"'}).join(" +\n")
|
30
|
-
mod.class_eval <<-EOS, File.expand_path(io.path)
|
31
|
-
def #{name}
|
32
|
-
#{text}
|
33
|
-
end
|
34
|
-
EOS
|
35
|
-
end
|
36
|
-
|
37
|
-
module Mixin
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
module MyHelpers
|
42
|
-
end
|
43
|
-
|
44
|
-
class Environment
|
45
|
-
include MyHelpers
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
describe Merb::Template do
|
50
|
-
|
51
|
-
# @public
|
52
|
-
it "should accept template-type registrations via #register_extensions" do
|
53
|
-
Merb::Template.register_extensions(Merb::Test::Fixtures::MyTemplateEngine, %w[myt])
|
54
|
-
Merb::Template.engine_for("foo.myt").should == Merb::Test::Fixtures::MyTemplateEngine
|
55
|
-
Merb::Template.template_extensions.should include("myt")
|
56
|
-
end
|
57
|
-
|
58
|
-
# @semipublic
|
59
|
-
|
60
|
-
def rendering_template(template_path)
|
61
|
-
Merb::Template.inline_template(File.open(template_path), Merb::Test::Fixtures::MyHelpers)
|
62
|
-
Merb::Test::Fixtures::Environment.new.
|
63
|
-
send(Merb::Template.template_name(template_path))
|
64
|
-
end
|
65
|
-
alias_method :render_template, :rendering_template
|
66
|
-
|
67
|
-
it "should compile and inline templates via #inline methods for custom languages" do
|
68
|
-
template_path = File.dirname(__FILE__) / "templates" / "template.html.myt"
|
69
|
-
rendering_template(template_path).should == "Hello world!"
|
70
|
-
end
|
71
|
-
|
72
|
-
it "should compile and inline templates via #inline_template for erubis" do
|
73
|
-
template_path = File.dirname(__FILE__) / "templates" / "template.html.erb"
|
74
|
-
rendering_template(template_path).should == "Hello world!"
|
75
|
-
end
|
76
|
-
|
77
|
-
it "should compile and inline templates that comes through via VirtualFile" do
|
78
|
-
Merb::Template.inline_template(VirtualFile.new("Hello",
|
79
|
-
File.dirname(__FILE__) / "templates" / "template.html.erb"),
|
80
|
-
Merb::Test::Fixtures::MyHelpers)
|
81
|
-
|
82
|
-
res = Merb::Test::Fixtures::Environment.new.
|
83
|
-
send(Merb::Template.template_name(File.dirname(__FILE__) / "templates" / "template.html.erb"))
|
84
|
-
|
85
|
-
res.should == "Hello"
|
86
|
-
end
|
87
|
-
|
88
|
-
it "should know how to correctly report errors" do
|
89
|
-
template_path = File.dirname(__FILE__) / "templates" / "error.html.erb"
|
90
|
-
running { render_template(template_path) }.should raise_error(NameError, /`foo'/)
|
91
|
-
begin
|
92
|
-
render_template(template_path)
|
93
|
-
rescue Exception => e
|
94
|
-
e.backtrace.first.match(/\/([^:\/]*:\d*)/)[1].should == "error.html.erb:2"
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should find the full template name for a path via #template_for" do
|
99
|
-
template_path = File.dirname(__FILE__) / "templates" / "template.html.erb"
|
100
|
-
name = Merb::Template.inline_template(File.open(template_path), Merb::Test::Fixtures::MyHelpers)
|
101
|
-
Merb::Test::Fixtures::Environment.new.should respond_to(name)
|
102
|
-
end
|
103
|
-
|
104
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
Hello world!
|
@@ -1 +0,0 @@
|
|
1
|
-
Hello world!
|
@@ -1,412 +0,0 @@
|
|
1
|
-
require File.join(File.dirname(__FILE__), "..", "..", "spec_helper")
|
2
|
-
|
3
|
-
Merb.start :environment => 'test', :log_level => :fatal
|
4
|
-
|
5
|
-
class TestController < Merb::Controller
|
6
|
-
attr_accessor :redirect_to
|
7
|
-
def redirect_action; redirect(@redirect_to || "/"); end
|
8
|
-
def success_action; end
|
9
|
-
def missing_action; render("i can has errorz", :status => 404); end
|
10
|
-
|
11
|
-
def redirect_with_message_action
|
12
|
-
redirect(@redirect_to, :message => "okey dookey")
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe Merb::Test::Rspec::ControllerMatchers do
|
17
|
-
include Merb::Test::ControllerHelper
|
18
|
-
before(:each) do
|
19
|
-
Merb::Router.prepare do |r|
|
20
|
-
r.match("/redirect").to(:controller => "test_controller", :action => "redirect_action")
|
21
|
-
r.match("/success").to(:controller => "test_controller", :action => "success_action")
|
22
|
-
r.match("/missing").to(:controller => "test_controller", :action => "missing_action")
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
describe "#redirect" do
|
27
|
-
it "should work with the result of a dispatch_to helper call" do
|
28
|
-
dispatch_to(TestController, :redirect_action).should redirect
|
29
|
-
end
|
30
|
-
|
31
|
-
it "should work with the result of a get helper call" do
|
32
|
-
get("/redirect").should redirect
|
33
|
-
end
|
34
|
-
|
35
|
-
it "should work with a redirection code" do
|
36
|
-
dispatch_to(TestController, :redirect_action).status.should redirect
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "#redirect_to" do
|
41
|
-
it "should work with the result of a dispatch_to helper call" do
|
42
|
-
dispatch_to(TestController, :redirect_action).should redirect_to("/")
|
43
|
-
dispatch_to(TestController, :redirect_action){ |controller| controller.redirect_to = "http://example.com/" }.should redirect_to("http://example.com/")
|
44
|
-
end
|
45
|
-
|
46
|
-
it "should work with the result of a get helper call" do
|
47
|
-
get("/redirect"){|controller| controller.redirect_to = "http://example.com/" }.should redirect_to("http://example.com/")
|
48
|
-
end
|
49
|
-
|
50
|
-
it 'takes :message option' do
|
51
|
-
dispatch_to(TestController, :redirect_with_message_action) { |controller|
|
52
|
-
controller.redirect_to = "http://example.com/"
|
53
|
-
}.should redirect_to("http://example.com/", :message => "okey dookey")
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe "#respond_successfully" do
|
58
|
-
it "should work with the result of a dispatch_to helper call" do
|
59
|
-
dispatch_to(TestController, :success_action).should respond_successfully
|
60
|
-
end
|
61
|
-
|
62
|
-
it "should work with the result of a get helper call" do
|
63
|
-
get("/success").should respond_successfully
|
64
|
-
end
|
65
|
-
|
66
|
-
it "should work with a redirection code" do
|
67
|
-
dispatch_to(TestController, :success_action).status.should be_successful
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe "#be_missing" do
|
72
|
-
it "should work with the result of a dispatch_to helper call" do
|
73
|
-
dispatch_to(TestController, :missing_action).should be_missing
|
74
|
-
end
|
75
|
-
|
76
|
-
it "should work with the result of a get helper call" do
|
77
|
-
get("/missing").should be_client_error
|
78
|
-
end
|
79
|
-
|
80
|
-
it "should work with a redirection code" do
|
81
|
-
dispatch_to(TestController, :missing_action).status.should be_missing
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
module Merb::Test::Rspec
|
87
|
-
module ControllerMatchers
|
88
|
-
class RedirectableTarget
|
89
|
-
attr_accessor :status, :headers
|
90
|
-
def initialize; @headers = {}; end
|
91
|
-
end
|
92
|
-
|
93
|
-
describe BeRedirect do
|
94
|
-
before(:each) do
|
95
|
-
@target = RedirectableTarget.new
|
96
|
-
end
|
97
|
-
|
98
|
-
it "should match a 301 'Moved Permanently' redirect code" do
|
99
|
-
BeRedirect.new.matches?(301).should be_true
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should match a 302 'Found' redirect code" do
|
103
|
-
BeRedirect.new.matches?(302).should be_true
|
104
|
-
end
|
105
|
-
|
106
|
-
it "should match a 303 'See Other' redirect code" do
|
107
|
-
BeRedirect.new.matches?(303).should be_true
|
108
|
-
end
|
109
|
-
|
110
|
-
it "should match a 304 'Not Modified' redirect code" do
|
111
|
-
BeRedirect.new.matches?(304).should be_true
|
112
|
-
end
|
113
|
-
|
114
|
-
it "should match a 307 'Temporary Redirect' redirect code" do
|
115
|
-
BeRedirect.new.matches?(307).should be_true
|
116
|
-
end
|
117
|
-
|
118
|
-
it "should match a target with a valid redirect code" do
|
119
|
-
@target.status = 301
|
120
|
-
|
121
|
-
BeRedirect.new.matches?(@target).should be_true
|
122
|
-
end
|
123
|
-
|
124
|
-
it "should not match a target with an unused redirect code" do
|
125
|
-
@target.status = 399
|
126
|
-
|
127
|
-
BeRedirect.new.matches?(@target).should_not be_true
|
128
|
-
end
|
129
|
-
|
130
|
-
it "should not match a target with a non redirect code" do
|
131
|
-
@target.status = 200
|
132
|
-
|
133
|
-
BeRedirect.new.matches?(@target).should_not be_true
|
134
|
-
end
|
135
|
-
|
136
|
-
describe "#failure_message" do
|
137
|
-
it "should be 'expected to redirect' when the target is a status code" do
|
138
|
-
matcher = BeRedirect.new
|
139
|
-
matcher.matches?(200)
|
140
|
-
matcher.failure_message.should == "expected to redirect"
|
141
|
-
end
|
142
|
-
|
143
|
-
it "should be 'expected Foo#bar to redirect' when the target's controller is Foo and action is bar" do
|
144
|
-
matcher = BeRedirect.new
|
145
|
-
@target.stub!(:controller_name).and_return :Foo
|
146
|
-
@target.stub!(:action_name).and_return :bar
|
147
|
-
matcher.matches?(@target)
|
148
|
-
matcher.failure_message.should == "expected Foo#bar to redirect"
|
149
|
-
end
|
150
|
-
end
|
151
|
-
|
152
|
-
describe "#negative_failure_message" do
|
153
|
-
it "should be 'expected not to redirect' when the target is a status code" do
|
154
|
-
matcher = BeRedirect.new
|
155
|
-
matcher.matches?(200)
|
156
|
-
matcher.negative_failure_message.should == "expected not to redirect"
|
157
|
-
end
|
158
|
-
|
159
|
-
it "should be 'expected Foo#bar to redirect' when the target's controller is Foo and action is bar" do
|
160
|
-
matcher = BeRedirect.new
|
161
|
-
@target.stub!(:controller_name).and_return :Foo
|
162
|
-
@target.stub!(:action_name).and_return :bar
|
163
|
-
matcher.matches?(@target)
|
164
|
-
matcher.negative_failure_message.should == "expected Foo#bar not to redirect"
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
168
|
-
|
169
|
-
describe RedirectTo do
|
170
|
-
before(:each) do
|
171
|
-
@target = RedirectableTarget.new
|
172
|
-
end
|
173
|
-
|
174
|
-
it "should match a target if the status code is 300 level and the locations match" do
|
175
|
-
@target.status = 301
|
176
|
-
@target.headers['Location'] = "http://example.com/"
|
177
|
-
|
178
|
-
RedirectTo.new("http://example.com/").matches?(@target).should be_true
|
179
|
-
end
|
180
|
-
|
181
|
-
it "should not match a target if the status code is not 300 level but the locations match" do
|
182
|
-
@target.status = 404
|
183
|
-
@target.headers['Location'] = "http://example.com/"
|
184
|
-
|
185
|
-
RedirectTo.new("http://example.com/").matches?(@target).should_not be_true
|
186
|
-
end
|
187
|
-
|
188
|
-
it "should not match a target if the status code is 300 level but the locations do not match" do
|
189
|
-
@target.status = 301
|
190
|
-
@target.headers['Location'] = "http://merbivore.com/"
|
191
|
-
|
192
|
-
RedirectTo.new("http://example.com/").matches?(@target).should_not be_true
|
193
|
-
end
|
194
|
-
|
195
|
-
describe "#failure_message" do
|
196
|
-
it "should be 'expected Foo#bar to redirect to <http://expected.com/>, but was <http://target.com/>' when the expected url is http://expected.com/ and the target url is http://target.com/" do
|
197
|
-
@target.stub!(:controller_name).and_return :Foo
|
198
|
-
@target.stub!(:action_name).and_return :bar
|
199
|
-
@target.status = 301
|
200
|
-
@target.headers['Location'] = "http://target.com/"
|
201
|
-
matcher = RedirectTo.new("http://expected.com/")
|
202
|
-
matcher.matches?(@target)
|
203
|
-
matcher.failure_message.should == "expected Foo#bar to redirect to <http://expected.com/>, but was <http://target.com/>"
|
204
|
-
end
|
205
|
-
|
206
|
-
it "should be 'expected Foo#bar to redirect, but there was no redirection' when the target is not redirected" do
|
207
|
-
@target.stub!(:controller_name).and_return :Foo
|
208
|
-
@target.stub!(:action_name).and_return :bar
|
209
|
-
@target.status = 200
|
210
|
-
@target.headers['Location'] = "http://target.com/"
|
211
|
-
matcher = RedirectTo.new("http://expected.com/")
|
212
|
-
matcher.matches?(@target)
|
213
|
-
matcher.failure_message.should == "expected Foo#bar to redirect to <http://expected.com/>, but there was no redirection"
|
214
|
-
end
|
215
|
-
end
|
216
|
-
|
217
|
-
describe "#negative_failure_message" do
|
218
|
-
it "should be 'expected Foo#bar not to redirect to <http://expected.com/>, but it did anyways" do
|
219
|
-
@target.stub!(:controller_name).and_return :Foo
|
220
|
-
@target.stub!(:action_name).and_return :bar
|
221
|
-
@target.status = 200
|
222
|
-
@target.headers['Location'] = "http://target.com/"
|
223
|
-
matcher = RedirectTo.new("http://expected.com/")
|
224
|
-
matcher.matches?(@target)
|
225
|
-
matcher.negative_failure_message.should == "expected Foo#bar not to redirect to <http://expected.com/>, but did anyway"
|
226
|
-
end
|
227
|
-
end
|
228
|
-
end
|
229
|
-
|
230
|
-
describe BeSuccess do
|
231
|
-
before(:each) do
|
232
|
-
@target = RedirectableTarget.new
|
233
|
-
end
|
234
|
-
|
235
|
-
it "should match a target with a 200 'OK' status code" do
|
236
|
-
BeSuccess.new.matches?(200).should be_true
|
237
|
-
end
|
238
|
-
|
239
|
-
it "should match a target with a 201 'Created' status code" do
|
240
|
-
BeSuccess.new.matches?(201).should be_true
|
241
|
-
end
|
242
|
-
|
243
|
-
it "should match a target with a 202 'Accepted' status code" do
|
244
|
-
BeSuccess.new.matches?(202).should be_true
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should match a target with a 203 'Non-Authoritative Information' status code" do
|
248
|
-
BeSuccess.new.matches?(203).should be_true
|
249
|
-
end
|
250
|
-
|
251
|
-
it "should match a target with a 204 'No Content' status code" do
|
252
|
-
BeSuccess.new.matches?(204).should be_true
|
253
|
-
end
|
254
|
-
|
255
|
-
it "should match a target with a 205 'Reset Content' status code" do
|
256
|
-
BeSuccess.new.matches?(205).should be_true
|
257
|
-
end
|
258
|
-
|
259
|
-
it "should match a target with a 206 'Partial Content' status code" do
|
260
|
-
BeSuccess.new.matches?(206).should be_true
|
261
|
-
end
|
262
|
-
|
263
|
-
it "should match a target with a 207 'Multi-Status' status code" do
|
264
|
-
BeSuccess.new.matches?(207).should be_true
|
265
|
-
end
|
266
|
-
|
267
|
-
it "should not match a target with an unused 200 level status code" do
|
268
|
-
BeSuccess.new.matches?(299).should_not be_true
|
269
|
-
end
|
270
|
-
|
271
|
-
it "should not match a target with a non 200 level status code" do
|
272
|
-
BeSuccess.new.matches?(301).should_not be_true
|
273
|
-
end
|
274
|
-
|
275
|
-
describe "#failure_message" do
|
276
|
-
it "should be 'expected to be successful but was 300' when the target is status code 300" do
|
277
|
-
matcher = BeSuccess.new
|
278
|
-
matcher.matches?(300)
|
279
|
-
matcher.failure_message.should == "expected to be successful but was 300"
|
280
|
-
end
|
281
|
-
|
282
|
-
it "should be 'expected Foo#bar to be successful but was 404' when the target is controller-ish" do
|
283
|
-
@target.stub!(:controller_name).and_return :Foo
|
284
|
-
@target.stub!(:action_name).and_return :bar
|
285
|
-
@target.status = 404
|
286
|
-
matcher = BeSuccess.new
|
287
|
-
matcher.matches?(@target)
|
288
|
-
matcher.failure_message.should == "expected Foo#bar to be successful but was 404"
|
289
|
-
end
|
290
|
-
end
|
291
|
-
|
292
|
-
describe "#negative_failure_message" do
|
293
|
-
it "should be 'expected not to be successful but it was' when the target is a 200 status code" do
|
294
|
-
matcher = BeSuccess.new
|
295
|
-
matcher.matches?(200)
|
296
|
-
matcher.negative_failure_message.should == "expected not to be successful but it was 200"
|
297
|
-
end
|
298
|
-
|
299
|
-
it "should be 'expected Foo#bar not to be successful but it was 200' when the target is controller-ish" do
|
300
|
-
@target.stub!(:controller_name).and_return :Foo
|
301
|
-
@target.stub!(:action_name).and_return :bar
|
302
|
-
@target.status = 200
|
303
|
-
matcher = BeSuccess.new
|
304
|
-
matcher.matches?(@target)
|
305
|
-
matcher.negative_failure_message.should == "expected Foo#bar not to be successful but it was 200"
|
306
|
-
end
|
307
|
-
end
|
308
|
-
end
|
309
|
-
|
310
|
-
describe BeMissing do
|
311
|
-
before(:each) do
|
312
|
-
@target = RedirectableTarget.new
|
313
|
-
end
|
314
|
-
|
315
|
-
it "should match a 400 'Bad Request'" do
|
316
|
-
BeMissing.new.matches?(400).should be_true
|
317
|
-
end
|
318
|
-
|
319
|
-
it "should match a 401 'Unauthorized'" do
|
320
|
-
BeMissing.new.matches?(401).should be_true
|
321
|
-
end
|
322
|
-
|
323
|
-
it "should match a 403 'Forbidden'" do
|
324
|
-
BeMissing.new.matches?(403).should be_true
|
325
|
-
end
|
326
|
-
|
327
|
-
it "should match a 404 'Not Found'" do
|
328
|
-
BeMissing.new.matches?(404).should be_true
|
329
|
-
end
|
330
|
-
|
331
|
-
it "should match a 409 'Conflict'" do
|
332
|
-
BeMissing.new.matches?(409).should be_true
|
333
|
-
end
|
334
|
-
|
335
|
-
it "should match a target with a valid client side error code" do
|
336
|
-
@target.status = 404
|
337
|
-
|
338
|
-
BeMissing.new.matches?(@target).should be_true
|
339
|
-
end
|
340
|
-
|
341
|
-
it "should not match a target with an unused client side error code" do
|
342
|
-
@target.status = 499
|
343
|
-
|
344
|
-
BeMissing.new.matches?(@target).should_not be_true
|
345
|
-
end
|
346
|
-
|
347
|
-
it "should not match a target with a non client side error code" do
|
348
|
-
@target.status = 200
|
349
|
-
|
350
|
-
BeMissing.new.matches?(@target).should_not be_true
|
351
|
-
end
|
352
|
-
|
353
|
-
describe "#failure_message" do
|
354
|
-
it "should be 'expected to be missing but was 300' when the target is status code 300" do
|
355
|
-
matcher = BeMissing.new
|
356
|
-
matcher.matches?(300)
|
357
|
-
matcher.failure_message.should == "expected to be missing but was 300"
|
358
|
-
end
|
359
|
-
|
360
|
-
it "should be 'expected Foo#bar to be successful but was 301' when the target is controller-ish" do
|
361
|
-
@target.stub!(:controller_name).and_return :Foo
|
362
|
-
@target.stub!(:action_name).and_return :bar
|
363
|
-
@target.status = 301
|
364
|
-
matcher = BeMissing.new
|
365
|
-
matcher.matches?(@target)
|
366
|
-
matcher.failure_message.should == "expected Foo#bar to be missing but was 301"
|
367
|
-
end
|
368
|
-
end
|
369
|
-
|
370
|
-
describe "#negative_failure_message" do
|
371
|
-
it "should be 'expected not to be successful but it was' when the target is a 400 status code" do
|
372
|
-
matcher = BeMissing.new
|
373
|
-
matcher.matches?(400)
|
374
|
-
matcher.negative_failure_message.should == "expected not to be missing but it was 400"
|
375
|
-
end
|
376
|
-
|
377
|
-
it "should be 'expected Foo#bar not to be missing but it was 404' when the target is controller-ish" do
|
378
|
-
@target.stub!(:controller_name).and_return :Foo
|
379
|
-
@target.stub!(:action_name).and_return :bar
|
380
|
-
@target.status = 404
|
381
|
-
matcher = BeMissing.new
|
382
|
-
matcher.matches?(@target)
|
383
|
-
matcher.negative_failure_message.should == "expected Foo#bar not to be missing but it was 404"
|
384
|
-
end
|
385
|
-
end
|
386
|
-
end
|
387
|
-
|
388
|
-
describe Provide do
|
389
|
-
class TestController < Merb::Controller
|
390
|
-
provides :xml
|
391
|
-
end
|
392
|
-
|
393
|
-
it 'should match for formats a controller class provides' do
|
394
|
-
Provide.new( :xml ).matches?( TestController ).should be_true
|
395
|
-
end
|
396
|
-
|
397
|
-
it 'should match for formats a controller instance provides' do
|
398
|
-
t = TestController.new( fake_request )
|
399
|
-
Provide.new( :xml ).matches?( t ).should be_true
|
400
|
-
end
|
401
|
-
|
402
|
-
it 'should not match for formats a controller class does not provide' do
|
403
|
-
Provide.new( :yaml ).matches?( TestController ).should be_false
|
404
|
-
end
|
405
|
-
|
406
|
-
it 'should not match for formats a controller instance does not provide' do
|
407
|
-
t = TestController.new( fake_request )
|
408
|
-
Provide.new( :yaml ).matches?( t ).should be_false
|
409
|
-
end
|
410
|
-
end
|
411
|
-
end
|
412
|
-
end
|