merb 0.4.0 → 0.4.1

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.
Files changed (143) hide show
  1. data/README +23 -160
  2. data/Rakefile +15 -14
  3. data/app_generators/merb/merb_generator.rb +4 -3
  4. data/app_generators/merb/templates/Rakefile +1 -6
  5. data/app_generators/merb/templates/app/mailers/views/layout/{application.erb → application.html.erb} +0 -0
  6. data/app_generators/merb/templates/app/mailers/views/layout/application.text.erb +1 -0
  7. data/app_generators/merb/templates/app/parts/views/layout/application.html.erb +1 -0
  8. data/app_generators/merb/templates/app/views/layout/application.html.erb +2 -2
  9. data/app_generators/merb/templates/config/dependencies.rb +1 -1
  10. data/app_generators/merb/templates/config/router.rb +4 -1
  11. data/app_generators/merb/templates/spec/spec_helper.rb +2 -3
  12. data/lib/autotest/merb_rspec.rb +1 -0
  13. data/lib/merb/abstract_controller.rb +31 -2
  14. data/lib/merb/controller.rb +5 -5
  15. data/lib/merb/core_ext/get_args.rb +5 -1
  16. data/lib/merb/exceptions.rb +17 -0
  17. data/lib/merb/generators/merb_app/merb_app.rb +4 -1
  18. data/lib/merb/generators/merb_plugin.rb +4 -1
  19. data/lib/merb/logger.rb +5 -1
  20. data/lib/merb/mail_controller.rb +1 -1
  21. data/lib/merb/mailer.rb +2 -2
  22. data/lib/merb/mixins/controller.rb +5 -1
  23. data/lib/merb/mixins/render.rb +57 -27
  24. data/lib/merb/part_controller.rb +1 -1
  25. data/lib/merb/request.rb +2 -2
  26. data/lib/merb/server.rb +33 -5
  27. data/lib/merb/template/erubis.rb +1 -1
  28. data/lib/merb.rb +15 -5
  29. data/merb_generators/resource/resource_generator.rb +9 -2
  30. data/spec/fixtures/config/merb.yml +18 -0
  31. data/spec/fixtures/controllers/dispatch_spec_controllers.rb +227 -0
  32. data/spec/fixtures/controllers/render_spec_controllers.rb +115 -0
  33. data/spec/fixtures/foo.rb +3 -0
  34. data/spec/fixtures/mailers/views/layout/application.html.erb +3 -0
  35. data/spec/fixtures/mailers/views/layout/application.text.erb +3 -0
  36. data/spec/fixtures/mailers/views/test_mail_controller/eighth.html.erb +1 -0
  37. data/spec/fixtures/mailers/views/test_mail_controller/eighth.text.erb +1 -0
  38. data/spec/fixtures/mailers/views/test_mail_controller/first.html.erb +1 -0
  39. data/spec/fixtures/mailers/views/test_mail_controller/first.text.erb +1 -0
  40. data/spec/fixtures/mailers/views/test_mail_controller/ninth.html.erb +1 -0
  41. data/spec/fixtures/mailers/views/test_mail_controller/ninth.text.erb +1 -0
  42. data/spec/fixtures/mailers/views/test_mail_controller/second.text.erb +1 -0
  43. data/spec/fixtures/mailers/views/test_mail_controller/third.html.erb +1 -0
  44. data/spec/fixtures/models/router_spec_models.rb +20 -0
  45. data/spec/fixtures/parts/views/layout/todo_part.html.erb +3 -0
  46. data/spec/fixtures/parts/views/layout/todo_part.xml.erb +3 -0
  47. data/spec/fixtures/parts/views/todo_part/formatted_output.html.erb +1 -0
  48. data/spec/fixtures/parts/views/todo_part/formatted_output.js.erb +1 -0
  49. data/spec/fixtures/parts/views/todo_part/formatted_output.xml.erb +1 -0
  50. data/spec/fixtures/parts/views/todo_part/list.html.erb +3 -0
  51. data/spec/fixtures/sample.txt +1 -0
  52. data/spec/fixtures/views/erubis.html.erb +1 -0
  53. data/spec/fixtures/views/examples/_erubis.html.erb +1 -0
  54. data/spec/fixtures/views/examples/_haml.html.haml +1 -0
  55. data/spec/fixtures/views/examples/_markaby.html.mab +1 -0
  56. data/spec/fixtures/views/examples/_throw_content.html.erb +6 -0
  57. data/spec/fixtures/views/examples/hello.xml.builder +1 -0
  58. data/spec/fixtures/views/examples/js.js.erb +1 -0
  59. data/spec/fixtures/views/examples/template_catch_content.html.erb +15 -0
  60. data/spec/fixtures/views/examples/template_catch_content_from_partial.html.erb +6 -0
  61. data/spec/fixtures/views/examples/template_throw_content.html.erb +10 -0
  62. data/spec/fixtures/views/exceptions/admin_access_required.html.erb +1 -0
  63. data/spec/fixtures/views/extension_template_controller/_nested_js.js.erb +1 -0
  64. data/spec/fixtures/views/extension_template_controller/_nested_xml.xml.erb +1 -0
  65. data/spec/fixtures/views/extension_template_controller/_render_partial_multiple_times.html.erb +1 -0
  66. data/spec/fixtures/views/extension_template_controller/erubis_templates.html.erb +1 -0
  67. data/spec/fixtures/views/extension_template_controller/erubis_templates.js.erb +1 -0
  68. data/spec/fixtures/views/extension_template_controller/erubis_templates.rhtml +1 -0
  69. data/spec/fixtures/views/extension_template_controller/erubis_templates.xml.erb +1 -0
  70. data/spec/fixtures/views/extension_template_controller/haml_index.html.haml +0 -0
  71. data/spec/fixtures/views/extension_template_controller/haml_templates.html.haml +1 -0
  72. data/spec/fixtures/views/extension_template_controller/haml_templates.js.haml +1 -0
  73. data/spec/fixtures/views/extension_template_controller/haml_templates.xml.haml +1 -0
  74. data/spec/fixtures/views/extension_template_controller/index.html.erb +0 -0
  75. data/spec/fixtures/views/extension_template_controller/markaby_index.html.mab +0 -0
  76. data/spec/fixtures/views/extension_template_controller/markaby_templates.html.mab +1 -0
  77. data/spec/fixtures/views/extension_template_controller/markaby_templates.js.mab +1 -0
  78. data/spec/fixtures/views/extension_template_controller/markaby_templates.xml.mab +1 -0
  79. data/spec/fixtures/views/extension_template_controller/render_multiple_partials.html.erb +4 -0
  80. data/spec/fixtures/views/extension_template_controller/render_nested_js.js.erb +1 -0
  81. data/spec/fixtures/views/extension_template_controller/render_nested_xml.xml.erb +1 -0
  82. data/spec/fixtures/views/haml.html.haml +1 -0
  83. data/spec/fixtures/views/haml.xml.haml +2 -0
  84. data/spec/fixtures/views/layout/application.html.erb +1 -0
  85. data/spec/fixtures/views/layout/application.xml.erb +1 -0
  86. data/spec/fixtures/views/layout/nested/example.html.erb +1 -0
  87. data/spec/fixtures/views/markaby.html.mab +1 -0
  88. data/spec/fixtures/views/nested/example/test.html.erb +1 -0
  89. data/spec/fixtures/views/partials/_erubis.html.erb +1 -0
  90. data/spec/fixtures/views/partials/_erubis_collection.html.erb +1 -0
  91. data/spec/fixtures/views/partials/_erubis_collection_with_locals.html.erb +1 -0
  92. data/spec/fixtures/views/partials/_erubis_new.html.erb +1 -0
  93. data/spec/fixtures/views/partials/_haml.html.haml +1 -0
  94. data/spec/fixtures/views/partials/_haml_collection.html.haml +1 -0
  95. data/spec/fixtures/views/partials/_haml_collection_with_locals.html.haml +1 -0
  96. data/spec/fixtures/views/partials/_haml_new.html.haml +1 -0
  97. data/spec/fixtures/views/partials/_markaby.html.mab +1 -0
  98. data/spec/fixtures/views/partials/_markaby_collection.html.mab +1 -0
  99. data/spec/fixtures/views/partials/_markaby_collection_with_locals.html.mab +1 -0
  100. data/spec/fixtures/views/partials/_markaby_new.html.mab +1 -0
  101. data/spec/fixtures/views/render_object_controller/render_object_with_template.html.erb +1 -0
  102. data/spec/fixtures/views/render_object_controller/render_object_with_template.js.erb +1 -0
  103. data/spec/fixtures/views/render_object_controller/render_object_with_template.xml.erb +1 -0
  104. data/spec/fixtures/views/template_views/interface__buffer_erubis.html.erb +4 -0
  105. data/spec/fixtures/views/template_views/interface__buffer_haml.html.haml +7 -0
  106. data/spec/fixtures/views/template_views/interface__buffer_markaby.html.mab +7 -0
  107. data/spec/fixtures/views/template_views/interface_capture_erubis.html.erb +15 -0
  108. data/spec/fixtures/views/template_views/interface_capture_haml.html.haml +15 -0
  109. data/spec/fixtures/views/template_views/interface_capture_markaby.html.mab +4 -0
  110. data/spec/fixtures/views/template_views/interface_concat_erubis.html.erb +12 -0
  111. data/spec/fixtures/views/template_views/interface_concat_haml.html.haml +11 -0
  112. data/spec/fixtures/views/template_views/interface_concat_markaby.html.mab +14 -0
  113. data/spec/fixtures/views/test.dir/the_template.html.erb +1 -0
  114. data/spec/merb/abstract_controller_spec.rb +37 -0
  115. data/spec/merb/caching_spec.rb +102 -0
  116. data/spec/merb/config_spec.rb +29 -0
  117. data/spec/merb/controller_filters_spec.rb +188 -0
  118. data/spec/merb/controller_spec.rb +144 -0
  119. data/spec/merb/cookie_store_spec.rb +85 -0
  120. data/spec/merb/core_ext_spec.rb +430 -0
  121. data/spec/merb/dispatch_spec.rb +514 -0
  122. data/spec/merb/fake_request_spec.rb +72 -0
  123. data/spec/merb/form_control_mixin_spec.rb +431 -0
  124. data/spec/merb/generator_spec.rb +121 -0
  125. data/spec/merb/handler_spec.rb +169 -0
  126. data/spec/merb/mail_controller_spec.rb +144 -0
  127. data/spec/merb/mailer_spec.rb +87 -0
  128. data/spec/merb/multipart_spec.rb +49 -0
  129. data/spec/merb/part_controller_spec.rb +92 -0
  130. data/spec/merb/plugins_spec.rb +80 -0
  131. data/spec/merb/render_spec.rb +378 -0
  132. data/spec/merb/request_spec.rb +243 -0
  133. data/spec/merb/responder_spec.rb +561 -0
  134. data/spec/merb/router_spec.rb +726 -0
  135. data/spec/merb/template_spec.rb +41 -0
  136. data/spec/merb/upload_handler_spec.rb +101 -0
  137. data/spec/merb/view_context_spec.rb +148 -0
  138. data/spec/spec_generator_helper.rb +19 -0
  139. data/spec/spec_helper.rb +88 -0
  140. metadata +203 -65
  141. data/lib/merb/caching/store/memcache.rb +0 -20
  142. data/script/destroy +0 -14
  143. data/script/generate +0 -14
