merb 0.5.3 → 0.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/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/spec/merb/cookies_spec.rb
DELETED
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../spec_helper'
|
|
2
|
-
|
|
3
|
-
module CookiesSpecModule
|
|
4
|
-
def cookie_time(time)
|
|
5
|
-
time.gmtime.strftime(Merb::Const::COOKIE_EXPIRATION_FORMAT)
|
|
6
|
-
end
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
describe Merb::Cookies do
|
|
10
|
-
include CookiesSpecModule
|
|
11
|
-
|
|
12
|
-
before do
|
|
13
|
-
@_cookies = Mash.new
|
|
14
|
-
@_headers = {}
|
|
15
|
-
@cookies = Merb::Cookies.new(@_cookies, @_headers)
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "should respond to []" do
|
|
19
|
-
@cookies.should respond_to(:[])
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should respond to []=" do
|
|
23
|
-
@cookies.should respond_to(:[]=)
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it "should respond to delete" do
|
|
27
|
-
@cookies.should respond_to(:delete)
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it "should accept simple cookies that expire at end of session" do
|
|
31
|
-
@cookies[:foo] = 'bar'
|
|
32
|
-
|
|
33
|
-
@_headers['Set-Cookie'].should == ['foo=bar; path=/;']
|
|
34
|
-
|
|
35
|
-
@cookies[:foo].should == 'bar'
|
|
36
|
-
@cookies['foo'].should == 'bar'
|
|
37
|
-
end
|
|
38
|
-
|
|
39
|
-
it "should accept cookies with expiry dates" do
|
|
40
|
-
expires = Time.now + 2.weeks
|
|
41
|
-
@cookies[:dozen] = {
|
|
42
|
-
:value => 'twelve',
|
|
43
|
-
:expires => expires
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
@_headers['Set-Cookie'].should ==
|
|
47
|
-
["dozen=twelve; expires=%s; path=/;" % cookie_time(expires)]
|
|
48
|
-
|
|
49
|
-
@cookies[:dozen].should == 'twelve'
|
|
50
|
-
@cookies['dozen'].should == 'twelve'
|
|
51
|
-
end
|
|
52
|
-
|
|
53
|
-
it "should accept multiple cookies" do
|
|
54
|
-
expires = Time.now + 2.weeks
|
|
55
|
-
@cookies[:foo] = 'bar'
|
|
56
|
-
@cookies[:dozen] = {
|
|
57
|
-
:value => 'twelve',
|
|
58
|
-
:expires => expires
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
@_headers['Set-Cookie'].should == [
|
|
62
|
-
'foo=bar; path=/;',
|
|
63
|
-
"dozen=twelve; expires=%s; path=/;" % cookie_time(expires)
|
|
64
|
-
]
|
|
65
|
-
|
|
66
|
-
@cookies[:dozen].should == 'twelve'
|
|
67
|
-
@cookies['dozen'].should == 'twelve'
|
|
68
|
-
@cookies[:foo].should == 'bar'
|
|
69
|
-
@cookies['foo'].should == 'bar'
|
|
70
|
-
end
|
|
71
|
-
|
|
72
|
-
it "should give access to currently saved cookies" do
|
|
73
|
-
@_cookies[:original] = 'accessible'
|
|
74
|
-
@cookies[:original].should == 'accessible'
|
|
75
|
-
|
|
76
|
-
@cookies[:foo] = 'bar'
|
|
77
|
-
@cookies[:foo].should == 'bar'
|
|
78
|
-
@cookies[:original].should == 'accessible'
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it "should overwrite old cookies with new cookies" do
|
|
82
|
-
@_cookies[:foo] = 'bar'
|
|
83
|
-
@cookies[:foo].should == 'bar'
|
|
84
|
-
|
|
85
|
-
@cookies[:foo] = 'new'
|
|
86
|
-
@cookies[:foo].should == 'new'
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
it "should allow deleting of cookies" do
|
|
90
|
-
@_cookies[:foo] = 'bar'
|
|
91
|
-
@cookies[:foo].should == 'bar'
|
|
92
|
-
|
|
93
|
-
@cookies.delete(:foo)
|
|
94
|
-
@cookies[:foo].should == nil
|
|
95
|
-
end
|
|
96
|
-
end
|
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
-
|
|
3
|
-
# Class cattr_reader
|
|
4
|
-
|
|
5
|
-
class ClassWithCAttrReader
|
|
6
|
-
cattr_reader :bacon
|
|
7
|
-
def initialize; @@bacon = "chunky"; end
|
|
8
|
-
end
|
|
9
|
-
|
|
10
|
-
describe "Core Class with cattr_reader", :shared => true do
|
|
11
|
-
|
|
12
|
-
it "should read value from attribute" do
|
|
13
|
-
@klass.bacon.should == "chunky"
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should not write to attribute" do
|
|
17
|
-
lambda {
|
|
18
|
-
@klass.bacon = "soggy"
|
|
19
|
-
}.should raise_error(NoMethodError)
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
describe Class, "with cattr_reader" do
|
|
25
|
-
|
|
26
|
-
before do
|
|
27
|
-
@klass = ClassWithCAttrReader.new.class
|
|
28
|
-
end
|
|
29
|
-
it_should_behave_like "Core Class with cattr_reader"
|
|
30
|
-
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
describe Class, "with cattr_reader (instantiated)" do
|
|
34
|
-
|
|
35
|
-
before do
|
|
36
|
-
@klass = ClassWithCAttrReader.new
|
|
37
|
-
end
|
|
38
|
-
it_should_behave_like "Core Class with cattr_reader"
|
|
39
|
-
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
# Class cattr_writer
|
|
43
|
-
|
|
44
|
-
class ClassWithCAttrWriter
|
|
45
|
-
cattr_writer :bacon
|
|
46
|
-
def self.chunky?; @@bacon == "chunky"; end
|
|
47
|
-
def chunky?; self.class.chunky?; end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
describe "Core Class with cattr_writer", :shared => true do
|
|
51
|
-
|
|
52
|
-
it "should write value to attribute" do
|
|
53
|
-
@klass.should be_chunky
|
|
54
|
-
end
|
|
55
|
-
|
|
56
|
-
it "should not read attribute" do
|
|
57
|
-
lambda {
|
|
58
|
-
@klass.bacon
|
|
59
|
-
}.should raise_error(NoMethodError)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
end
|
|
63
|
-
|
|
64
|
-
describe Class, "with cattr_writer" do
|
|
65
|
-
|
|
66
|
-
before do
|
|
67
|
-
@klass = ClassWithCAttrWriter.new.class
|
|
68
|
-
@klass.bacon = "chunky"
|
|
69
|
-
end
|
|
70
|
-
it_should_behave_like "Core Class with cattr_writer"
|
|
71
|
-
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
describe Class, "with cattr_writer (instantiated)" do
|
|
75
|
-
|
|
76
|
-
before do
|
|
77
|
-
@klass = ClassWithCAttrWriter.new
|
|
78
|
-
@klass.bacon = "chunky"
|
|
79
|
-
end
|
|
80
|
-
it_should_behave_like "Core Class with cattr_writer"
|
|
81
|
-
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
class ClassWithAttrInitialize
|
|
85
|
-
attr_initialize :dog, :muppet
|
|
86
|
-
attr_accessor :dog, :muppet
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
describe ClassWithAttrInitialize do
|
|
90
|
-
|
|
91
|
-
it "should initialize with values" do
|
|
92
|
-
c = ClassWithAttrInitialize.new("louie", "bert")
|
|
93
|
-
c.dog.should == "louie"
|
|
94
|
-
c.muppet.should == "bert"
|
|
95
|
-
end
|
|
96
|
-
|
|
97
|
-
end
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Enumerable do
|
|
4
|
-
before do
|
|
5
|
-
@mascots = ['louie', 'bert', 'ernie']
|
|
6
|
-
end
|
|
7
|
-
|
|
8
|
-
it "should perform injecting" do
|
|
9
|
-
@mascots.injecting({}) { |m,i| m[i] = i.size }.should ==
|
|
10
|
-
{ 'louie' => 5, 'bert' => 4, 'ernie' => 5 }
|
|
11
|
-
end
|
|
12
|
-
|
|
13
|
-
it "should find arrays of things inside other arrays" do
|
|
14
|
-
@mascots.include_any?('louie', 'sasquatch').should be_true
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "should recognize absence of arrays of things inside other arrays" do
|
|
18
|
-
@mascots.include_any?('chicken', 'sasquatch').should be_false
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "should group by" do
|
|
22
|
-
groups = (1..6).group_by{ |i| i % 3 }
|
|
23
|
-
groups[0].should == [3,6]
|
|
24
|
-
groups[1].should == [1,4]
|
|
25
|
-
groups[2].should == [2,5]
|
|
26
|
-
end
|
|
27
|
-
end
|
|
@@ -1,251 +0,0 @@
|
|
|
1
|
-
require File.dirname(__FILE__) + '/../../spec_helper'
|
|
2
|
-
|
|
3
|
-
describe Hash, "environmentize_keys!" do
|
|
4
|
-
it "should transform keys to uppercase text" do
|
|
5
|
-
{ :test_1 => 'test', 'test_2' => 'test', 1 => 'test' }.environmentize_keys!.should ==
|
|
6
|
-
{ 'TEST_1' => 'test', 'TEST_2' => 'test', '1' => 'test' }
|
|
7
|
-
end
|
|
8
|
-
|
|
9
|
-
it "should only transform one level of keys" do
|
|
10
|
-
{ :test_1 => { :test2 => 'test'} }.environmentize_keys!.should ==
|
|
11
|
-
{ 'TEST_1' => { :test2 => 'test'} }
|
|
12
|
-
end
|
|
13
|
-
end
|
|
14
|
-
|
|
15
|
-
describe Hash, "only" do
|
|
16
|
-
before do
|
|
17
|
-
@hash = { :one => 'ONE', 'two' => 'TWO', 3 => 'THREE' }
|
|
18
|
-
end
|
|
19
|
-
|
|
20
|
-
it "should return a hash with only the given key(s)" do
|
|
21
|
-
@hash.only(:one).should == { :one => 'ONE' }
|
|
22
|
-
@hash.only(:one, 3).should == { :one => 'ONE', 3 => 'THREE' }
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
describe Hash, "except" do
|
|
27
|
-
before do
|
|
28
|
-
@hash = { :one => 'ONE', 'two' => 'TWO', 3 => 'THREE' }
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
it "should return a hash without only the given key(s)" do
|
|
32
|
-
@hash.except(:one).should == { 'two' => 'TWO', 3 => 'THREE' }
|
|
33
|
-
@hash.except(:one, 3).should == { 'two' => 'TWO' }
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
describe Hash, "symbolize_keys!" do
|
|
38
|
-
before do
|
|
39
|
-
@hash = { 'one' => 1, 'two' => 2 }
|
|
40
|
-
@hash_with_another_hash = { 'a' => 'A', 'prefs' => { 'private' => true, 'sex' => 'yes please' } }
|
|
41
|
-
@hash_with_non_string_keys = { 'one' => 1, 2 => 'TWO', '' => 'blank' }
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
it "should convert all keys to symbols" do
|
|
45
|
-
@hash.symbolize_keys!
|
|
46
|
-
@hash.should == { :one => 1, :two => 2 }
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "should recursively convert all keys to symbols" do
|
|
50
|
-
@hash_with_another_hash.symbolize_keys!
|
|
51
|
-
@hash_with_another_hash.should == { :a => 'A', :prefs => { :private => true, :sex => 'yes please' } }
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
describe Hash, "to_xml_attributes" do
|
|
56
|
-
before do
|
|
57
|
-
@hash = { :one => "ONE", "two" => "TWO" }
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
it "should turn the hash into xml attributes" do
|
|
61
|
-
attrs = @hash.to_xml_attributes
|
|
62
|
-
attrs.should match(/one="ONE"/m)
|
|
63
|
-
attrs.should match(/two="TWO"/m)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
describe Hash, "from_xml" do
|
|
68
|
-
it "should transform a simple tag with content" do
|
|
69
|
-
xml = "<tag>This is the contents</tag>"
|
|
70
|
-
Hash.from_xml(xml).should == { 'tag' => 'This is the contents' }
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
it "should work with cdata tags" do
|
|
74
|
-
xml = <<-END
|
|
75
|
-
<tag>
|
|
76
|
-
<![CDATA[
|
|
77
|
-
text inside cdata
|
|
78
|
-
]]>
|
|
79
|
-
</tag>
|
|
80
|
-
END
|
|
81
|
-
Hash.from_xml(xml)["tag"].strip.should == "text inside cdata"
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
it "should transform a simple tag with attributes" do
|
|
85
|
-
xml = "<tag attr1='1' attr2='2'></tag>"
|
|
86
|
-
hash = { 'tag' => { 'attr1' => '1', 'attr2' => '2' } }
|
|
87
|
-
Hash.from_xml(xml).should == hash
|
|
88
|
-
end
|
|
89
|
-
|
|
90
|
-
it "should transform repeating siblings into an array" do
|
|
91
|
-
xml =<<-XML
|
|
92
|
-
<opt>
|
|
93
|
-
<user login="grep" fullname="Gary R Epstein" />
|
|
94
|
-
<user login="stty" fullname="Simon T Tyson" />
|
|
95
|
-
</opt>
|
|
96
|
-
XML
|
|
97
|
-
|
|
98
|
-
Hash.from_xml(xml)['opt']['user'].should be_an_instance_of(Array)
|
|
99
|
-
|
|
100
|
-
hash = {
|
|
101
|
-
'opt' => {
|
|
102
|
-
'user' => [{
|
|
103
|
-
'login' => 'grep',
|
|
104
|
-
'fullname' => 'Gary R Epstein'
|
|
105
|
-
},{
|
|
106
|
-
'login' => 'stty',
|
|
107
|
-
'fullname' => 'Simon T Tyson'
|
|
108
|
-
}]
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
Hash.from_xml(xml).should == hash
|
|
113
|
-
end
|
|
114
|
-
|
|
115
|
-
it "should not transform non-repeating siblings into an array" do
|
|
116
|
-
xml =<<-XML
|
|
117
|
-
<opt>
|
|
118
|
-
<user login="grep" fullname="Gary R Epstein" />
|
|
119
|
-
</opt>
|
|
120
|
-
XML
|
|
121
|
-
|
|
122
|
-
Hash.from_xml(xml)['opt']['user'].should be_an_instance_of(Hash)
|
|
123
|
-
|
|
124
|
-
hash = {
|
|
125
|
-
'opt' => {
|
|
126
|
-
'user' => {
|
|
127
|
-
'login' => 'grep',
|
|
128
|
-
'fullname' => 'Gary R Epstein'
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
Hash.from_xml(xml).should == hash
|
|
134
|
-
end
|
|
135
|
-
|
|
136
|
-
it "should typecast an integer" do
|
|
137
|
-
xml = "<tag type='integer'>10</tag>"
|
|
138
|
-
Hash.from_xml(xml)['tag'].should == 10
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
it "should typecast a true boolean" do
|
|
142
|
-
xml = "<tag type='boolean'>true</tag>"
|
|
143
|
-
Hash.from_xml(xml)['tag'].should be_true
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
it "should typecast a false boolean" do
|
|
147
|
-
["false", "1", "0", "some word" ].each do |w|
|
|
148
|
-
Hash.from_xml("<tag type='boolean'>#{w}</tag>")['tag'].should be_false
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
it "should typecast a datetime" do
|
|
153
|
-
xml = "<tag type='datetime'>2007-12-31 10:32</tag>"
|
|
154
|
-
Hash.from_xml(xml)['tag'].should == Time.parse( '2007-12-31 10:32' ).utc
|
|
155
|
-
end
|
|
156
|
-
|
|
157
|
-
it "should typecast a date" do
|
|
158
|
-
xml = "<tag type='date'>2007-12-31</tag>"
|
|
159
|
-
Hash.from_xml(xml)['tag'].should == Date.parse('2007-12-31')
|
|
160
|
-
end
|
|
161
|
-
|
|
162
|
-
it "should unescape html entities" do
|
|
163
|
-
values = {
|
|
164
|
-
"<" => "<",
|
|
165
|
-
">" => ">",
|
|
166
|
-
'"' => """,
|
|
167
|
-
"'" => "'",
|
|
168
|
-
"&" => "&"
|
|
169
|
-
}
|
|
170
|
-
values.each do |k,v|
|
|
171
|
-
xml = "<tag>Some content #{v}</tag>"
|
|
172
|
-
Hash.from_xml(xml)['tag'].should match(Regexp.new(k))
|
|
173
|
-
end
|
|
174
|
-
end
|
|
175
|
-
|
|
176
|
-
it "should undasherize keys as tags" do
|
|
177
|
-
xml = "<tag-1>Stuff</tag-1>"
|
|
178
|
-
Hash.from_xml(xml).keys.should include( 'tag_1' )
|
|
179
|
-
end
|
|
180
|
-
|
|
181
|
-
it "should undasherize keys as attributes" do
|
|
182
|
-
xml = "<tag1 attr-1='1'></tag1>"
|
|
183
|
-
Hash.from_xml(xml)['tag1'].keys.should include( 'attr_1')
|
|
184
|
-
end
|
|
185
|
-
|
|
186
|
-
it "should undasherize keys as tags and attributes" do
|
|
187
|
-
xml = "<tag-1 attr-1='1'></tag-1>"
|
|
188
|
-
Hash.from_xml(xml).keys.should include( 'tag_1' )
|
|
189
|
-
Hash.from_xml(xml)['tag_1'].keys.should include( 'attr_1')
|
|
190
|
-
end
|
|
191
|
-
|
|
192
|
-
it "should render nested content correctly" do
|
|
193
|
-
xml = "<root><tag1>Tag1 Content <em><strong>This is strong</strong></em></tag1></root>"
|
|
194
|
-
Hash.from_xml(xml)['root']['tag1'].should == "Tag1 Content <em><strong>This is strong</strong></em>"
|
|
195
|
-
end
|
|
196
|
-
|
|
197
|
-
it "should render nested content with split text nodes correctly" do
|
|
198
|
-
xml = "<root>Tag1 Content<em>Stuff</em> Hi There</root>"
|
|
199
|
-
Hash.from_xml(xml)['root'].should == "Tag1 Content<em>Stuff</em> Hi There"
|
|
200
|
-
end
|
|
201
|
-
|
|
202
|
-
it "should ignore attributes when a child is a text node" do
|
|
203
|
-
xml = "<root attr1='1'>Stuff</root>"
|
|
204
|
-
Hash.from_xml(xml).should == { "root" => "Stuff" }
|
|
205
|
-
end
|
|
206
|
-
|
|
207
|
-
it "should ignore attributes when any child is a text node" do
|
|
208
|
-
xml = "<root attr1='1'>Stuff <em>in italics</em></root>"
|
|
209
|
-
Hash.from_xml(xml).should == { "root" => "Stuff <em>in italics</em>" }
|
|
210
|
-
end
|
|
211
|
-
|
|
212
|
-
it "should correctly transform multiple children" do
|
|
213
|
-
xml = <<-XML
|
|
214
|
-
<user gender='m'>
|
|
215
|
-
<age type='integer'>35</age>
|
|
216
|
-
<name>Home Simpson</name>
|
|
217
|
-
<dob type='date'>1988-01-01</dob>
|
|
218
|
-
<joined-at type='datetime'>2000-04-28 23:01</joined-at>
|
|
219
|
-
<is-cool type='boolean'>true</is-cool>
|
|
220
|
-
</user>
|
|
221
|
-
XML
|
|
222
|
-
|
|
223
|
-
hash = {
|
|
224
|
-
"user" => {
|
|
225
|
-
"gender" => "m",
|
|
226
|
-
"age" => 35,
|
|
227
|
-
"name" => "Home Simpson",
|
|
228
|
-
"dob" => Date.parse('1988-01-01'),
|
|
229
|
-
"joined_at" => Time.parse("2000-04-28 23:01"),
|
|
230
|
-
"is_cool" => true
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
Hash.from_xml(xml).should == hash
|
|
235
|
-
end
|
|
236
|
-
end
|
|
237
|
-
|
|
238
|
-
describe Hash, 'to_params' do
|
|
239
|
-
before do
|
|
240
|
-
@hash = { :name => 'Bob', :address => { :street => '111 Ruby Ave.', :city => 'Ruby Central', :phones => ['111-111-1111', '222-222-2222'] } }
|
|
241
|
-
end
|
|
242
|
-
|
|
243
|
-
it 'should convert correctly into query parameters' do
|
|
244
|
-
@hash.to_params.split('&').sort.should ==
|
|
245
|
-
'name=Bob&address[city]=Ruby Central&address[phones]=111-111-1111222-222-2222&address[street]=111 Ruby Ave.'.split('&').sort
|
|
246
|
-
end
|
|
247
|
-
|
|
248
|
-
it 'should not leave a trailing &' do
|
|
249
|
-
@hash.to_params.should_not match(/&$/)
|
|
250
|
-
end
|
|
251
|
-
end
|