pancake 0.1.8

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 (172) hide show
  1. data/LICENSE +20 -0
  2. data/README.textile +95 -0
  3. data/Rakefile +56 -0
  4. data/TODO +17 -0
  5. data/bin/jeweler +19 -0
  6. data/bin/pancake-gen +17 -0
  7. data/bin/rubyforge +19 -0
  8. data/lib/pancake/bootloaders.rb +180 -0
  9. data/lib/pancake/configuration.rb +145 -0
  10. data/lib/pancake/constants.rb +5 -0
  11. data/lib/pancake/core_ext/class.rb +44 -0
  12. data/lib/pancake/core_ext/object.rb +22 -0
  13. data/lib/pancake/core_ext/symbol.rb +15 -0
  14. data/lib/pancake/defaults/configuration.rb +22 -0
  15. data/lib/pancake/defaults/middlewares.rb +1 -0
  16. data/lib/pancake/errors.rb +61 -0
  17. data/lib/pancake/generators/base.rb +12 -0
  18. data/lib/pancake/generators/micro_generator.rb +17 -0
  19. data/lib/pancake/generators/short_generator.rb +17 -0
  20. data/lib/pancake/generators/stack_generator.rb +17 -0
  21. data/lib/pancake/generators/templates/common/dotgitignore +22 -0
  22. data/lib/pancake/generators/templates/common/dothtaccess +17 -0
  23. data/lib/pancake/generators/templates/micro/%stack_name%/%stack_name%.rb.tt +8 -0
  24. data/lib/pancake/generators/templates/micro/%stack_name%/config.ru.tt +12 -0
  25. data/lib/pancake/generators/templates/micro/%stack_name%/pancake.init.tt +1 -0
  26. data/lib/pancake/generators/templates/micro/%stack_name%/public/.empty_directory +0 -0
  27. data/lib/pancake/generators/templates/micro/%stack_name%/tmp/.empty_directory +0 -0
  28. data/lib/pancake/generators/templates/micro/%stack_name%/views/root.html.haml +1 -0
  29. data/lib/pancake/generators/templates/short/%stack_name%/LICENSE.tt +20 -0
  30. data/lib/pancake/generators/templates/short/%stack_name%/README.tt +7 -0
  31. data/lib/pancake/generators/templates/short/%stack_name%/Rakefile.tt +50 -0
  32. data/lib/pancake/generators/templates/short/%stack_name%/VERSION.tt +1 -0
  33. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/%stack_name%.rb.tt +6 -0
  34. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/config.ru.tt +10 -0
  35. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/mounts/.empty_directory +0 -0
  36. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/public/.empty_directory +0 -0
  37. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/tmp/.empty_directory +0 -0
  38. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%/views/root.html.haml +2 -0
  39. data/lib/pancake/generators/templates/short/%stack_name%/lib/%stack_name%.rb.tt +5 -0
  40. data/lib/pancake/generators/templates/short/%stack_name%/pancake.init.tt +1 -0
  41. data/lib/pancake/generators/templates/short/%stack_name%/spec/%stack_name%_spec.rb.tt +7 -0
  42. data/lib/pancake/generators/templates/short/%stack_name%/spec/spec_helper.rb.tt +9 -0
  43. data/lib/pancake/generators/templates/stack/%stack_name%/LICENSE.tt +20 -0
  44. data/lib/pancake/generators/templates/stack/%stack_name%/README.tt +7 -0
  45. data/lib/pancake/generators/templates/stack/%stack_name%/Rakefile.tt +50 -0
  46. data/lib/pancake/generators/templates/stack/%stack_name%/VERSION.tt +1 -0
  47. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/development.rb.tt +18 -0
  48. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/environments/production.rb.tt +18 -0
  49. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config/router.rb.tt +6 -0
  50. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/config.ru.tt +12 -0
  51. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/gems/cache/.empty_directory +0 -0
  52. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/mounts/.empty_directory +0 -0
  53. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/public/.empty_directory +0 -0
  54. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%/tmp/.empty_directory +0 -0
  55. data/lib/pancake/generators/templates/stack/%stack_name%/lib/%stack_name%.rb.tt +3 -0
  56. data/lib/pancake/generators/templates/stack/%stack_name%/pancake.init.tt +1 -0
  57. data/lib/pancake/generators/templates/stack/%stack_name%/spec/%stack_name%_spec.rb.tt +7 -0
  58. data/lib/pancake/generators/templates/stack/%stack_name%/spec/spec_helper.rb.tt +9 -0
  59. data/lib/pancake/generators.rb +8 -0
  60. data/lib/pancake/hooks/inheritable_inner_classes.rb +60 -0
  61. data/lib/pancake/hooks/on_inherit.rb +34 -0
  62. data/lib/pancake/logger.rb +200 -0
  63. data/lib/pancake/master.rb +123 -0
  64. data/lib/pancake/middleware.rb +347 -0
  65. data/lib/pancake/middlewares/logger.rb +16 -0
  66. data/lib/pancake/middlewares/static.rb +38 -0
  67. data/lib/pancake/mime_types.rb +265 -0
  68. data/lib/pancake/mixins/publish/action_options.rb +104 -0
  69. data/lib/pancake/mixins/publish.rb +125 -0
  70. data/lib/pancake/mixins/render/render.rb +168 -0
  71. data/lib/pancake/mixins/render/template.rb +23 -0
  72. data/lib/pancake/mixins/render/view_context.rb +21 -0
  73. data/lib/pancake/mixins/render.rb +109 -0
  74. data/lib/pancake/mixins/request_helper.rb +100 -0
  75. data/lib/pancake/mixins/stack_helper.rb +46 -0
  76. data/lib/pancake/mixins/url.rb +10 -0
  77. data/lib/pancake/paths.rb +218 -0
  78. data/lib/pancake/router.rb +99 -0
  79. data/lib/pancake/stack/app.rb +10 -0
  80. data/lib/pancake/stack/bootloader.rb +79 -0
  81. data/lib/pancake/stack/configuration.rb +44 -0
  82. data/lib/pancake/stack/middleware.rb +0 -0
  83. data/lib/pancake/stack/router.rb +21 -0
  84. data/lib/pancake/stack/stack.rb +66 -0
  85. data/lib/pancake/stacks/short/bootloaders.rb +13 -0
  86. data/lib/pancake/stacks/short/controller.rb +116 -0
  87. data/lib/pancake/stacks/short/default/views/base.html.haml +5 -0
  88. data/lib/pancake/stacks/short/stack.rb +187 -0
  89. data/lib/pancake/stacks/short.rb +3 -0
  90. data/lib/pancake.rb +58 -0
  91. data/spec/helpers/helpers.rb +20 -0
  92. data/spec/helpers/matchers.rb +25 -0
  93. data/spec/pancake/bootloaders_spec.rb +109 -0
  94. data/spec/pancake/configuration_spec.rb +177 -0
  95. data/spec/pancake/constants_spec.rb +7 -0
  96. data/spec/pancake/defaults/configuration_spec.rb +58 -0
  97. data/spec/pancake/fixtures/foo_stack/pancake.init +0 -0
  98. data/spec/pancake/fixtures/middlewares/other_public/two.html +1 -0
  99. data/spec/pancake/fixtures/middlewares/public/foo#bar.html +1 -0
  100. data/spec/pancake/fixtures/middlewares/public/one.html +1 -0
  101. data/spec/pancake/fixtures/paths/controllers/controller1.rb +0 -0
  102. data/spec/pancake/fixtures/paths/controllers/controller2.rb +0 -0
  103. data/spec/pancake/fixtures/paths/controllers/controller3.rb +0 -0
  104. data/spec/pancake/fixtures/paths/models/model1.rb +0 -0
  105. data/spec/pancake/fixtures/paths/models/model2.rb +0 -0
  106. data/spec/pancake/fixtures/paths/models/model3.rb +0 -0
  107. data/spec/pancake/fixtures/paths/stack/controllers/controller1.rb +0 -0
  108. data/spec/pancake/fixtures/paths/stack/models/model3.rb +0 -0
  109. data/spec/pancake/fixtures/paths/stack/views/view1.erb +0 -0
  110. data/spec/pancake/fixtures/paths/stack/views/view1.rb +0 -0
  111. data/spec/pancake/fixtures/paths/stack/views/view2.erb +0 -0
  112. data/spec/pancake/fixtures/paths/stack/views/view2.haml +0 -0
  113. data/spec/pancake/fixtures/render_templates/context_template.html.erb +2 -0
  114. data/spec/pancake/fixtures/render_templates/erb_template.html.erb +1 -0
  115. data/spec/pancake/fixtures/render_templates/erb_template.json.erb +1 -0
  116. data/spec/pancake/fixtures/render_templates/haml_template.html.haml +1 -0
  117. data/spec/pancake/fixtures/render_templates/haml_template.xml.haml +1 -0
  118. data/spec/pancake/fixtures/render_templates/templates/context.erb +2 -0
  119. data/spec/pancake/fixtures/render_templates/view_context/capture_erb.erb +5 -0
  120. data/spec/pancake/fixtures/render_templates/view_context/capture_haml.haml +4 -0
  121. data/spec/pancake/fixtures/render_templates/view_context/concat_erb.erb +2 -0
  122. data/spec/pancake/fixtures/render_templates/view_context/concat_haml.haml +2 -0
  123. data/spec/pancake/fixtures/render_templates/view_context/context.erb +3 -0
  124. data/spec/pancake/fixtures/render_templates/view_context/context2.erb +3 -0
  125. data/spec/pancake/fixtures/render_templates/view_context/helper_methods.erb +3 -0
  126. data/spec/pancake/fixtures/render_templates/view_context/inherited_erb_from_haml.erb +5 -0
  127. data/spec/pancake/fixtures/render_templates/view_context/inherited_erb_level_0.erb +5 -0
  128. data/spec/pancake/fixtures/render_templates/view_context/inherited_erb_level_1.erb +5 -0
  129. data/spec/pancake/fixtures/render_templates/view_context/inherited_haml_from_erb.haml +4 -0
  130. data/spec/pancake/fixtures/render_templates/view_context/inherited_haml_level_0.haml +4 -0
  131. data/spec/pancake/fixtures/render_templates/view_context/inherited_haml_level_1.haml +4 -0
  132. data/spec/pancake/fixtures/render_templates/view_context/nested_content_level_0.haml +6 -0
  133. data/spec/pancake/fixtures/render_templates/view_context/nested_content_level_1.haml +4 -0
  134. data/spec/pancake/fixtures/render_templates/view_context/nested_inner.erb +1 -0
  135. data/spec/pancake/fixtures/render_templates/view_context/nested_outer.erb +3 -0
  136. data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_erb_0.erb +5 -0
  137. data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_erb_1.erb +6 -0
  138. data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_haml_0.erb +5 -0
  139. data/spec/pancake/fixtures/render_templates/view_context/super_erb_from_haml_1.erb +6 -0
  140. data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_erb_0.haml +4 -0
  141. data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_erb_1.haml +5 -0
  142. data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_haml_0.haml +5 -0
  143. data/spec/pancake/fixtures/render_templates/view_context/super_haml_from_haml_1.haml +5 -0
  144. data/spec/pancake/fixtures/stacks/short/foobar/other_root/views/base.html.haml +4 -0
  145. data/spec/pancake/fixtures/stacks/short/foobar/views/basic.html.haml +1 -0
  146. data/spec/pancake/fixtures/stacks/short/foobar/views/inherited_from_base.html.haml +5 -0
  147. data/spec/pancake/hooks/on_inherit_spec.rb +65 -0
  148. data/spec/pancake/inheritance_spec.rb +100 -0
  149. data/spec/pancake/middleware_spec.rb +401 -0
  150. data/spec/pancake/middlewares/logger_spec.rb +29 -0
  151. data/spec/pancake/middlewares/static_spec.rb +83 -0
  152. data/spec/pancake/mime_types_spec.rb +234 -0
  153. data/spec/pancake/mixins/publish_spec.rb +94 -0
  154. data/spec/pancake/mixins/render/template_spec.rb +69 -0
  155. data/spec/pancake/mixins/render/view_context_spec.rb +248 -0
  156. data/spec/pancake/mixins/render_spec.rb +56 -0
  157. data/spec/pancake/mixins/request_helper_spec.rb +27 -0
  158. data/spec/pancake/mixins/stack_helper_spec.rb +46 -0
  159. data/spec/pancake/pancake_spec.rb +90 -0
  160. data/spec/pancake/paths_spec.rb +210 -0
  161. data/spec/pancake/stack/app_spec.rb +28 -0
  162. data/spec/pancake/stack/bootloader_spec.rb +41 -0
  163. data/spec/pancake/stack/middleware_spec.rb +0 -0
  164. data/spec/pancake/stack/router_spec.rb +282 -0
  165. data/spec/pancake/stack/stack_configuration_spec.rb +101 -0
  166. data/spec/pancake/stack/stack_spec.rb +60 -0
  167. data/spec/pancake/stacks/short/controller_spec.rb +322 -0
  168. data/spec/pancake/stacks/short/middlewares_spec.rb +22 -0
  169. data/spec/pancake/stacks/short/router_spec.rb +136 -0
  170. data/spec/pancake/stacks/short/stack_spec.rb +64 -0
  171. data/spec/spec_helper.rb +23 -0
  172. metadata +294 -0