@@ -0,0 +1,20 @@
1
+ class Blogposts
2
+ def to_param
3
+ id
4
+ end
5
+ def id
6
+ 42
7
+ end
8
+ end
9
+
10
+ class Comment
11
+ def to_param
12
+ id
13
+ end
14
+ def id
15
+ 24
16
+ end
17
+ def blogpost_id
18
+ 42
19
+ end
20
+ end
@@ -0,0 +1,3 @@
1
+ TODOLAYOUT
2
+ <%= catch_content :layout %>
3
+ TODOLAYOUT
@@ -0,0 +1,3 @@
1
+ <todolayout>
2
+ <%= catch_content :layout %>
3
+ </todolayout>
@@ -0,0 +1 @@
1
+ part_html_format
@@ -0,0 +1 @@
1
+ part_js_format
@@ -0,0 +1 @@
1
+ part_xml_format
@@ -0,0 +1,3 @@
1
+ TODOPART
2
+ <%= @todos.join('|') %>
3
+ TODOPART
@@ -0,0 +1 @@
1
+ This is a text file with some small content in it.
@@ -0,0 +1 @@
1
+ <%= "Hello!" %>
@@ -0,0 +1 @@
1
+ <%= "Hello!" %>
@@ -0,0 +1 @@
1
+ = "Hello!"
@@ -0,0 +1 @@
1
+ "Hello!"
@@ -0,0 +1,6 @@
1
+ <% throw_content :from_partial do %>
2
+ CONTENT THROWN FROM PARTIAL
3
+ <% end %>
4
+ <% throw_content :from_partial do %>
5
+ CONTENT THROWN FROM PARTIAL
6
+ <% end %>
@@ -0,0 +1 @@
1
+ xml.hello "world"
@@ -0,0 +1 @@
1
+ new Ajax.Request("<%= :embedded_ruby_symbol %>");
@@ -0,0 +1,15 @@
1
+ <% throw_content :header do %>
2
+ CAUGHT CONTENT
3
+ <% end %>
4
+
5
+ <% throw_content :footer do %>
6
+ CAUGHT FOOTER
7
+ <% end %>
8
+
9
+ START HEADER
10
+ <%= catch_content :header -%>
11
+ END HEADER
12
+
13
+ START FOOTER
14
+ <%= catch_content :footer -%>
15
+ END FOOTER
@@ -0,0 +1,6 @@
1
+ <% partial "examples/throw_content" %>
2
+
3
+ <%= catch_content :from_partial %>
4
+ <% partial "examples/throw_content" %>
5
+
6
+ <%= catch_content :from_partial %>
@@ -0,0 +1,10 @@
1
+ <% throw_content :header do %>
2
+ THROWN CONTENT
3
+ <% end %>
4
+
5
+ <%= controller.thrown_content[:header] -%>
6
+ <% throw_content :header do %>
7
+ THROWN CONTENT
8
+ <% end %>
9
+
10
+ <%= @_header_content -%>
@@ -0,0 +1 @@
1
+ <%= "An Error Occurred!" %>
@@ -0,0 +1,4 @@
1
+ Template contents
2
+ <% (1..10).each do |i| -%>
3
+ <%= partial :render_partial_multiple_times, {:count => i} %>
4
+ <% end -%>
@@ -0,0 +1 @@
1
+ <%= partial( "nested_js" )%>
@@ -0,0 +1 @@
1
+ <%= partial("nested_xml") %>
@@ -0,0 +1 @@
1
+ = "Hello!"
@@ -0,0 +1,2 @@
1
+ !!! XML
2
+ %hello= "world"
@@ -0,0 +1 @@
1
+ <%= catch_content :layout %>
@@ -0,0 +1 @@
1
+ <%= catch_content :layout %>
@@ -0,0 +1 @@
1
+ <%= catch_content :layout %>
@@ -0,0 +1 @@
1
+ "Hello!"
@@ -0,0 +1 @@
1
+ <%= "Hello!" %>
@@ -0,0 +1 @@
1
+ <%= respond_to?(:yo) ? yo : "No Locals!" %>
@@ -0,0 +1 @@
1
+ <%= erubis_collection %>
@@ -0,0 +1 @@
1
+ <%= respond_to?(:yo) ? yo : "No Locals!" %>
@@ -0,0 +1 @@
1
+ = respond_to?(:yo) && yo ? yo : "No Locals!"
@@ -0,0 +1 @@
1
+ = haml_collection
@@ -0,0 +1 @@
1
+ = respond_to?(:yo) && yo ? yo : "No Locals!"
@@ -0,0 +1 @@
1
+ "#{defined?(yo) && yo ? yo : "No Locals!"}"
@@ -0,0 +1 @@
1
+ "#{markaby_collection}\n"
@@ -0,0 +1 @@
1
+ "#{defined?(yo) && yo ? yo : "No Locals!"}"
@@ -0,0 +1 @@
1
+ object with template html format
@@ -0,0 +1 @@
1
+ object with template js format
@@ -0,0 +1 @@
1
+ object with template xml format
@@ -0,0 +1,4 @@
1
+ respond_to?(:_buffer) = <%= respond_to?(:_buffer) ? "TRUE" : "FALSE" %>
2
+
3
+ Test the view_buffer helper
4
+ <% _buffer( binding ) << "Text for the view buffer" %>
@@ -0,0 +1,7 @@
1
+ %p
2
+ respond_to?(:_buffer) =
3
+ = respond_to?(:_buffer) ? "TRUE" : "FALSE"
4
+
5
+ %p
6
+ Test the view_buffer helper
7
+ - _buffer( binding ) << "Text for the view buffer"
@@ -0,0 +1,7 @@
1
+ p do
2
+ "respond_to?(:_buffer) = #{respond_to?(:_buffer) ? "TRUE" : "FALSE"}"
3
+ end
4
+ p do
5
+ text "Test the view_buffer helper"
6
+ _buffer( binding ) << "Text for the view buffer"
7
+ end
@@ -0,0 +1,15 @@
1
+ <% @foo = capture do %>
2
+ Capture Text Without Args
3
+ <% end %>
4
+ <%= @foo %>
5
+
6
+ <% @struct = Struct.new( :value ) -%>
7
+ <% @obj = @struct.new( "capture text from yielded object" )%>
8
+
9
+ <% @foo2 = capture( @obj ) do |obj| %>
10
+ BEFORE
11
+ <%= obj.value %>
12
+ AFTER
13
+ <% end %>
14
+
15
+ <%= @foo2 %>
@@ -0,0 +1,15 @@
1
+ - @foo = capture do
2
+ Capture Text Without Args
3
+
4
+ = @foo
5
+
6
+ - @struct = Struct.new( :value )
7
+ - @obj = @struct.new( "capture text from yielded object" )
8
+
9
+ - @foo2 = capture( @obj ) do |obj|
10
+ BEFORE
11
+ = obj.value
12
+ AFTER
13
+
14
+
15
+ = @foo2
@@ -0,0 +1,4 @@
1
+ @foo = capture do
2
+ "Capture Text Without Args"
3
+ end
4
+
@@ -0,0 +1,12 @@
1
+ Test the Concat Helper
2
+ <% concat( "Concat Text", binding ) -%>
3
+
4
+ <% def tester( &block ) -%>
5
+ <% concat( "Start Tester Block", block.binding ) %>
6
+ <% yield %>
7
+ <% concat( "Finish Tester Block", block.binding ) %>
8
+ <% end %>
9
+
10
+ <% tester do %>
11
+ In Tester Block
12
+ <% end %>
@@ -0,0 +1,11 @@
1
+ Test the Concat Helper
2
+ - concat( "Concat Text", binding )
3
+
4
+ - def tester( &block )
5
+ - concat( "Start Tester Block", block.binding )
6
+ - yield
7
+ - concat( "Finish Tester Block", block.binding )
8
+
9
+
10
+ - tester do
11
+ In Tester Block
@@ -0,0 +1,14 @@
1
+ p do
2
+ "Test the Concat Helper"
3
+ concat( "Concat Text", binding )
4
+ end
5
+
6
+ def tester_helper( &block )
7
+ concat( "Start Tester Block", block.binding )
8
+ yield
9
+ concat( "Finish Tester Block", block.binding )
10
+ end
11
+
12
+ tester_helper do
13
+ text "In Tester Block"
14
+ end
@@ -0,0 +1,37 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Merb::AbstractController do
4
+
5
+ before(:all) do
6
+ @abc = Merb::AbstractController
7
+ @template = "/my/template/path/file.html.erb"
8
+ @key = "/my/template/path/file.html"
9
+ end
10
+
11
+ before(:each) do
12
+ @abc.reset_template_path_cache!
13
+ end
14
+
15
+ after(:all) do
16
+ Merb::Server.load_controller_template_path_cache
17
+ end
18
+
19
+ it "should add a template path" do
20
+ @abc.add_path_to_template_cache(@template)
21
+ @abc._template_path_cache.should include(@key)
22
+ @abc._template_path_cache[@key].should == @template
23
+ end
24
+
25
+ it "should reset the template_path_cache" do
26
+ @abc.add_path_to_template_cache(@template)
27
+ @abc._template_path_cache.should_not be_empty
28
+ @abc.reset_template_path_cache!
29
+ @abc._template_path_cache.should be_empty
30
+ end
31
+
32
+ it "should return false if the template is the wrong format when adding" do
33
+ @abc.add_path_to_template_cache("/my/path/to/template.rhtml").should == false
34
+ @abc._template_path_cache.should_not include( "/my/path/to/template.rhtml")
35
+ end
36
+
37
+ end
@@ -0,0 +1,102 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "all fragment caching", :shared => true do
4
+
5
+ it "should be able to store and retrieve a key" do
6
+ @c.put(:foo, "Bar")
7
+ @c.get(:foo).should == "Bar"
8
+ end
9
+
10
+ it "should be able to expire a fragment" do
11
+ @c.put(:foo, "Bar")
12
+ @c.get(:foo).should == "Bar"
13
+ @c.expire_fragment(:foo)
14
+ @c.get(:foo).should == nil
15
+ end
16
+
17
+ it "should clear the cache on reset" do
18
+ @c.put(:foo, "Bar")
19
+ @c.get(:foo).should == "Bar"
20
+ @c.clear
21
+ @c.get(:foo).should == nil
22
+ end
23
+
24
+ it "should be ok to clear the cache twice" do
25
+ @c.clear
26
+ @c.clear
27
+ end
28
+
29
+ it "should accept keys and subkeys" do
30
+ @c.put([:user, :joe], "Joe's data")
31
+ @c.get([:user, :joe]).should. == "Joe's data"
32
+ end
33
+
34
+ it "should keep subkeys separate" do
35
+ @c.put([:user, :joe], "Joe's data")
36
+ @c.put([:user, :bill], "Bill's data")
37
+ @c.get([:user, :joe]).should == "Joe's data"
38
+ @c.get([:user, :bill]).should == "Bill's data"
39
+ end
40
+
41
+ it "should expire a subkey" do
42
+ @c.put([:user, :joe], "Joe's data")
43
+ @c.put([:user, :bill], "Bill's data")
44
+ @c.expire_fragment([:user,:joe])
45
+ @c.get([:user, :joe]).should == nil
46
+ @c.get([:user, :bill]).should == "Bill's data"
47
+ end
48
+
49
+ it "should expire a key and all its children when passed an array containing only the top key" do
50
+ @c.put([:user, :joe], "Joe's data")
51
+ @c.put([:user, :bill], "Bill's data")
52
+ @c.expire_fragment([:user])
53
+ @c.get([:user, :joe]).should == nil
54
+ @c.get([:user, :bill]).should == nil
55
+ end
56
+
57
+ it "should expire a key and all its children when passed only the top key" do
58
+ @c.put([:user, :joe], "Joe's data")
59
+ @c.put([:user, :bill], "Bill's data")
60
+ @c.expire_fragment(:user)
61
+ @c.get([:user, :joe]).should == nil
62
+ @c.get([:user, :bill]).should == nil
63
+ end
64
+
65
+ it "should handle arbitrary levels of keys" do
66
+ @c.put([:users, :show, :bob], "Bob's data")
67
+ @c.put([:users, :show, :mary], "Mary's data")
68
+ @c.put([:users, :edit, :bob], "Bob's editable data")
69
+ @c.get([:users, :show, :bob]).should == "Bob's data"
70
+ @c.get([:users, :edit, :bob]).should == "Bob's editable data"
71
+ @c.expire_fragment([:users, :show, :mary])
72
+ @c.get([:users, :show, :mary]).should == nil
73
+ @c.get([:users, :show, :bob]).should == "Bob's data"
74
+ @c.expire_fragment([:users, :show])
75
+ @c.get([:users, :show, :bob]).should == nil
76
+ @c.expire_fragment([:users])
77
+ @c.get([:users, :edit, :bob]).should == nil
78
+ end
79
+
80
+
81
+ end
82
+
83
+
84
+ describe "fragment caching in memory" do
85
+ before do
86
+ Merb::Server.config['cache_store'] = 'memory'
87
+ @c = Merb::Caching::Fragment
88
+ @c.clear
89
+ end
90
+
91
+ it_should_behave_like "all fragment caching"
92
+ end
93
+
94
+ describe "fragment caching to a file" do
95
+ before do
96
+ Merb::Server.config[:cache_store] = 'file'
97
+ @c = Merb::Caching::Fragment
98
+ @c.clear
99
+ end
100
+
101
+ it_should_behave_like "all fragment caching"
102
+ end
@@ -0,0 +1,29 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Merb::Config do
4
+ before(:all) do
5
+ @config_yml = File.expand_path(File.dirname(__FILE__) / ".." / "fixtures")
6
+ end
7
+
8
+ it "should have a default configuration" do
9
+ Merb::Config.defaults.should be_is_a(Hash)
10
+ Merb::Config.defaults[:merb_root].should == Dir.pwd
11
+ end
12
+
13
+ it "should not load the config.yml file if it does not exist" do
14
+ Merb::Config.setup.should be_is_a(Hash)
15
+ Merb::Config.setup.should == Merb::Config.defaults
16
+ end
17
+
18
+ it "should load the config.yml file if it exists" do
19
+ Merb::Config.defaults.merge!(:merb_root => @config_yml)
20
+ Merb::Config.setup.should be_is_a(Hash)
21
+ Merb::Config.setup[:host].should == "127.0.0.1"
22
+ end
23
+
24
+ it "should accept erb in the config.yml file" do
25
+ Merb::Config.defaults.merge!(:merb_root => @config_yml)
26
+ Merb::Config.setup.should be_is_a(Hash)
27
+ Merb::Config.setup[:environment].should == "test"
28
+ end
29
+ end