merb 0.5.3 → 0.9.2
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +0 -20
- data/README +0 -277
- data/Rakefile +80 -199
- data/TODO +0 -3
- metadata +19 -438
- data/SVN_REVISION +0 -1
- data/app_generators/merb/USAGE +0 -5
- data/app_generators/merb/merb_generator.rb +0 -108
- data/app_generators/merb/templates/Rakefile +0 -124
- data/app_generators/merb/templates/app/controllers/application.rb +0 -3
- data/app_generators/merb/templates/app/controllers/exceptions.rb +0 -13
- data/app_generators/merb/templates/app/helpers/global_helper.rb +0 -5
- data/app_generators/merb/templates/app/mailers/views/layout/application.html.erb +0 -1
- data/app_generators/merb/templates/app/mailers/views/layout/application.text.erb +0 -1
- data/app_generators/merb/templates/app/parts/views/layout/application.html.erb +0 -1
- data/app_generators/merb/templates/app/views/exceptions/internal_server_error.html.erb +0 -216
- data/app_generators/merb/templates/app/views/exceptions/not_acceptable.html.erb +0 -38
- data/app_generators/merb/templates/app/views/exceptions/not_found.html.erb +0 -40
- data/app_generators/merb/templates/app/views/layout/application.html.erb +0 -11
- data/app_generators/merb/templates/config/boot.rb +0 -11
- data/app_generators/merb/templates/config/dependencies.rb +0 -41
- data/app_generators/merb/templates/config/environments/development.rb +0 -1
- data/app_generators/merb/templates/config/environments/production.rb +0 -1
- data/app_generators/merb/templates/config/environments/test.rb +0 -1
- data/app_generators/merb/templates/config/merb.yml +0 -82
- data/app_generators/merb/templates/config/merb_init.rb +0 -17
- data/app_generators/merb/templates/config/plugins.yml +0 -1
- data/app_generators/merb/templates/config/router.rb +0 -35
- data/app_generators/merb/templates/config/upload.conf +0 -0
- data/app_generators/merb/templates/public/images/merb.jpg +0 -0
- data/app_generators/merb/templates/public/merb.fcgi +0 -6
- data/app_generators/merb/templates/public/stylesheets/master.css +0 -119
- data/app_generators/merb/templates/script/destroy +0 -32
- data/app_generators/merb/templates/script/generate +0 -32
- data/app_generators/merb/templates/script/stop_merb +0 -13
- data/app_generators/merb/templates/script/win_script.cmd +0 -1
- data/app_generators/merb/templates/spec/spec.opts +0 -6
- data/app_generators/merb/templates/spec/spec_helper.rb +0 -15
- data/app_generators/merb/templates/test/test_helper.rb +0 -14
- data/app_generators/merb_plugin/USAGE +0 -5
- data/app_generators/merb_plugin/merb_plugin_generator.rb +0 -68
- data/app_generators/merb_plugin/templates/LICENSE +0 -20
- data/app_generators/merb_plugin/templates/README +0 -4
- data/app_generators/merb_plugin/templates/Rakefile +0 -35
- data/app_generators/merb_plugin/templates/TODO +0 -5
- data/app_generators/merb_plugin/templates/merbtasks.rb +0 -6
- data/app_generators/merb_plugin/templates/sampleplugin.rb +0 -10
- data/app_generators/merb_plugin/templates/sampleplugin_spec.rb +0 -7
- data/app_generators/merb_plugin/templates/spec_helper.rb +0 -2
- data/bin/merb +0 -4
- data/lib/autotest/discover.rb +0 -3
- data/lib/autotest/merb_rspec.rb +0 -80
- data/lib/merb.rb +0 -188
- data/lib/merb/abstract_controller.rb +0 -399
- data/lib/merb/assets.rb +0 -160
- data/lib/merb/assets.rb.orig +0 -119
- data/lib/merb/boot_loader.rb +0 -286
- data/lib/merb/boot_loader.rb.orig +0 -235
- data/lib/merb/caching.rb +0 -5
- data/lib/merb/caching/action_cache.rb +0 -92
- data/lib/merb/caching/fragment_cache.rb +0 -39
- data/lib/merb/caching/store/file_cache.rb +0 -90
- data/lib/merb/caching/store/memory_cache.rb +0 -85
- data/lib/merb/config.rb +0 -290
- data/lib/merb/constants.rb +0 -50
- data/lib/merb/controller.rb +0 -220
- data/lib/merb/cookies.rb +0 -95
- data/lib/merb/core_ext.rb +0 -15
- data/lib/merb/core_ext/array.rb +0 -0
- data/lib/merb/core_ext/class.rb +0 -180
- data/lib/merb/core_ext/enumerable.rb +0 -49
- data/lib/merb/core_ext/get_args.rb +0 -76
- data/lib/merb/core_ext/hash.rb +0 -306
- data/lib/merb/core_ext/inflections.rb +0 -112
- data/lib/merb/core_ext/inflector.rb +0 -275
- data/lib/merb/core_ext/kernel.rb +0 -242
- data/lib/merb/core_ext/mash.rb +0 -88
- data/lib/merb/core_ext/module.rb +0 -67
- data/lib/merb/core_ext/numeric.rb +0 -72
- data/lib/merb/core_ext/object.rb +0 -183
- data/lib/merb/core_ext/string.rb +0 -53
- data/lib/merb/core_ext/symbol.rb +0 -6
- data/lib/merb/dispatcher.rb +0 -109
- data/lib/merb/drb_server.rb +0 -19
- data/lib/merb/erubis_ext.rb +0 -10
- data/lib/merb/exceptions.rb +0 -192
- data/lib/merb/generators/merb_app/merb_app.rb +0 -22
- data/lib/merb/generators/merb_generator_helpers.rb +0 -318
- data/lib/merb/generators/merb_plugin.rb +0 -22
- data/lib/merb/logger.rb +0 -78
- data/lib/merb/mail_controller.rb +0 -268
- data/lib/merb/mailer.rb +0 -87
- data/lib/merb/mixins/basic_authentication.rb +0 -35
- data/lib/merb/mixins/controller.rb +0 -160
- data/lib/merb/mixins/erubis_capture.rb +0 -68
- data/lib/merb/mixins/general_controller.rb +0 -253
- data/lib/merb/mixins/inline_partial.rb +0 -32
- data/lib/merb/mixins/render.rb +0 -465
- data/lib/merb/mixins/responder.rb +0 -449
- data/lib/merb/mixins/view_context.rb +0 -558
- data/lib/merb/mixins/web_controller.rb +0 -36
- data/lib/merb/mongrel_handler.rb +0 -168
- data/lib/merb/part_controller.rb +0 -29
- data/lib/merb/plugins.rb +0 -16
- data/lib/merb/rack_adapter.rb +0 -37
- data/lib/merb/request.rb +0 -465
- data/lib/merb/router.rb +0 -646
- data/lib/merb/server.rb +0 -169
- data/lib/merb/session.rb +0 -23
- data/lib/merb/session/cookie_store.rb +0 -118
- data/lib/merb/session/mem_cache_session.rb +0 -131
- data/lib/merb/session/memory_session.rb +0 -176
- data/lib/merb/template.rb +0 -37
- data/lib/merb/template/erubis.rb +0 -68
- data/lib/merb/template/haml.rb +0 -87
- data/lib/merb/template/markaby.rb +0 -59
- data/lib/merb/template/xml_builder.rb +0 -50
- data/lib/merb/test/fake_request.rb +0 -74
- data/lib/merb/test/helper.rb +0 -260
- data/lib/merb/test/hpricot.rb +0 -136
- data/lib/merb/test/multipart.rb +0 -66
- data/lib/merb/test/rspec.rb +0 -18
- data/lib/merb/test/rspec_matchers/controller_matchers.rb +0 -117
- data/lib/merb/test/rspec_matchers/markup_matchers.rb +0 -98
- data/lib/merb/upload_handler.rb +0 -80
- data/lib/merb/upload_progress.rb +0 -48
- data/lib/merb/version.rb +0 -49
- data/lib/merb/view_context.rb +0 -79
- data/lib/tasks.rb +0 -7
- data/lib/tasks/merb.rake +0 -54
- data/merb_default_generators/model/USAGE +0 -0
- data/merb_default_generators/model/model_generator.rb +0 -16
- data/merb_default_generators/model/templates/new_model_template.erb +0 -5
- data/merb_default_generators/resource_controller/USAGE +0 -0
- data/merb_default_generators/resource_controller/resource_controller_generator.rb +0 -26
- data/merb_default_generators/resource_controller/templates/controller.rb +0 -30
- data/merb_default_generators/resource_controller/templates/edit.html.erb +0 -1
- data/merb_default_generators/resource_controller/templates/helper.rb +0 -5
- data/merb_default_generators/resource_controller/templates/index.html.erb +0 -1
- data/merb_default_generators/resource_controller/templates/new.html.erb +0 -1
- data/merb_default_generators/resource_controller/templates/show.html.erb +0 -1
- data/merb_generators/controller/USAGE +0 -5
- data/merb_generators/controller/controller_generator.rb +0 -16
- data/merb_generators/controller/templates/controller.rb +0 -8
- data/merb_generators/controller/templates/helper.rb +0 -5
- data/merb_generators/controller/templates/index.html.erb +0 -3
- data/merb_generators/part_controller/USAGE +0 -5
- data/merb_generators/part_controller/part_controller_generator.rb +0 -27
- data/merb_generators/part_controller/templates/controller.rb +0 -8
- data/merb_generators/part_controller/templates/helper.rb +0 -5
- data/merb_generators/part_controller/templates/index.html.erb +0 -3
- data/merb_generators/resource/USAGE +0 -0
- data/merb_generators/resource/resource_generator.rb +0 -67
- data/rspec_generators/merb_controller_test/merb_controller_test_generator.rb +0 -67
- data/rspec_generators/merb_controller_test/templates/controller_spec.rb +0 -8
- data/rspec_generators/merb_controller_test/templates/edit_spec.rb +0 -12
- data/rspec_generators/merb_controller_test/templates/helper_spec.rb +0 -5
- data/rspec_generators/merb_controller_test/templates/index_spec.rb +0 -12
- data/rspec_generators/merb_controller_test/templates/new_spec.rb +0 -12
- data/rspec_generators/merb_controller_test/templates/show_spec.rb +0 -5
- data/rspec_generators/merb_model_test/merb_model_test_generator.rb +0 -26
- data/rspec_generators/merb_model_test/templates/model_spec_template.erb +0 -7
- data/script/destroy +0 -14
- data/script/generate +0 -14
- data/spec/fixtures/config/environments/environment_config_test.yml +0 -1
- data/spec/fixtures/config/merb.yml +0 -18
- data/spec/fixtures/controllers/dispatch_spec_controllers.rb +0 -235
- data/spec/fixtures/controllers/render_spec_controllers.rb +0 -184
- data/spec/fixtures/foo.rb +0 -3
- data/spec/fixtures/mailers/views/layout/application.html.erb +0 -3
- data/spec/fixtures/mailers/views/layout/application.text.erb +0 -3
- data/spec/fixtures/mailers/views/test_mail_controller/eighth.html.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/eighth.text.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/first.html.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/first.text.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/ninth.html.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/ninth.text.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/second.text.erb +0 -1
- data/spec/fixtures/mailers/views/test_mail_controller/third.html.erb +0 -1
- data/spec/fixtures/models/router_spec_models.rb +0 -30
- data/spec/fixtures/parts/views/layout/todo_part.html.erb +0 -3
- data/spec/fixtures/parts/views/layout/todo_part.xml.erb +0 -3
- data/spec/fixtures/parts/views/todo_part/formatted_output.html.erb +0 -1
- data/spec/fixtures/parts/views/todo_part/formatted_output.js.erb +0 -1
- data/spec/fixtures/parts/views/todo_part/formatted_output.xml.erb +0 -1
- data/spec/fixtures/parts/views/todo_part/list.html.erb +0 -3
- data/spec/fixtures/sample.txt +0 -1
- data/spec/fixtures/views/erubis.html.erb +0 -1
- data/spec/fixtures/views/examples/_erubis.html.erb +0 -1
- data/spec/fixtures/views/examples/_haml.html.haml +0 -1
- data/spec/fixtures/views/examples/_markaby.html.mab +0 -1
- data/spec/fixtures/views/examples/_throw_content.html.erb +0 -6
- data/spec/fixtures/views/examples/hello.xml.builder +0 -1
- data/spec/fixtures/views/examples/js.js.erb +0 -1
- data/spec/fixtures/views/examples/template_catch_content.html.erb +0 -15
- data/spec/fixtures/views/examples/template_catch_content_from_partial.html.erb +0 -6
- data/spec/fixtures/views/examples/template_throw_content.html.erb +0 -10
- data/spec/fixtures/views/examples/template_throw_content_without_block.html.erb +0 -3
- data/spec/fixtures/views/exceptions/admin_access_required.html.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/_nested_js.js.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/_nested_xml.xml.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/_render_partial_multiple_times.html.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/erubis_templates.html.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/erubis_templates.js.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/erubis_templates.rhtml +0 -1
- data/spec/fixtures/views/extension_template_controller/erubis_templates.xml.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/haml_index.html.haml +0 -0
- data/spec/fixtures/views/extension_template_controller/haml_templates.html.haml +0 -1
- data/spec/fixtures/views/extension_template_controller/haml_templates.js.haml +0 -1
- data/spec/fixtures/views/extension_template_controller/haml_templates.xml.haml +0 -1
- data/spec/fixtures/views/extension_template_controller/index.html.erb +0 -0
- data/spec/fixtures/views/extension_template_controller/markaby_index.html.mab +0 -0
- data/spec/fixtures/views/extension_template_controller/markaby_templates.html.mab +0 -1
- data/spec/fixtures/views/extension_template_controller/markaby_templates.js.mab +0 -1
- data/spec/fixtures/views/extension_template_controller/markaby_templates.xml.mab +0 -1
- data/spec/fixtures/views/extension_template_controller/render_multiple_partials.html.erb +0 -4
- data/spec/fixtures/views/extension_template_controller/render_nested_js.js.erb +0 -1
- data/spec/fixtures/views/extension_template_controller/render_nested_xml.xml.erb +0 -1
- data/spec/fixtures/views/haml.html.haml +0 -1
- data/spec/fixtures/views/haml.xml.haml +0 -2
- data/spec/fixtures/views/layout/application.html.erb +0 -1
- data/spec/fixtures/views/layout/application.xml.erb +0 -1
- data/spec/fixtures/views/layout/nested/example.html.erb +0 -1
- data/spec/fixtures/views/markaby.html.mab +0 -1
- data/spec/fixtures/views/nested/example/test.html.erb +0 -1
- data/spec/fixtures/views/partials/_erubis.html.erb +0 -1
- data/spec/fixtures/views/partials/_erubis_collection.html.erb +0 -1
- data/spec/fixtures/views/partials/_erubis_collection_with_locals.html.erb +0 -1
- data/spec/fixtures/views/partials/_erubis_new.html.erb +0 -1
- data/spec/fixtures/views/partials/_haml.html.haml +0 -1
- data/spec/fixtures/views/partials/_haml_collection.html.haml +0 -1
- data/spec/fixtures/views/partials/_haml_collection_with_locals.html.haml +0 -1
- data/spec/fixtures/views/partials/_haml_new.html.haml +0 -1
- data/spec/fixtures/views/partials/_markaby.html.mab +0 -1
- data/spec/fixtures/views/partials/_markaby_collection.html.mab +0 -1
- data/spec/fixtures/views/partials/_markaby_collection_with_locals.html.mab +0 -1
- data/spec/fixtures/views/partials/_markaby_new.html.mab +0 -1
- data/spec/fixtures/views/render_object_controller/render_object_with_template.html.erb +0 -1
- data/spec/fixtures/views/render_object_controller/render_object_with_template.js.erb +0 -1
- data/spec/fixtures/views/render_object_controller/render_object_with_template.xml.erb +0 -1
- data/spec/fixtures/views/template_views/interface__buffer_erubis.html.erb +0 -4
- data/spec/fixtures/views/template_views/interface__buffer_haml.html.haml +0 -7
- data/spec/fixtures/views/template_views/interface__buffer_markaby.html.mab +0 -7
- data/spec/fixtures/views/template_views/interface_capture_erubis.html.erb +0 -15
- data/spec/fixtures/views/template_views/interface_capture_haml.html.haml +0 -15
- data/spec/fixtures/views/template_views/interface_capture_markaby.html.mab +0 -4
- data/spec/fixtures/views/template_views/interface_concat_erubis.html.erb +0 -12
- data/spec/fixtures/views/template_views/interface_concat_haml.html.haml +0 -11
- data/spec/fixtures/views/template_views/interface_concat_markaby.html.mab +0 -14
- data/spec/fixtures/views/test.dir/the_template.html.erb +0 -1
- data/spec/merb/abstract_controller_spec.rb +0 -38
- data/spec/merb/assets_spec.rb +0 -207
- data/spec/merb/caching_spec.rb +0 -102
- data/spec/merb/config_spec.rb +0 -29
- data/spec/merb/controller_filters_spec.rb +0 -253
- data/spec/merb/controller_spec.rb +0 -126
- data/spec/merb/cookie_store_spec.rb +0 -72
- data/spec/merb/cookies_spec.rb +0 -96
- data/spec/merb/core_ext/class_spec.rb +0 -97
- data/spec/merb/core_ext/enumerable_spec.rb +0 -27
- data/spec/merb/core_ext/hash_spec.rb +0 -251
- data/spec/merb/core_ext/inflector_spec.rb +0 -34
- data/spec/merb/core_ext/kernel_spec.rb +0 -25
- data/spec/merb/core_ext/numeric_spec.rb +0 -26
- data/spec/merb/core_ext/object_spec.rb +0 -47
- data/spec/merb/core_ext/string_spec.rb +0 -22
- data/spec/merb/core_ext/symbol_spec.rb +0 -7
- data/spec/merb/dependency_spec.rb +0 -22
- data/spec/merb/dispatch_spec.rb +0 -528
- data/spec/merb/fake_request_spec.rb +0 -80
- data/spec/merb/generator_spec.rb +0 -248
- data/spec/merb/handler_spec.rb +0 -169
- data/spec/merb/mail_controller_spec.rb +0 -177
- data/spec/merb/mailer_spec.rb +0 -87
- data/spec/merb/multipart_spec.rb +0 -50
- data/spec/merb/part_controller_spec.rb +0 -124
- data/spec/merb/plugins_spec.rb +0 -80
- data/spec/merb/render_spec.rb +0 -469
- data/spec/merb/request_spec.rb +0 -287
- data/spec/merb/responder_spec.rb +0 -562
- data/spec/merb/router_spec.rb +0 -900
- data/spec/merb/server_spec.rb +0 -19
- data/spec/merb/template_spec.rb +0 -41
- data/spec/merb/upload_handler_spec.rb +0 -108
- data/spec/merb/version_spec.rb +0 -33
- data/spec/merb/view_context_spec.rb +0 -366
- data/spec/spec_generator_helper.rb +0 -34
- data/spec/spec_helper.rb +0 -101
- data/spec/spec_helpers/url_shared_behaviour.rb +0 -112
- data/test_unit_generators/merb_controller_test/merb_controller_test_generator.rb +0 -53
- data/test_unit_generators/merb_controller_test/templates/functional_test.rb +0 -17
- data/test_unit_generators/merb_controller_test/templates/helper_test.rb +0 -9
- data/test_unit_generators/merb_model_test/merb_model_test_generator.rb +0 -29
- data/test_unit_generators/merb_model_test/templates/model_test_unit_template.erb +0 -9
data/lib/merb/test/hpricot.rb
DELETED
@@ -1,136 +0,0 @@
|
|
1
|
-
# http://yehudakatz.com/2007/01/27/a-better-assert_select-assert_elements/
|
2
|
-
# based on assert_elements
|
3
|
-
# Author: Yehuda Katz
|
4
|
-
# Email: wycats @nospam@ gmail.com
|
5
|
-
# Web: http://www.yehudakatz.com
|
6
|
-
#
|
7
|
-
# which was based on HpricotTestHelper
|
8
|
-
# Author: Luke Redpath
|
9
|
-
# Email: contact @nospam@ lukeredpath.co.uk
|
10
|
-
# Web: www.lukeredpath.co.uk / opensource.agileevolved.com
|
11
|
-
|
12
|
-
require 'hpricot'
|
13
|
-
|
14
|
-
class Hpricot::Elem
|
15
|
-
def should_contain(value)
|
16
|
-
self.inner_text.include?(value)
|
17
|
-
end
|
18
|
-
|
19
|
-
def should_match(regex)
|
20
|
-
self.inner_text.match(regex)
|
21
|
-
end
|
22
|
-
|
23
|
-
# courtesy of 'thomas' from the comments
|
24
|
-
# of _whys blog - get in touch if you want a better credit!
|
25
|
-
def inner_text
|
26
|
-
self.children.collect do |child|
|
27
|
-
child.is_a?(Hpricot::Text) ? child.content : ((child.respond_to?("inner_text") && child.inner_text) || "")
|
28
|
-
end.join.strip
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
module HpricotTestHelper
|
33
|
-
# returns the inner content of
|
34
|
-
# the first tag found by the css query
|
35
|
-
def tag(css_query)
|
36
|
-
process_output
|
37
|
-
@output.content_for(css_query)
|
38
|
-
end
|
39
|
-
|
40
|
-
# returns an array of tag contents
|
41
|
-
# for all of the tags found by the
|
42
|
-
# css query
|
43
|
-
def tags(css_query)
|
44
|
-
process_output
|
45
|
-
@output.content_for_all(css_query)
|
46
|
-
end
|
47
|
-
|
48
|
-
# returns a raw Hpricot::Elem object
|
49
|
-
# for the first result found by the query
|
50
|
-
def element(css_query)
|
51
|
-
process_output
|
52
|
-
@output[css_query].first
|
53
|
-
end
|
54
|
-
|
55
|
-
# returns an array of Hpricot::Elem objects
|
56
|
-
# for the results found by the query
|
57
|
-
def elements(css_query)
|
58
|
-
process_output
|
59
|
-
Hpricot::Elements[*css_query.split(",").map(&:strip).map do |query|
|
60
|
-
@output[query]
|
61
|
-
end.flatten]
|
62
|
-
end
|
63
|
-
|
64
|
-
def get_elements css_query, text
|
65
|
-
els = elements(css_query)
|
66
|
-
case text
|
67
|
-
when String then els.reject! {|t| !t.should_contain(text) }
|
68
|
-
when Regexp then els.reject! {|t| !t.should_match(text) }
|
69
|
-
end
|
70
|
-
els
|
71
|
-
end
|
72
|
-
|
73
|
-
def assert_elements css_query, equality = nil, &block
|
74
|
-
message = equality.delete(:message) if equality.is_a?(Hash)
|
75
|
-
|
76
|
-
case equality
|
77
|
-
when Numeric then equality = {:count => equality}
|
78
|
-
when Range then equality = {:minimum => equality.to_a.first, :maximum => equality.to_a.last }
|
79
|
-
else equality ||= {}
|
80
|
-
end
|
81
|
-
|
82
|
-
equality.merge!({:minimum => 1}) if (equality.keys & [:minimum, :maximum, :count]).empty?
|
83
|
-
|
84
|
-
els = get_elements(css_query, equality[:text])
|
85
|
-
|
86
|
-
ret = equality.keys.include?(:minimum) ? (els.size >= equality[:minimum]) : true
|
87
|
-
ret &&= (els.size <= equality[:maximum]) if equality.keys.include?(:maximum)
|
88
|
-
ret &&= (els.size == equality[:count]) if equality.keys.include?(:count)
|
89
|
-
|
90
|
-
if block && !els.empty?
|
91
|
-
ret &&= self.dup.instance_eval do
|
92
|
-
@output = HpricotTestHelper::DocumentOutput.new(els.inner_html)
|
93
|
-
@block = true
|
94
|
-
instance_eval(&block)
|
95
|
-
end
|
96
|
-
end
|
97
|
-
|
98
|
-
if(equality[:count] != 0)
|
99
|
-
assert ret, "#{ message } \"#{ css_query }\" with \"#{ equality.inspect }\" was not found."
|
100
|
-
else
|
101
|
-
assert ret, "#{ message } \"#{ css_query }\" with \"#{ equality.reject{|k,v| k == :count}.inspect }\" was found, but you specified :count => 0."
|
102
|
-
end
|
103
|
-
ret
|
104
|
-
end
|
105
|
-
|
106
|
-
# small utility class for working with
|
107
|
-
# the Hpricot parser class
|
108
|
-
class DocumentOutput
|
109
|
-
def initialize(response_body)
|
110
|
-
@parser = Hpricot.parse(response_body)
|
111
|
-
end
|
112
|
-
|
113
|
-
def content_for(css_query)
|
114
|
-
@parser.search(css_query).first.inner_text
|
115
|
-
end
|
116
|
-
|
117
|
-
def content_for_all(css_query)
|
118
|
-
@parser.search(css_query).collect(&:inner_text)
|
119
|
-
end
|
120
|
-
|
121
|
-
def [](css_query)
|
122
|
-
@parser.search(css_query)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
protected
|
127
|
-
# creates a new DocumentOutput object from the response
|
128
|
-
# body if hasn't already been created. This is
|
129
|
-
# called automatically by the element and tag methods
|
130
|
-
def process_output
|
131
|
-
if !@block && (@output.nil? || (@controller.body != @response_output))
|
132
|
-
@output = HpricotTestHelper::DocumentOutput.new(@controller.body)
|
133
|
-
@response_output = @controller.body
|
134
|
-
end
|
135
|
-
end
|
136
|
-
end
|
data/lib/merb/test/multipart.rb
DELETED
@@ -1,66 +0,0 @@
|
|
1
|
-
module Merb
|
2
|
-
module Test
|
3
|
-
module Multipart
|
4
|
-
require 'rubygems'
|
5
|
-
require 'mime/types'
|
6
|
-
|
7
|
-
class Param
|
8
|
-
attr_accessor :key, :value
|
9
|
-
def initialize(key, value)
|
10
|
-
@key = key
|
11
|
-
@value = value
|
12
|
-
end
|
13
|
-
|
14
|
-
def to_multipart
|
15
|
-
return %(Content-Disposition: form-data; name="#{key}"\r\n\r\n#{value}\r\n)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
class FileParam
|
20
|
-
attr_accessor :key, :filename, :content
|
21
|
-
def initialize(key, filename, content)
|
22
|
-
@key = key
|
23
|
-
@filename = filename
|
24
|
-
@content = content
|
25
|
-
end
|
26
|
-
|
27
|
-
def to_multipart
|
28
|
-
return %(Content-Disposition: form-data; name="#{key}"; filename="#{filename}"\r\n) + "Content-Type: #{MIME::Types.type_for(@filename)}\r\n\r\n" + content + "\r\n"
|
29
|
-
end
|
30
|
-
end
|
31
|
-
|
32
|
-
class Post
|
33
|
-
BOUNDARY = '----------0xKhTmLbOuNdArY'
|
34
|
-
CONTENT_TYPE = "multipart/form-data, boundary=" + BOUNDARY
|
35
|
-
|
36
|
-
def initialize(params = {})
|
37
|
-
@multipart_params = []
|
38
|
-
push_params(params)
|
39
|
-
end
|
40
|
-
|
41
|
-
def push_params(params, prefix = nil)
|
42
|
-
params.sort_by {|k| k.to_s}.each do |key, value|
|
43
|
-
param_key = prefix.nil? ? key : "#{prefix}[#{key}]"
|
44
|
-
if value.respond_to?(:read)
|
45
|
-
@multipart_params << FileParam.new(param_key, value.path, value.read)
|
46
|
-
else
|
47
|
-
if value.is_a?(Hash) || value.is_a?(Mash)
|
48
|
-
value.keys.each do |k|
|
49
|
-
push_params(value, param_key)
|
50
|
-
end
|
51
|
-
else
|
52
|
-
@multipart_params << Param.new(param_key, value)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
def to_multipart
|
59
|
-
query = @multipart_params.collect { |param| "--" + BOUNDARY + "\r\n" + param.to_multipart }.join("") + "--" + BOUNDARY + "--"
|
60
|
-
return query, CONTENT_TYPE
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
data/lib/merb/test/rspec.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
require 'hpricot'
|
2
|
-
require 'spec'
|
3
|
-
|
4
|
-
# Get all the rspec matchers for merb and include them
|
5
|
-
Dir[(File.dirname(__FILE__) + "/rspec_matchers/**/*.rb")].each do |file|
|
6
|
-
require "#{file[0...-3]}"
|
7
|
-
end
|
8
|
-
|
9
|
-
module Merb
|
10
|
-
module Test
|
11
|
-
module RspecMatchers
|
12
|
-
|
13
|
-
include ControllerMatchers
|
14
|
-
include MarkupMatchers
|
15
|
-
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,117 +0,0 @@
|
|
1
|
-
module Merb
|
2
|
-
module Test
|
3
|
-
module ControllerMatchers
|
4
|
-
|
5
|
-
class BeRedirect
|
6
|
-
def matches?(target)
|
7
|
-
@target = target
|
8
|
-
[301, 302].include? target
|
9
|
-
end
|
10
|
-
def failure_message
|
11
|
-
"expected to redirect"
|
12
|
-
end
|
13
|
-
def negative_failure_message
|
14
|
-
"expected not to redirect"
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class Redirect
|
19
|
-
def matches?(target)
|
20
|
-
@target = target
|
21
|
-
BeRedirect.new.matches?(target.status)
|
22
|
-
end
|
23
|
-
def failure_message
|
24
|
-
"expected #{@target.inspect} to redirect"
|
25
|
-
end
|
26
|
-
def negative_failure_message
|
27
|
-
"expected #{@target.inspect} not to redirect"
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
class RedirectTo
|
32
|
-
def initialize(expected)
|
33
|
-
@expected = expected
|
34
|
-
end
|
35
|
-
|
36
|
-
def matches?(target)
|
37
|
-
@target = target.headers['Location']
|
38
|
-
@redirected = BeRedirect.new.matches?(target.status)
|
39
|
-
@target == @expected
|
40
|
-
end
|
41
|
-
|
42
|
-
def failure_message
|
43
|
-
msg = "expected a redirect to <#{@expected}>, but "
|
44
|
-
if @redirected
|
45
|
-
msg << "found one to <#{@target}>"
|
46
|
-
else
|
47
|
-
msg << "there was no redirect"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def negative_failure_message
|
52
|
-
"expected not to redirect to <#{@expected}>, but did anyway"
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
class BeSuccess
|
57
|
-
|
58
|
-
def matches?(target)
|
59
|
-
@target = target.status
|
60
|
-
(200..299).include?(@target)
|
61
|
-
end
|
62
|
-
|
63
|
-
def failure_message
|
64
|
-
"expected #{@target} to be successful but was #{@target.status}"
|
65
|
-
end
|
66
|
-
|
67
|
-
def negative_failure_message
|
68
|
-
"expected #{@target} not to be successful but it was"
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
class BeMissing
|
73
|
-
def matches?(target)
|
74
|
-
@target = target
|
75
|
-
(400..499).include?(@target.status)
|
76
|
-
end
|
77
|
-
|
78
|
-
def failure_message
|
79
|
-
"expected #{@target} to be missing but was #{@target.status}"
|
80
|
-
end
|
81
|
-
|
82
|
-
def negative_failure_message
|
83
|
-
"expected #{@target} not to be missing but it was"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
|
88
|
-
def be_redirect
|
89
|
-
BeRedirect.new
|
90
|
-
end
|
91
|
-
|
92
|
-
def redirect
|
93
|
-
Redirect.new
|
94
|
-
end
|
95
|
-
|
96
|
-
def redirect_to(expected)
|
97
|
-
RedirectTo.new(expected)
|
98
|
-
end
|
99
|
-
|
100
|
-
def be_success
|
101
|
-
BeSuccess.new
|
102
|
-
end
|
103
|
-
|
104
|
-
def be_successful
|
105
|
-
BeSuccess.new
|
106
|
-
end
|
107
|
-
|
108
|
-
def respond_successfully
|
109
|
-
BeSuccess.new
|
110
|
-
end
|
111
|
-
|
112
|
-
def be_missing
|
113
|
-
BeMissing.new
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
117
|
-
end
|
@@ -1,98 +0,0 @@
|
|
1
|
-
module Merb
|
2
|
-
module Test
|
3
|
-
module MarkupMatchers
|
4
|
-
class HaveSelector
|
5
|
-
def initialize(expected)
|
6
|
-
@expected = expected
|
7
|
-
end
|
8
|
-
|
9
|
-
def matches?(stringlike)
|
10
|
-
@document = case stringlike
|
11
|
-
when Hpricot::Elem
|
12
|
-
stringlike
|
13
|
-
when StringIO
|
14
|
-
Hpricot.parse(stringlike.string)
|
15
|
-
else
|
16
|
-
Hpricot.parse(stringlike)
|
17
|
-
end
|
18
|
-
!@document.search(@expected).empty?
|
19
|
-
end
|
20
|
-
|
21
|
-
def failure_message
|
22
|
-
"expected following text to match selector #{@expected}:\n#{@document}"
|
23
|
-
end
|
24
|
-
|
25
|
-
def negative_failure_message
|
26
|
-
"expected following text to not match selector #{@expected}:\n#{@document}"
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
class MatchTag
|
31
|
-
def initialize(name, attrs)
|
32
|
-
@name, @attrs = name, attrs
|
33
|
-
@content = @attrs.delete(:content)
|
34
|
-
end
|
35
|
-
|
36
|
-
def matches?(target)
|
37
|
-
@errors = []
|
38
|
-
unless target.include?("<#{@name}")
|
39
|
-
@errors << "Expected a <#{@name}>, but was #{target}"
|
40
|
-
end
|
41
|
-
@attrs.each do |attr, val|
|
42
|
-
unless target.include?("#{attr}=\"#{val}\"")
|
43
|
-
@errors << "Expected #{attr}=\"#{val}\", but was #{target}"
|
44
|
-
end
|
45
|
-
end
|
46
|
-
if @content
|
47
|
-
unless target.include?(">#{@content}<")
|
48
|
-
@errors << "Expected #{target} to include #{@content}"
|
49
|
-
end
|
50
|
-
end
|
51
|
-
@errors.size == 0
|
52
|
-
end
|
53
|
-
|
54
|
-
def failure_message
|
55
|
-
@errors[0]
|
56
|
-
end
|
57
|
-
|
58
|
-
def negative_failure_message
|
59
|
-
"Expected not to match against <#{@name} #{@attrs.map{ |a,v| "#{a}=\"#{v}\"" }.join(" ")}> tag, but it matched"
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
class NotMatchTag
|
64
|
-
def initialize(attrs)
|
65
|
-
@attrs = attrs
|
66
|
-
end
|
67
|
-
|
68
|
-
def matches?(target)
|
69
|
-
@errors = []
|
70
|
-
@attrs.each do |attr, val|
|
71
|
-
if target.include?("#{attr}=\"#{val}\"")
|
72
|
-
@errors << "Should not include #{attr}=\"#{val}\", but was #{target}"
|
73
|
-
end
|
74
|
-
end
|
75
|
-
@errors.size == 0
|
76
|
-
end
|
77
|
-
|
78
|
-
def failure_message
|
79
|
-
@errors[0]
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
def match_tag(name, attrs={})
|
84
|
-
MatchTag.new(name, attrs)
|
85
|
-
end
|
86
|
-
def not_match_tag(attrs)
|
87
|
-
NotMatchTag.new(attrs)
|
88
|
-
end
|
89
|
-
|
90
|
-
def have_selector(expected)
|
91
|
-
HaveSelector.new(expected)
|
92
|
-
end
|
93
|
-
alias_method :match_selector, :have_selector
|
94
|
-
|
95
|
-
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
data/lib/merb/upload_handler.rb
DELETED
@@ -1,80 +0,0 @@
|
|
1
|
-
module Mongrel
|
2
|
-
module Const
|
3
|
-
POST = 'POST'.freeze unless const_defined?(:POST)
|
4
|
-
PUT = 'PUT'.freeze unless const_defined?(:PUT)
|
5
|
-
QUERY_STRING = 'QUERY_STRING'.freeze unless const_defined?(:QUERY_STRING)
|
6
|
-
UPLOAD_ID = 'upload_id'.freeze
|
7
|
-
end
|
8
|
-
|
9
|
-
unless ENV['EVENT'] || ENV['SWIFT']
|
10
|
-
HttpHandler.class_eval do
|
11
|
-
def request_aborted(params)
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
HttpRequest.class_eval do
|
16
|
-
def initialize_with_abort(params, socket, dispatchers)
|
17
|
-
initialize_without_abort(params, socket, dispatchers)
|
18
|
-
dispatchers.each {|d| d.request_aborted(params) if @body.nil? && d }
|
19
|
-
end
|
20
|
-
|
21
|
-
alias_method :initialize_without_abort, :initialize
|
22
|
-
alias_method :initialize, :initialize_with_abort
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
|
28
|
-
class MerbUploadHandler < Mongrel::HttpHandler
|
29
|
-
|
30
|
-
def initialize(options = {})
|
31
|
-
@path_match = Regexp.new(options[:upload_path_match])
|
32
|
-
@frequency = options[:upload_frequency] || 3
|
33
|
-
@request_notify = true
|
34
|
-
if options[:start_drb]
|
35
|
-
require 'drb'
|
36
|
-
DRb.start_service
|
37
|
-
Mongrel.const_set :Uploads, DRbObject.new(nil, "druby://#{options[:host]}:#{options[:drb_server_port]}").upload_progress
|
38
|
-
else
|
39
|
-
Mongrel.const_set :Uploads, Merb::UploadProgress.new
|
40
|
-
end
|
41
|
-
Mongrel::Uploads.debug = true if options[:debug]
|
42
|
-
end
|
43
|
-
|
44
|
-
def request_begins(params)
|
45
|
-
upload_notify(:add, params, params[Mongrel::Const::CONTENT_LENGTH].to_i)
|
46
|
-
end
|
47
|
-
|
48
|
-
def request_progress(params, clen, total)
|
49
|
-
upload_notify(:mark, params, clen)
|
50
|
-
end
|
51
|
-
|
52
|
-
def process(request, response)
|
53
|
-
upload_notify(:finish, request.params)
|
54
|
-
end
|
55
|
-
|
56
|
-
def request_aborted(params)
|
57
|
-
return unless upload_id = valid_upload?(params)
|
58
|
-
Mongrel::Uploads.finish(upload_id)
|
59
|
-
Merb.logger.info "#{self.class.name} - request aborted for " <<
|
60
|
-
"id: #{upload_id.inspect}, params: #{params.inspect}"
|
61
|
-
end
|
62
|
-
|
63
|
-
private
|
64
|
-
def upload_notify(action, params, *args)
|
65
|
-
return unless upload_id = valid_upload?(params)
|
66
|
-
if action == :mark
|
67
|
-
last_checked_time = Mongrel::Uploads.last_checked(upload_id)
|
68
|
-
return unless last_checked_time && Time.now - last_checked_time > @frequency
|
69
|
-
end
|
70
|
-
Mongrel::Uploads.send(action, upload_id, *args)
|
71
|
-
Mongrel::Uploads.update_checked_time(upload_id) unless action == :finish
|
72
|
-
end
|
73
|
-
|
74
|
-
def valid_upload?(params)
|
75
|
-
params[Mongrel::Const::PATH_INFO].match(@path_match) &&
|
76
|
-
[Mongrel::Const::POST, Mongrel::Const::PUT].include?(params[Mongrel::Const::REQUEST_METHOD]) &&
|
77
|
-
Mongrel::HttpRequest.query_parse(params[Mongrel::Const::QUERY_STRING])[Mongrel::Const::UPLOAD_ID]
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|