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,27 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe Pancake::Mixins::RequestHelper do
4
+ before do
5
+ class ::FooBar
6
+ include Pancake::Mixins::RequestHelper
7
+ end
8
+ end
9
+
10
+ after do
11
+ clear_constants :FooBar
12
+ end
13
+
14
+ describe "logger" do
15
+ before do
16
+ @logger = mock("logger")
17
+ @app = FooBar.new
18
+ @app.env = {Pancake::Constants::ENV_LOGGER_KEY => @logger}
19
+ end
20
+
21
+ it "should access the rack.logger variable when using" do
22
+ @logger.should_receive(:foo)
23
+ @app.logger.foo
24
+ end
25
+ end
26
+
27
+ end
@@ -0,0 +1,46 @@
1
+ require File.join(File.expand_path(File.dirname(__FILE__)), "..","..","spec_helper")
2
+
3
+ describe Pancake::Mixins::StackHelper do
4
+ before do
5
+ class ::FooStack < Pancake::Stack
6
+ class Bar
7
+ include Pancake::Mixins::StackHelper
8
+ end
9
+ end
10
+ end
11
+
12
+ after do
13
+ clear_constants :FooStack, :BarStack, :FooBar
14
+ end
15
+
16
+ it "should provide access to the stack helper to the Bar class" do
17
+ FooStack::Bar.stack_class.should == FooStack
18
+ end
19
+
20
+ it "should track the class for a newly namespaced stack" do
21
+ class ::BarStack < FooStack
22
+ class Bar < ::FooStack::Bar
23
+ end
24
+ end
25
+
26
+ BarStack::Bar.stack_class.should == BarStack
27
+ end
28
+
29
+ it "should raise an exception when including it into a class that is not of a stack" do
30
+ lambda do
31
+ class ::FooBar
32
+ include Pancake::Mixins::StackHelper
33
+ end
34
+ end.should raise_error
35
+ end
36
+
37
+ it "should remember the stack it was initially mixed into if it's inherited to a non namespaced class" do
38
+ class ::FooBar < FooStack::Bar; end
39
+ FooBar.stack_class.should == FooStack
40
+ end
41
+
42
+ it "should provide access to the stack helper from an instance of the Bar class" do
43
+ FooStack::Bar.new.stack_class.should == FooStack
44
+ end
45
+
46
+ end
@@ -0,0 +1,90 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe "pancake" do
4
+
5
+ it "should get the correct root directory for a file" do
6
+ Pancake.get_root(__FILE__).should == File.expand_path(File.dirname(__FILE__))
7
+ end
8
+
9
+ it "should join the arguments together to form a path" do
10
+ Pancake.get_root(__FILE__, "foo").should == File.expand_path(File.join(File.dirname(__FILE__), "foo"))
11
+ end
12
+
13
+ describe "stack labels" do
14
+ before(:each) do
15
+ @orig_lables = Pancake.stack_labels
16
+ end
17
+
18
+ after(:each) do
19
+ Pancake.stack_labels = @orig_labels
20
+ end
21
+
22
+ it "should allow me to set a stack type on panckae" do
23
+ Pancake.stack_labels = [:foo, :bar]
24
+ Pancake.stack_labels.should == [:foo, :bar]
25
+ end
26
+
27
+ it "should provide me with stack label of [:production] by default" do
28
+ Pancake.stack_labels = nil
29
+ Pancake.stack_labels.should == [:production]
30
+ Pancake.stack_labels = []
31
+ Pancake.stack_labels.should == [:production]
32
+ end
33
+ end
34
+
35
+ describe "handle errors" do
36
+ before do
37
+ @orig_env = ENV['RACK_ENV']
38
+ end
39
+
40
+ after do
41
+ ENV['RACK_ENV'] = @orig_env
42
+ end
43
+
44
+ it "should allow me to set the error handling status to true" do
45
+ Pancake.handle_errors!(true)
46
+ Pancake.handle_errors?.should be_true
47
+ end
48
+
49
+ it "should allow me to set the error handling status to a false" do
50
+ Pancake.handle_errors!(false)
51
+ Pancake.handle_errors?.should be_false
52
+ end
53
+
54
+ it "should allow me to set the error handling status to a value" do
55
+ Pancake.handle_errors!("some_string")
56
+ ENV['RACK_ENV'] = "some_string"
57
+ Pancake.handle_errors?.should be_true
58
+ ENV['RACK_ENV'] = "other string"
59
+ Pancake.handle_errors?.should be_false
60
+ end
61
+
62
+ it "should allow me to set the error handling status to an array of strings" do
63
+ Pancake.handle_errors!("some", "another")
64
+ ENV['RACK_ENV'] = "some"
65
+ Pancake.handle_errors?.should be_true
66
+ ENV['RACK_ENV'] = "another"
67
+ Pancake.handle_errors?.should be_true
68
+ ENV['RACK_ENV'] = "different"
69
+ Pancake.handle_errors?.should be_false
70
+ end
71
+
72
+ it "should default to handling errors in production" do
73
+ Pancake.default_error_handling!
74
+ ENV['RACK_ENV'] = "production"
75
+ Pancake.handle_errors?.should be_true
76
+ end
77
+
78
+ it "should default to not handling errors in development" do
79
+ Pancake.default_error_handling!
80
+ ENV['RACK_ENV'] = "development"
81
+ Pancake.default_error_handling!
82
+ end
83
+
84
+ it "should default to handling errors in test" do
85
+ Pancake.default_error_handling!
86
+ ENV['RACK_ENV'] = "test"
87
+ Pancake.default_error_handling!
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,210 @@
1
+ require File.dirname(__FILE__) + '/../spec_helper'
2
+
3
+ describe Pancake::Paths do
4
+
5
+ def fixture_root
6
+ File.expand_path(File.join(File.dirname(__FILE__), "fixtures", "paths"))
7
+ end
8
+
9
+ before(:each) do
10
+ remove_consts!
11
+ class ::Foo
12
+ extend Pancake::Paths
13
+ end
14
+ end
15
+
16
+ after(:all) do
17
+ remove_consts!
18
+ end
19
+
20
+ def remove_consts!
21
+ Object.class_eval do
22
+ remove_const("Foo") if defined?(Foo)
23
+ remove_const("Bar") if defined?(Bar)
24
+ remove_const("Baz") if defined?(Baz)
25
+ end
26
+ end
27
+
28
+ describe "setting roots" do
29
+ it "should allow me to set roots" do
30
+ Foo.roots.should == []
31
+ Foo.roots << fixture_root
32
+ Foo.roots.should == [fixture_root]
33
+ end
34
+ end
35
+
36
+ describe "pushing paths" do
37
+ before do
38
+ Foo.roots << fixture_root
39
+ end
40
+
41
+ it "should push a single path" do
42
+ Foo.push_paths(:models, "models")
43
+ Foo.dirs_for(:models).should == [File.join(fixture_root,"models")]
44
+ end
45
+
46
+ it "should give me an empty array of paths when there have been no paths added" do
47
+ Foo.dirs_for(:models).should == []
48
+ end
49
+
50
+ it "should raise and error if there are no paths specified" do
51
+ lambda do
52
+ Foo.push_paths(:models)
53
+ end.should raise_error(ArgumentError)
54
+
55
+ lambda do
56
+ Foo.push_paths(:models, [])
57
+ end.should raise_error(Pancake::Paths::NoPathsGiven)
58
+ end
59
+
60
+ it "should allow me to push multiple times to a single path group" do
61
+ Foo.push_paths(:models, "models")
62
+ Foo.push_paths(:models, "stack/models")
63
+ Foo.dirs_for(:models).should == [
64
+ File.join(fixture_root, "models"),
65
+ File.join(fixture_root, "stack", "models")
66
+ ]
67
+ end
68
+
69
+ it "should allow me to push multiple path sets" do
70
+ Foo.push_paths(:models, ["models", "stack/models"])
71
+ Foo.push_paths(:controllers, "controllers")
72
+ Foo.push_paths(:views, "stack/views")
73
+ Foo.dirs_for(:models).should == [
74
+ File.join(fixture_root, "models"),
75
+ File.join(fixture_root, "stack", "models")
76
+ ]
77
+ Foo.dirs_for(:controllers ).should == [File.join(fixture_root, "controllers")]
78
+ Foo.dirs_for(:views ).should == [File.join(fixture_root, "stack", "views")]
79
+ end
80
+
81
+ it "should reverse the dirs_for when specified" do
82
+ Foo.push_paths(:models, ["models", "stack/models"])
83
+ Foo.dirs_for(:models, :invert => true).should == [
84
+ File.join(fixture_root, "stack", "models"),
85
+ File.join(fixture_root, "models")
86
+ ]
87
+ end
88
+
89
+ describe "globs" do
90
+ it "should allow me to supply a glob to associate with the path" do
91
+ Foo.push_paths(:models, "models", "**/*.rb")
92
+ Foo.push_paths(:models, "stack/models", "**/*.rb")
93
+ Foo.dirs_and_glob_for(:models).should == [
94
+ [File.join(fixture_root, "models"), "**/*.rb"],
95
+ [File.join(fixture_root, "stack", "models"), "**/*.rb"]
96
+ ]
97
+ end
98
+
99
+ it "should associate an empty glob when not specified" do
100
+ Foo.push_paths(:models, "foo/bar")
101
+ Foo.dirs_for(:models).should == [File.join(fixture_root, "foo/bar")]
102
+ Foo.dirs_and_glob_for(:models).should == [[File.join(fixture_root, "foo/bar"), nil]]
103
+ end
104
+
105
+ it "should revers the dirs_and_globs when requested" do
106
+ Foo.push_paths(:models, "models", "**/*.rb")
107
+ Foo.push_paths(:models, "stack/models", "**/*.rb")
108
+ result = Foo.dirs_and_glob_for(:models, :invert => true)
109
+ result.should == [
110
+ [File.join(fixture_root, "stack", "models"), "**/*.rb"],
111
+ [File.join(fixture_root, "models"), "**/*.rb"]
112
+ ]
113
+ end
114
+ end
115
+ end
116
+
117
+ describe "reading paths" do
118
+ before(:each) do
119
+ @model_root = File.join(fixture_root, "models")
120
+ @stack_root = File.join(fixture_root, "stack/models")
121
+ Foo.roots << fixture_root
122
+ Foo.push_paths(:model, ["models", "stack/models"], "**/*.rb")
123
+ end
124
+
125
+ it "should have list all the paths for :model" do
126
+ result = Foo.paths_for(:model).should == [
127
+ [@model_root, "/model1.rb"],
128
+ [@model_root, "/model2.rb"],
129
+ [@model_root, "/model3.rb"],
130
+ [@stack_root, "/model3.rb"]
131
+ ]
132
+ end
133
+
134
+ it "should allow me to invert the order of the roots" do
135
+ result = Foo.paths_for(:model, :invert => true).should == [
136
+ [@stack_root, "/model3.rb"],
137
+ [@model_root, "/model3.rb"],
138
+ [@model_root, "/model2.rb"],
139
+ [@model_root, "/model1.rb"]
140
+ ]
141
+ end
142
+
143
+ it "should allow me to get the unique_paths" do
144
+ result = Foo.unique_paths_for(:model).should == [
145
+ [@model_root, "/model1.rb"],
146
+ [@model_root, "/model2.rb"],
147
+ [@stack_root, "/model3.rb"]
148
+ ]
149
+ end
150
+
151
+ it "should allow me to invert the order of the unique_paths" do
152
+ result = Foo.unique_paths_for(:model, :invert => true).should == [
153
+ [@model_root, "/model3.rb"],
154
+ [@model_root, "/model2.rb"],
155
+ [@model_root, "/model1.rb"]
156
+ ]
157
+ end
158
+ end
159
+
160
+ describe "inherited paths" do
161
+ before(:each) do
162
+ Foo.push_paths(:model, "models")
163
+ Foo.push_paths(:controller, "controllers")
164
+ Foo.roots << fixture_root
165
+ class ::Bar < Foo; end
166
+ end
167
+
168
+ it "should inherit paths from the parent" do
169
+ Bar.dirs_for(:model).should == [File.join(fixture_root, "models")]
170
+ Bar.dirs_for(:controller).should == [File.join(fixture_root, "controllers")]
171
+ end
172
+
173
+ it "should let me add to the collection from the parent" do
174
+ Bar.push_paths(:model, "stack/models")
175
+ Bar.dirs_for(:model).should == [
176
+ File.join(fixture_root, "models"),
177
+ File.join(fixture_root, "stack/models")
178
+ ]
179
+ end
180
+
181
+ it "should not bleed paths back up to the parent" do
182
+ Bar.push_paths(:model, "stack/models")
183
+ Foo.dirs_for(:model).should == [File.join(fixture_root, "models")]
184
+ end
185
+
186
+ it "should not bleed paths over to a sibling class" do
187
+ class ::Baz < Foo; end
188
+ Bar.push_paths(:model, "stack/models")
189
+ Baz.push_paths(:model, "baz/paths")
190
+ Bar.dirs_for(:model).should == [
191
+ File.join(fixture_root, "models"),
192
+ File.join(fixture_root, "stack/models")
193
+ ]
194
+ Baz.dirs_for(:model).should == [
195
+ File.join(fixture_root, "models"),
196
+ File.join(fixture_root, "baz/paths")
197
+ ]
198
+ Foo.dirs_for(:model).should == [File.join(fixture_root, "models")]
199
+ end
200
+
201
+ it "should inherit multpile times" do
202
+ class ::Baz < Bar; end
203
+ Bar.push_paths(:model, "bar/path")
204
+ Baz.dirs_for(:model).should == [
205
+ File.join(fixture_root, "models"),
206
+ File.join(fixture_root, "bar/path")
207
+ ]
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,28 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "Pancake::Stack.new_app_instance" do
4
+
5
+ before(:each) do
6
+ class ::FooStack < Pancake::Stack
7
+
8
+ end
9
+ end
10
+
11
+ after(:each) do
12
+ clear_constants(:FooStack)
13
+ end
14
+
15
+ it "should provide a new instance of the applciation" do
16
+ FooStack.new_app_instance.should == Pancake::MISSING_APP
17
+ end
18
+
19
+ it "should allow me to overwrite the new_app_instance for this stack" do
20
+ class ::BarStack < Pancake::Stack
21
+ def self.new_app_instance
22
+ ::Pancake::OK_APP
23
+ end
24
+ end
25
+
26
+ BarStack.new_app_instance.should == ::Pancake::OK_APP
27
+ end
28
+ end
@@ -0,0 +1,41 @@
1
+ require File.dirname(__FILE__) + '/../../spec_helper'
2
+
3
+ describe "Stack BootLoaders" do
4
+
5
+ before(:each) do
6
+ clear_constants(:FooStack, :BarStack)
7
+ end
8
+
9
+ it "should inherit the standard bootloaders from Pancake::Stack" do
10
+ class ::FooStack < Pancake::Stack; end
11
+ FooStack::BootLoader.should inherit_from(Pancake::Stack::BootLoader)
12
+ end
13
+
14
+ it "should get all the bootloaders from pancake stack" do
15
+ class ::FooStack < Pancake::Stack; end
16
+ FooStack::BootLoader.map{|n,bl|n}.should == Pancake::Stack::BootLoader.map{|n,bl|n}
17
+ end
18
+
19
+ it "should let FooStack define it's own bootloaders" do
20
+ class ::FooStack < Pancake::Stack; end
21
+ FooStack::BootLoader.add(:foo_stack_bootloader){ def run!; end }
22
+ FooStack::BootLoader.map{|n,b|n}.should include(:foo_stack_bootloader)
23
+ Pancake::Stack::BootLoader.map{|n,b|n}.should_not include(:foo_stack_bootloader)
24
+ end
25
+
26
+ it "should not pollute other bootloaders" do
27
+ class ::FooStack < Pancake::Stack; end
28
+ FooStack::BootLoader.add(:foo_stack_bootloader){ def run!; end }
29
+ class ::BarStack < Pancake::Stack; end
30
+ FooStack::BootLoader.map{|n,b|n}.should_not == BarStack::BootLoader.map{|n,b|n}
31
+ BarStack::BootLoader.map{|n,b|n}.should_not include(:foo_stack_bootloader)
32
+ end
33
+
34
+ it "should inherit custom bootloaders" do
35
+ class ::FooStack < Pancake::Stack; end
36
+ FooStack::BootLoader.add(:foo_stack_bootloader){ def run!; end }
37
+ class ::BarStack < FooStack; end
38
+ BarStack::BootLoader.map{|n,b|n}.should include(:foo_stack_bootloader)
39
+ end
40
+
41
+ end
File without changes