@@ -0,0 +1,109 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Pancake::Stack::BootLoader" do
4
+
5
+ before(:each) do
6
+ $captures = []
7
+
8
+ class ::FooStack < Pancake::Stack
9
+ roots << File.join(Pancake.get_root(__FILE__), "..", "fixtures", "foo_stack")
10
+ end
11
+ end
12
+
13
+ after(:each) do
14
+ clear_constants(:FooStack)
15
+ end
16
+
17
+ it "should not add the bootloader without it having a run! method" do
18
+ lambda do
19
+ FooStack::BootLoader.add(:foo){|s,c| :here }
20
+ end.should raise_error
21
+ end
22
+
23
+ it "should allow me to add an application specific BootLoader" do
24
+ FooStack::BootLoader.add(:my_initializer){ def run!; :foo; end}
25
+ FooStack::BootLoader[:my_initializer].call({}).should == :foo
26
+ end
27
+
28
+ it "should provide a bootloader instance" do
29
+ FooStack::BootLoader.add(:my_initializer){ def run!; :foo; end}
30
+ FooStack::BootLoader[:my_initializer].should inherit_from(Pancake::BootLoaderMixin::Base)
31
+ end
32
+
33
+ it "should allow me to add multiple boot loaders" do
34
+ FooStack::BootLoader.add(:foo){ def run!; :foo; end}
35
+ FooStack::BootLoader.add(:bar){ def run!; :bar; end}
36
+ FooStack::BootLoader[:foo].call({}).should == :foo
37
+ FooStack::BootLoader[:bar].call({}).should == :bar
38
+ end
39
+
40
+ it "should allow me to add a bootloader before another" do
41
+ $captures.should be_empty
42
+ FooStack::BootLoader.add(:foo){ def run!; $captures << :foo; end}
43
+ FooStack::BootLoader.add(:bar){ def run!; $captures << :bar; end}
44
+ FooStack::BootLoader.add(:baz, :before => :bar){ def run!; $captures << :baz; end}
45
+ FooStack.new
46
+ $captures.should == [:foo, :baz, :bar]
47
+ end
48
+
49
+ it "should allow me to add a bootloader after another" do
50
+ $captures.should be_empty
51
+ FooStack::BootLoader.add(:foo){ def run!; $captures << :foo; end}
52
+ FooStack::BootLoader.add(:bar){ def run!; $captures << :bar; end}
53
+ FooStack::BootLoader.add(:baz, :after => :foo){ def run!; $captures << :baz; end}
54
+ FooStack.new
55
+ $captures.should == [:foo, :baz, :bar]
56
+ end
57
+
58
+ it "should provide an arbitrarily complex setup" do
59
+ $captures.should be_empty
60
+ FooStack::BootLoader.add(:foo ){ def run!; $captures << :foo; end}
61
+ FooStack::BootLoader.add(:bar ){ def run!; $captures << :bar; end}
62
+ FooStack::BootLoader.add(:baz, :after => :foo ){ def run!; $captures << :baz; end}
63
+ FooStack::BootLoader.add(:paz, :before => :baz ){ def run!; $captures << :paz; end}
64
+ FooStack::BootLoader.add(:fred, :before => :bar ){ def run!; $captures << :fred; end}
65
+ FooStack::BootLoader.add(:barney, :after => :fred ){ def run!; $captures << :barney; end}
66
+
67
+ FooStack.new
68
+ $captures.should == [:foo, :paz, :baz, :fred, :barney, :bar]
69
+ end
70
+
71
+ describe "types" do
72
+
73
+ it "should run bootloaders marked as :init" do
74
+ FooStack::BootLoader.add(:bar, :level => :init ){ def run!; $captures << [:bar, :init ]; end}
75
+ FooStack::BootLoader.add(:baz, :level => :init ){ def run!; $captures << [:baz, :init ]; end}
76
+ FooStack::BootLoader.add(:paz, :level => :init, :before => :baz){ def run!; $captures << [:paz, :init]; end}
77
+
78
+ FooStack::BootLoader.run!(:only => {:level => :init})
79
+ $captures.should == [[:bar, :init], [:paz, :init], [:baz, :init]]
80
+ end
81
+
82
+ it "should run init or then default level bootloaders individually" do
83
+ FooStack::BootLoader.add(:foo ){ def run!; $captures << [:foo, :default]; end}
84
+ FooStack::BootLoader.add(:grh ){ def run!; $captures << [:grh, :default]; end}
85
+ FooStack::BootLoader.add(:bar, :level => :init ){ def run!; $captures << [:bar, :init ]; end}
86
+ FooStack::BootLoader.add(:ptf, :before => :grh ){ def run!; $captures << [:ptf, :default]; end}
87
+ FooStack::BootLoader.add(:baz, :level => :init ){ def run!; $captures << [:baz, :init ]; end}
88
+ FooStack::BootLoader.add(:paz, :level => :init, :before => :baz){ def run!; $captures << [:paz, :init]; end}
89
+
90
+ FooStack.new
91
+ $captures.should == [[:bar, :init], [:paz, :init], [:baz, :init], [:foo, :default], [:ptf, :default], [:grh, :default]]
92
+ end
93
+
94
+ it "should inherit from the default boot loaders" do
95
+ ::Pancake::Stack::BootLoader.add(:default_boot_loader_test){def run!; end}
96
+ class ::Bario < Pancake::Stack; end
97
+ Bario::BootLoader.map{|n,bl| n}.should include(:default_boot_loader_test)
98
+ end
99
+
100
+ it "should let me pass options to the bootloaders and pass them on" do
101
+ FooStack::BootLoader.add(:foo){ def run!; config[:result] << :foo; end}
102
+ FooStack::BootLoader.add(:bar){ def run!; config[:result] << :bar; end}
103
+
104
+ opts = { :result => [] }
105
+ FooStack.new(nil, opts)
106
+ opts[:result].should == [:foo, :bar]
107
+ end
108
+ end
109
+ end
@@ -0,0 +1,177 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "Pancake::Configuration" do
4
+
5
+ it "should let me make a new configuration" do
6
+ conf_klass = Pancake::Configuration.make
7
+ conf_klass.should inherit_from(Pancake::Configuration::Base)
8
+ end
9
+
10
+ describe "usage" do
11
+ before(:each) do
12
+ @Conf = Pancake::Configuration.make
13
+ end
14
+
15
+ it "should let me set defaults" do
16
+ @Conf.default :foo, :bar
17
+ c = @Conf.new
18
+ c.foo.should == :bar
19
+ @Conf.new.foo.should == :bar
20
+ end
21
+
22
+ it "should let me set a description on the default" do
23
+ @Conf.default :foo, :bar
24
+ @Conf.default :bar, :baz, "A description of bar"
25
+ c = @Conf.new
26
+ c.foo.should == :bar
27
+ c.bar.should == :baz
28
+ c.defaults[:foo][:description].should == ""
29
+ c.defaults[:bar][:description].should == "A description of bar"
30
+ end
31
+
32
+ it "should allow me to make multiple different configuration objects without polluting each other" do
33
+ c1 = Pancake::Configuration.make
34
+ c2 = Pancake::Configuration.make
35
+ c1.default :foo, :bar
36
+ c2.default :foo, :baz, "A description of foo"
37
+ c1i, c2i = c1.new, c2.new
38
+ c1i.foo.should == :bar
39
+ c1i.defaults[:foo][:value].should == :bar
40
+ c1i.defaults[:foo][:description].should == ""
41
+ c2i.foo.should == :baz
42
+ c2i.defaults[:foo][:value].should == :baz
43
+ c2i.defaults[:foo][:description].should == "A description of foo"
44
+ end
45
+
46
+ it "should allow me to define defaults in the make block" do
47
+ c1 = Pancake::Configuration.make do
48
+ default :foo, :bar, "Foo Desc"
49
+ default :baz, 42, "The Answer"
50
+ end
51
+ c = c1.new
52
+ c.foo.should == :bar
53
+ c.baz.should == 42
54
+ end
55
+
56
+ it "should overwrite the default values" do
57
+ @Conf.default :foo, :bar
58
+ c = @Conf.new
59
+ c.foo = :baz
60
+ c.foo.inspect
61
+ c.foo.should == :baz
62
+ c.defaults[:foo][:value].should == :bar
63
+ end
64
+
65
+ it "should not add a default value for values I set blindly" do
66
+ c = @Conf.new
67
+ c.bar.should be_nil
68
+ c.defaults.keys.should_not include(:bar)
69
+ end
70
+
71
+ it "should allow me to set a value then the default and not get mixed up" do
72
+ c = @Conf.new
73
+ c.bar = :foo
74
+ c.defaults[:bar][:value].should == nil
75
+ end
76
+
77
+ it "should let me declare defaults after I've initizlied the configuartion object" do
78
+ c = @Conf.new
79
+ @Conf.default :foo, :bar
80
+ c.foo.should == :bar
81
+ end
82
+
83
+ it "should give me a list of the current defaults" do
84
+ @Conf.default :foo, :bar
85
+ @Conf.default :bar, :baz, "Some description"
86
+ c = @Conf.new
87
+ c.defaults.should == {
88
+ :foo => {
89
+ :description => "",
90
+ :value => :bar
91
+ },
92
+ :bar => {
93
+ :description => "Some description",
94
+ :value => :baz
95
+ }
96
+ }
97
+ end
98
+
99
+ it "should give me a description for a default" do
100
+ @Conf.default :foo, :bar, "foo description"
101
+ c = @Conf.new
102
+ c.description_for(:foo).should == "foo description"
103
+ end
104
+
105
+ it "should give me a list of values for the current object" do
106
+ @Conf.default :foo, :bar
107
+ c = @Conf.new
108
+ c.values.should == {}
109
+ c.foo
110
+ c.values.should == {:foo => :bar}
111
+ c.baz = :paz
112
+ c.values.should == {:foo => :bar, :baz => :paz}
113
+ end
114
+
115
+ it "should allow me to define methods in the make block" do
116
+ c = Pancake::Configuration.make do
117
+ default :foo, :bar
118
+
119
+ default :bar do
120
+ foobar
121
+ end
122
+
123
+ def foobar
124
+ "This is in foobar"
125
+ end
126
+ end
127
+
128
+ ci = c.new
129
+ ci.foo.should == :bar
130
+ ci.bar.should == "This is in foobar"
131
+ end
132
+
133
+ it "should not cache the default when it's defined in a block" do
134
+ c = Pancake::Configuration.make do
135
+ default :foo do
136
+ bar
137
+ end
138
+ default :bar, :bar
139
+ end
140
+ ci = c.new
141
+ ci.foo.should == :bar
142
+ ci.bar = :baz
143
+ ci.bar.should == :baz
144
+ ci.foo.should == :baz
145
+ end
146
+
147
+ it "should overwrite the proc when set directly" do
148
+ @Conf.default :foo, :foo
149
+ @Conf.default(:bar){ foo }
150
+ ci = @Conf.new
151
+ ci.bar.should == :foo
152
+ ci.foo = :baz
153
+ ci.bar.should == :baz
154
+ ci.bar = :foobar
155
+ ci.bar.should == :foobar
156
+ end
157
+
158
+ it "should not cache nil when accessing before defaults are set" do
159
+ c = @Conf.new
160
+ c.foo.should be_nil
161
+ @Conf.default :foo, :bar
162
+ c.foo.should == :bar
163
+ c.foo = :baz
164
+ c.foo.should == :baz
165
+ end
166
+
167
+ end
168
+ end
169
+
170
+
171
+ describe "pancake configuartion" do
172
+
173
+ it "should provide access to it's configuration object" do
174
+ Pancake.configuration.class.should inherit_from(Pancake::Configuration::Base)
175
+ end
176
+
177
+ end
@@ -0,0 +1,7 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Pancake::Constants do
4
+ it "should have the ENV_LOGGER_KEY constant" do
5
+ Pancake::Constants::ENV_LOGGER_KEY.should == "rack.logger"
6
+ end
7
+ end
@@ -0,0 +1,58 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "Pancake configuration defaults" do
4
+ describe "logging defaults" do
5
+ before do
6
+ Pancake.root = Pancake.get_root(__FILE__)
7
+ end
8
+
9
+ after do
10
+ Pancake.reset_configuration
11
+ FileUtils.rm_rf(File.join(Pancake.root, "log"))
12
+ end
13
+
14
+ it "should set the log path" do
15
+ path = Pancake.configuration.log_path
16
+ path.should == "log/pancake_#{Pancake.env}.log"
17
+ end
18
+
19
+ it "should set the log level to :info" do
20
+ Pancake.configuration.log_level.should == :info
21
+ end
22
+
23
+ it "should set the delimiter to ~ " do
24
+ Pancake.configuration.log_delimiter.should == " ~ "
25
+ end
26
+
27
+ it "should set auto flush to true" do
28
+ Pancake.configuration.log_auto_flush.should be_true
29
+ end
30
+
31
+ it "should set log to file to false" do
32
+ Pancake.configuration.log_to_file.should be_false
33
+ end
34
+
35
+ it "should set log to file to true if env is production" do
36
+ Pancake.stub(:env).and_return("production")
37
+ Pancake.configuration.log_to_file.should be_true
38
+ end
39
+
40
+ it "should set the log_stream to STDOUT by default" do
41
+ Pancake.configuration.log_stream.should === STDOUT
42
+ end
43
+
44
+ it "should set the log stream to a file path when told to log to file" do
45
+ Pancake.configuration.log_to_file = true
46
+ result = Pancake.configuration.log_stream
47
+ result.should match(/\log\/pancake_#{Pancake.env}\.log$/)
48
+ end
49
+
50
+ it "should create the directory if it doesn't exist" do
51
+ File.exists?(File.join(Pancake.root, "log")).should be_false
52
+ Pancake.configuration.log_to_file = true
53
+ Pancake.configuration.log_stream
54
+ File.exists?(File.join(Pancake.root, "log")).should be_true
55
+ end
56
+ end
57
+
58
+ end
File without changes
@@ -0,0 +1 @@
1
+ escaped text is #
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,2 @@
1
+
2
+ <% $captures << self %>
@@ -0,0 +1,2 @@
1
+ <% $captures << self %>
2
+ in context
@@ -0,0 +1,5 @@
1
+ <% $captures << self %>
2
+ <p>erb capture test</p>
3
+ <% @captured_erb = capture do %>
4
+ <p><%= "captured erb" %></p>
5
+ <% end %>
@@ -0,0 +1,4 @@
1
+ - $captures << self
2
+ %p haml capture test
3
+ - @captured_haml = capture do
4
+ %p captured haml
@@ -0,0 +1,2 @@
1
+ <p>Concat Erb</p>
2
+ <% concat "concatenated" %>
@@ -0,0 +1,2 @@
1
+ %p Concat Haml
2
+ - concat "concatenated"
@@ -0,0 +1,3 @@
1
+ In view_context.erb
2
+ <% $captures << self %>
3
+ <%= self.class %>
@@ -0,0 +1,3 @@
1
+ In view_context.erb
2
+ <% $captures << self %>
3
+ <%= self.class %>
@@ -0,0 +1,3 @@
1
+ helper methods
2
+
3
+ <%= some_helper %>
@@ -0,0 +1,5 @@
1
+ <% inherits_from :inherited_haml_level_0 %>
2
+
3
+ <% content_block :foo do %>
4
+ <%= "inherited erb content" %>
5
+ <% end %>
@@ -0,0 +1,5 @@
1
+ inherited erb level 0
2
+
3
+ <% content_block :foo do %>
4
+ default content block content
5
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <% inherits_from :inherited_erb_level_0 %>
2
+
3
+ <% content_block :foo do %>
4
+ <%= "inherited erb level 1 content" %>
5
+ <% end %>
@@ -0,0 +1,4 @@
1
+ - inherits_from :inherited_erb_level_0
2
+
3
+ - content_block :foo do
4
+ = "inherited haml content"
@@ -0,0 +1,4 @@
1
+ %p inherited haml level 0
2
+
3
+ - content_block :foo do
4
+ %p default content block content
@@ -0,0 +1,4 @@
1
+ - inherits_from :inherited_haml_level_0
2
+
3
+ - content_block :foo do
4
+ %p inherited haml level 1 content
@@ -0,0 +1,6 @@
1
+ %p level 0 content
2
+
3
+ - content_block :foo do
4
+ %p nested foo content
5
+ - content_block :bar do
6
+ %p nested bar content
@@ -0,0 +1,4 @@
1
+ - inherits_from :nested_content_level_0
2
+
3
+ -content_block :bar do
4
+ %p nested new bar content
@@ -0,0 +1 @@
1
+ Nested Inner Template
@@ -0,0 +1,3 @@
1
+ Nested Outer Template
2
+
3
+ <%= render :nested_inner %>
@@ -0,0 +1,5 @@
1
+ <% inherits_from :inherited_erb_level_0 %>
2
+
3
+ <% content_block :foo do %>
4
+ <%= content_block.super %>
5
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% inherits_from :inherited_erb_level_0 %>
2
+
3
+ <% content_block :foo do %>
4
+ new content with super
5
+ <%= content_block.super %>
6
+ <% end %>
@@ -0,0 +1,5 @@
1
+ <% inherits_from :inherited_haml_level_0 %>
2
+
3
+ <% content_block :foo do %>
4
+ <%= content_block.super %>
5
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <% inherits_from :inherited_haml_level_0 %>
2
+
3
+ <% content_block :foo do %>
4
+ new content from erb
5
+ <%= content_block.super %>
6
+ <% end %>
@@ -0,0 +1,4 @@
1
+ - inherits_from :inherited_erb_level_0
2
+
3
+ - content_block :foo do
4
+ = content_block.super
@@ -0,0 +1,5 @@
1
+ - inherits_from :inherited_erb_level_0
2
+
3
+ -content_block :foo do
4
+ %p new content from haml
5
+ = content_block.super
@@ -0,0 +1,5 @@
1
+ - inherits_from :inherited_haml_level_0
2
+
3
+ - content_block :foo do
4
+ = content_block.super
5
+
@@ -0,0 +1,5 @@
1
+ - inherits_from :inherited_haml_level_0
2
+
3
+ - content_block :foo do
4
+ %p new content with super
5
+ = content_block.super
@@ -0,0 +1,4 @@
1
+ %h1 Not the default pancake
2
+
3
+ - content_block :content do
4
+ %p not pancake!
@@ -0,0 +1 @@
1
+ %p basic template
@@ -0,0 +1,5 @@
1
+ - inherits_from :base
2
+
3
+ - content_block :content do
4
+ %p inherited from base
5
+ = content_block.super
@@ -0,0 +1,65 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "Pancake::Stack inheritance" do
4
+ describe "inheritance hooks" do
5
+ before(:all) do
6
+ $on_inherit_blocks = Pancake::Stack.on_inherit.dup
7
+ end
8
+ after(:all) do
9
+ Pancake::Stack.on_inherit.clear
10
+ $on_inherit_blocks.each do |blk|
11
+ Pancake::Stack.on_inherit(&blk)
12
+ end
13
+ end
14
+
15
+ before(:each) do
16
+ $collector = []
17
+ clear_constants(:FooStack)
18
+ Pancake::Stack.on_inherit.clear
19
+ end
20
+
21
+ after(:each) do
22
+ clear_constants(:FooStack)
23
+ end
24
+
25
+ it "should be able to add inheritance hooks" do
26
+ Pancake::Stack.on_inherit do |base, parent|
27
+ $collector << base
28
+ end
29
+ class ::FooStack < Pancake::Stack; end
30
+ $collector.should == [FooStack]
31
+ end
32
+
33
+ it "should be able to add multiple inheritance hooks" do
34
+ Pancake::Stack.on_inherit{|b,p| $collector << b}
35
+ Pancake::Stack.on_inherit{|b,p| $collector << :foo}
36
+
37
+ class ::FooStack < Pancake::Stack
38
+ end
39
+
40
+ $collector.should == [FooStack, :foo]
41
+ end
42
+
43
+ end
44
+
45
+ describe "Inheriting Stacks" do
46
+ before(:all) do
47
+ clear_constants(:FooStack, :BarStack)
48
+ end
49
+
50
+ before(:each) do
51
+ class ::FooStack < Pancake::Stack; end
52
+ end
53
+
54
+ after(:each) do
55
+ clear_constants(:FooStack, :BarStack)
56
+ end
57
+
58
+ describe "configuration" do
59
+ it "should inherit the configuration with a stack" do
60
+ class ::BarStack < ::FooStack; end
61
+ BarStack::Configuration.should inherit_from(FooStack::Configuration)
62
+ end
63
+ end
64
+ end
65
+ end