vanilla 1.2 → 1.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (106) hide show
  1. data/Rakefile +61 -60
  2. data/bin/vanilla +6 -35
  3. data/config.example.yml +6 -0
  4. data/config.ru +10 -0
  5. data/lib/defensio.rb +59 -0
  6. data/lib/tasks/vanilla.rake +173 -0
  7. data/lib/vanilla.rb +3 -10
  8. data/lib/vanilla/app.rb +48 -104
  9. data/lib/vanilla/console.rb +5 -19
  10. data/lib/vanilla/dynasnips/comments.rb +108 -0
  11. data/lib/vanilla/dynasnips/current_snip.rb +32 -0
  12. data/{pristine_app/soups → lib/vanilla}/dynasnips/debug.rb +3 -5
  13. data/lib/vanilla/dynasnips/edit.rb +60 -0
  14. data/lib/vanilla/dynasnips/edit_link.rb +20 -0
  15. data/{pristine_app/soups → lib/vanilla}/dynasnips/index.rb +2 -4
  16. data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/kind.rb +12 -14
  17. data/{pristine_app/soups → lib/vanilla}/dynasnips/link_to.rb +0 -2
  18. data/lib/vanilla/dynasnips/link_to_current_snip.rb +16 -0
  19. data/lib/vanilla/dynasnips/login.rb +56 -0
  20. data/lib/vanilla/dynasnips/new.rb +14 -0
  21. data/lib/vanilla/dynasnips/notes.rb +42 -0
  22. data/{pristine_app/soups → lib/vanilla}/dynasnips/pre.rb +4 -6
  23. data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/rand.rb +0 -2
  24. data/{pristine_app/soups → lib/vanilla}/dynasnips/raw.rb +5 -8
  25. data/{pristine_app/soups/extras → lib/vanilla/dynasnips}/url_to.rb +0 -0
  26. data/lib/vanilla/renderers/base.rb +22 -32
  27. data/lib/vanilla/renderers/bold.rb +2 -0
  28. data/lib/vanilla/renderers/erb.rb +2 -0
  29. data/lib/vanilla/renderers/markdown.rb +2 -0
  30. data/lib/vanilla/renderers/raw.rb +2 -0
  31. data/lib/vanilla/renderers/ruby.rb +5 -9
  32. data/lib/vanilla/renderers/textile.rb +2 -0
  33. data/lib/vanilla/request.rb +15 -16
  34. data/lib/vanilla/routes.rb +18 -5
  35. data/lib/vanilla/snip_reference.rb +534 -0
  36. data/lib/vanilla/snip_reference.treetop +48 -0
  37. data/lib/vanilla/snip_reference_parser.rb +99 -82
  38. data/lib/vanilla/snips/start.rb +28 -0
  39. data/lib/vanilla/snips/system.rb +77 -0
  40. data/lib/vanilla/snips/tutorial.rb +244 -0
  41. data/lib/vanilla/soup_with_timestamps.rb +21 -0
  42. data/public/hatch.png +0 -0
  43. data/public/javascripts/jquery.autogrow-textarea.js +54 -0
  44. data/public/javascripts/jquery.js +4376 -0
  45. data/public/javascripts/vanilla.js +22 -0
  46. data/spec/dynasnip_spec.rb +28 -0
  47. data/spec/renderers/base_renderer_spec.rb +40 -0
  48. data/spec/renderers/erb_renderer_spec.rb +27 -0
  49. data/spec/renderers/markdown_renderer_spec.rb +29 -0
  50. data/spec/renderers/raw_renderer_spec.rb +21 -0
  51. data/spec/renderers/ruby_renderer_spec.rb +59 -0
  52. data/spec/renderers/vanilla_app_detecting_renderer_spec.rb +35 -0
  53. data/spec/spec_helper.rb +70 -0
  54. data/spec/tmp/config.yml +2 -0
  55. data/spec/tmp/soup/current_snip.yml +15 -0
  56. data/spec/tmp/soup/system.yml +5 -0
  57. data/spec/vanilla_app_spec.rb +38 -0
  58. data/spec/vanilla_presenting_spec.rb +84 -0
  59. data/spec/vanilla_request_spec.rb +73 -0
  60. metadata +79 -170
  61. data/lib/vanilla/renderers.rb +0 -12
  62. data/lib/vanilla/renderers/haml.rb +0 -13
  63. data/lib/vanilla/static.rb +0 -28
  64. data/pristine_app/Gemfile +0 -3
  65. data/pristine_app/Gemfile.lock +0 -32
  66. data/pristine_app/README +0 -47
  67. data/pristine_app/config.ru +0 -26
  68. data/pristine_app/public/vanilla.css +0 -15
  69. data/pristine_app/soups/base/layout.snip +0 -18
  70. data/pristine_app/soups/base/start.snip +0 -19
  71. data/pristine_app/soups/dynasnips/current_snip.rb +0 -29
  72. data/pristine_app/soups/dynasnips/link_to_current_snip.rb +0 -14
  73. data/pristine_app/soups/dynasnips/page_title.rb +0 -9
  74. data/pristine_app/soups/extras/comments.rb +0 -78
  75. data/pristine_app/soups/tutorial/bad_dynasnip.snip +0 -8
  76. data/pristine_app/soups/tutorial/hello_world.snip +0 -20
  77. data/pristine_app/soups/tutorial/markdown_example.snip +0 -13
  78. data/pristine_app/soups/tutorial/snip.snip +0 -9
  79. data/pristine_app/soups/tutorial/soup.snip +0 -3
  80. data/pristine_app/soups/tutorial/test.snip +0 -30
  81. data/pristine_app/soups/tutorial/textile_example.snip +0 -11
  82. data/pristine_app/soups/tutorial/tutorial-another-snip.snip +0 -1
  83. data/pristine_app/soups/tutorial/tutorial-basic-snip-inclusion.snip +0 -1
  84. data/pristine_app/soups/tutorial/tutorial-dynasnips.snip.markdown +0 -56
  85. data/pristine_app/soups/tutorial/tutorial-layout.snip +0 -56
  86. data/pristine_app/soups/tutorial/tutorial-links.snip +0 -4
  87. data/pristine_app/soups/tutorial/tutorial-renderers.snip.markdown +0 -77
  88. data/pristine_app/soups/tutorial/tutorial.snip.markdown +0 -69
  89. data/pristine_app/soups/tutorial/vanilla-rb.snip +0 -16
  90. data/pristine_app/soups/tutorial/vanilla.snip +0 -8
  91. data/test/dynasnip_test.rb +0 -42
  92. data/test/dynasnips/link_to_current_snip_test.rb +0 -19
  93. data/test/dynasnips/link_to_test.rb +0 -27
  94. data/test/dynasnips/page_title_test.rb +0 -19
  95. data/test/renderers/base_renderer_test.rb +0 -43
  96. data/test/renderers/erb_renderer_test.rb +0 -29
  97. data/test/renderers/haml_renderer_test.rb +0 -35
  98. data/test/renderers/markdown_renderer_test.rb +0 -31
  99. data/test/renderers/raw_renderer_test.rb +0 -23
  100. data/test/renderers/ruby_renderer_test.rb +0 -59
  101. data/test/snip_inclusion_test.rb +0 -56
  102. data/test/snip_reference_parser_test.rb +0 -123
  103. data/test/test_helper.rb +0 -75
  104. data/test/vanilla_app_test.rb +0 -83
  105. data/test/vanilla_presenting_test.rb +0 -125
  106. data/test/vanilla_request_test.rb +0 -87
@@ -0,0 +1,22 @@
1
+ function vanillaPrepareEditor() {
2
+ $('input.attribute_name').change(function() {
3
+ var dl_children = $('dl.attributes').children();
4
+ var dt_index = dl_children.index(this.parentNode) + 1;
5
+ var textarea_for_this = dl_children[dt_index].childNodes[0];
6
+ textarea_for_this.name = this.value;
7
+ });
8
+ $('textarea').autogrow();
9
+ }
10
+
11
+ $(document).ready(function() {
12
+
13
+ $('a#add').click(function() {
14
+ $('dl.attributes').append('<dt><input class="attribute_name" type="text"></input></dt><dd><textarea></textarea></dd>');
15
+ vanillaPrepareEditor();
16
+ return false;
17
+ });
18
+
19
+ vanillaPrepareEditor();
20
+
21
+ });
22
+
@@ -0,0 +1,28 @@
1
+ require File.join(File.dirname(__FILE__), "spec_helper")
2
+ require 'vanilla/dynasnip'
3
+
4
+ describe Dynasnip, "when storing attributes" do
5
+ class TestDyna < Dynasnip
6
+ attribute :test_attribute, "test attribute content"
7
+ end
8
+
9
+ it "should make the attribute available as an instance method" do
10
+ p TestDyna.new(@app).test_attribute
11
+ TestDyna.new(@app).test_attribute.should == "test attribute content"
12
+ end
13
+
14
+ it "should store the attribute in the soup" do
15
+ @app.soup << TestDyna.snip_attributes
16
+ @app.soup['test_dyna'].test_attribute.should == "test attribute content"
17
+ end
18
+
19
+ it "should allow the attribute to be overriden by the soup contents" do
20
+ @app.soup << TestDyna.snip_attributes
21
+ snip = @app.soup['test_dyna']
22
+ snip.test_attribute = "altered content"
23
+ snip.save
24
+
25
+ TestDyna.new(@app).test_attribute.should == "altered content"
26
+ end
27
+
28
+ end
@@ -0,0 +1,40 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
2
+
3
+ describe Vanilla::Renderers::Base do
4
+ describe "in general" do
5
+ before(:each) do
6
+ create_snip(:name => "test", :content => "content content", :part => "part content")
7
+ end
8
+
9
+ it "should render the contents part of the snip as it is" do
10
+ response_body_for("/test").should == "content content"
11
+ end
12
+
13
+ it "should render the specified part of the snip" do
14
+ response_body_for("/test/part").should == "part content"
15
+ end
16
+
17
+ it "should include the contents of a referenced snip" do
18
+ create_snip(:name => "snip_with_inclusions", :content => "loading {test}")
19
+ response_body_for("/snip_with_inclusions").should == "loading content content"
20
+ end
21
+
22
+ it "should perform snip inclusion when rendering a part" do
23
+ create_snip(:name => "snip_with_inclusions", :content => "other content", :part => "loading {test}")
24
+ response_body_for("/snip_with_inclusions/part").should == "loading content content"
25
+ end
26
+
27
+ it "should include other snips using their renderers" do
28
+ create_snip(:name => "including_snip", :content => "lets include {another_snip}")
29
+ create_snip(:name => "another_snip", :content => "blah", :render_as => "Bold")
30
+ response_body_for("/including_snip").gsub(/\s+/, ' ').should == "lets include <b>blah</b>"
31
+ end
32
+ end
33
+
34
+ describe "when trying to include a missing snip" do
35
+ it "should return a string describing the missing snip" do
36
+ create_snip(:name => 'blah', :content => 'include a {missing_snip}')
37
+ response_body_for("/blah").should == "include a [snip 'missing_snip' cannot be found]"
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,27 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
2
+
3
+ describe Vanilla::Renderers::Erb, "when rendering" do
4
+ def erb_snip(params)
5
+ create_snip(params.merge(:render_as => "Erb"))
6
+ end
7
+
8
+ it "should insert evaluated Erb content into the snip" do
9
+ erb_snip(:name => "test", :content => "<%= 1 + 2 %>")
10
+ response_body_for("/test").should == "3"
11
+ end
12
+
13
+ it "should evaluate Erb content in the snip" do
14
+ erb_snip(:name => "test", :content => "<% if false %>monkey<% else %>donkey<% end %>")
15
+ response_body_for("/test").should == "donkey"
16
+ end
17
+
18
+ it "should expose the snip as an instance variable" do
19
+ erb_snip(:name => "test", :content => "<%= @snip.name %>")
20
+ response_body_for("/test").should == "test"
21
+ end
22
+
23
+ it "shoudl expose the app as an instance variable" do
24
+ erb_snip(:name => "test", :content => "<%= @app.class.name %>")
25
+ response_body_for("/test").should == "Vanilla::App"
26
+ end
27
+ end
@@ -0,0 +1,29 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
2
+
3
+ describe Vanilla::Renderers::Markdown, "when rendering" do
4
+ def markdown_snip(attributes)
5
+ create_snip(attributes.merge(:render_as => "Markdown"))
6
+ end
7
+
8
+ it "should return the snip contents rendered via Markdown" do
9
+ content = <<Markdown
10
+ # markdown
11
+
12
+ * totally
13
+ * [rocks](http://www.example.com)!
14
+ Markdown
15
+ markdown_snip(:name => "test", :content => content)
16
+ response_body_for("/test").should == BlueCloth.new(content).to_html
17
+ end
18
+
19
+ it "should include other snips using their renderers" do
20
+ markdown_snip(:name => "test", :content => <<-Markdown
21
+ # markdown
22
+
23
+ and so lets include {another_snip}
24
+ Markdown
25
+ )
26
+ create_snip(:name => "another_snip", :content => "blah", :render_as => "Bold")
27
+ response_body_for("/test").gsub(/\s+/, ' ').should == "<h1>markdown</h1> <p>and so lets include <b>blah</b> </p>"
28
+ end
29
+ end
@@ -0,0 +1,21 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
2
+
3
+ describe Vanilla::Renderers::Raw, "when rendering" do
4
+ before(:each) do
5
+ @snip = create_snip(:name => "test", :content => "raw content", :part => "raw part")
6
+ set_main_template "<tag>{current_snip}</tag>"
7
+ end
8
+
9
+ it "should render the contents part of the snip as it is" do
10
+ response_body_for("/test.raw").should == "raw content"
11
+ end
12
+
13
+ it "should render the specified part of the snip" do
14
+ response_body_for("/test/part.raw").should == "raw part"
15
+ end
16
+
17
+ it "should not perform any snip inclusion" do
18
+ create_snip(:name => "snip_with_inclusions", :content => "loading {another_snip}")
19
+ response_body_for("/snip_with_inclusions.raw").should == "loading {another_snip}"
20
+ end
21
+ end
@@ -0,0 +1,59 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
2
+
3
+ describe Vanilla::Renderers::Ruby do
4
+ describe "when rendering normally" do
5
+ class TestDyna < Dynasnip
6
+ def handle(*args)
7
+ 'handle called'
8
+ end
9
+ end
10
+
11
+ before(:each) do
12
+ @app.soup << TestDyna.snip_attributes
13
+ end
14
+
15
+ it "should render the result of the handle method" do
16
+ response_body_for("/test_dyna").should == 'handle called'
17
+ end
18
+ end
19
+
20
+ describe "when responding restfully" do
21
+ class RestishDyna < Dynasnip
22
+ def get(*args)
23
+ 'get called'
24
+ end
25
+ def post(*args)
26
+ 'post called'
27
+ end
28
+ end
29
+
30
+ before(:each) do
31
+ @app.soup << RestishDyna.snip_attributes
32
+ end
33
+
34
+ it "should render the result of the get method on GET requests" do
35
+ response_body_for("/restish_dyna").should == 'get called'
36
+ end
37
+
38
+ it "should render the result of the post method on POST requests" do
39
+ response_body_for("/restish_dyna?_method=post") == 'post called'
40
+ end
41
+ end
42
+
43
+ describe "when knowing about enclosing snips" do
44
+ class Encloser < Dynasnip
45
+ def handle(*args)
46
+ "enclosing snip is #{enclosing_snip.name}"
47
+ end
48
+ end
49
+
50
+ before(:each) do
51
+ @app.soup << Encloser.snip_attributes
52
+ create_snip(:name => "test", :content => "{encloser}")
53
+ end
54
+
55
+ it "should know about the snip that called this dynasnip" do
56
+ response_body_for("/test").should == 'enclosing snip is test'
57
+ end
58
+ end
59
+ end
@@ -0,0 +1,35 @@
1
+ require File.join(File.dirname(__FILE__), "..", "spec_helper")
2
+
3
+ describe "when detecting the snip renderer" do
4
+ before(:each) do
5
+ @app = Vanilla::App.new
6
+ end
7
+
8
+ it "should return the constant refered to in the render_as property of the snip" do
9
+ snip = create_snip(:name => "blah", :render_as => "Raw")
10
+ @app.renderer_for(snip).should == Vanilla::Renderers::Raw
11
+ end
12
+
13
+ it "should return Vanilla::Renderers::Base if no render_as property exists" do
14
+ snip = create_snip(:name => "blah")
15
+ @app.renderer_for(snip).should == Vanilla::Renderers::Base
16
+ end
17
+
18
+ it "should return Vanilla::Renderers::Base if the render_as property is blank" do
19
+ snip = create_snip(:name => "blah", :render_as => '')
20
+ @app.renderer_for(snip).should == Vanilla::Renderers::Base
21
+ end
22
+
23
+ it "should raise an error if the specified renderer doesn't exist" do
24
+ snip = create_snip(:name => "blah", :render_as => "NonExistentClass")
25
+ lambda { @app.renderer_for(snip) }.should raise_error
26
+ end
27
+
28
+ it "should load constants outside of the Vanilla::Renderers module" do
29
+ class ::MyRenderer
30
+ end
31
+
32
+ snip = create_snip(:name => "blah", :render_as => "MyRenderer")
33
+ @app.renderer_for(snip).should == MyRenderer
34
+ end
35
+ end
@@ -0,0 +1,70 @@
1
+ $LOAD_PATH.unshift File.join(File.dirname(__FILE__), *%w[.. lib])
2
+ require "vanilla"
3
+ require "spec"
4
+ require "fileutils"
5
+ require "rack/mock"
6
+
7
+ module Vanilla
8
+ module Test
9
+ def setup_clean_environment
10
+ FileUtils.mkdir_p(File.dirname(test_config_file))
11
+ clear_soup
12
+ File.open(test_config_file, 'w') { |f| f.write({:soup => soup_path}.to_yaml) }
13
+ @app = Vanilla::App.new(test_config_file)
14
+
15
+ require "vanilla/dynasnips/current_snip"
16
+ @app.soup << CurrentSnip.snip_attributes
17
+ create_snip :name => "system", :main_template => "{current_snip}"
18
+ end
19
+
20
+ def response_for(url)
21
+ @app.call(mock_env_for_url(url))
22
+ end
23
+
24
+ def response_body_for(url)
25
+ response_for(url)[2].body[0]
26
+ end
27
+
28
+ def response_code_for(url)
29
+ response_for(url)[0]
30
+ end
31
+
32
+ def set_main_template(template_content)
33
+ system = @app.soup["system"] || Snip.new({:name => "system"}, @app.soup)
34
+ system.main_template = template_content
35
+ system.save
36
+ end
37
+
38
+ def create_snip(params)
39
+ s = Snip.new(params, @app.soup)
40
+ s.save
41
+ s
42
+ end
43
+
44
+ def mock_env_for_url(url)
45
+ Rack::MockRequest.env_for(url)
46
+ end
47
+
48
+ def mock_request(url)
49
+ Rack::Request.new(mock_env_for_url(url))
50
+ end
51
+
52
+ def test_config_file
53
+ File.join(File.dirname(__FILE__), "tmp", "config.yml")
54
+ end
55
+
56
+ def soup_path
57
+ File.expand_path(File.join(File.dirname(__FILE__), "tmp", "soup"))
58
+ end
59
+
60
+ def clear_soup
61
+ FileUtils.rm_rf(soup_path)
62
+ end
63
+ end
64
+ end
65
+
66
+ Spec::Runner.configure do |config|
67
+ config.include(Vanilla::Test)
68
+ config.before { setup_clean_environment }
69
+ end
70
+
@@ -0,0 +1,2 @@
1
+ ---
2
+ :soup: /Users/james/Code/lazyatom/vanilla-rb/spec/tmp/soup
@@ -0,0 +1,15 @@
1
+ CurrentSnip--- # Soup attributes
2
+ :name: current_snip
3
+ :render_as: Ruby
4
+ :created_at: 2009-10-12 17:39:26.752915 +01:00
5
+ :updated_at: 2009-10-12 17:39:26.752917 +01:00
6
+ :usage: |-
7
+ The current_snip dyna normally returns the result of rendering the snip named by the
8
+ 'snip' value in the parameters. This way, it can be used in templates to place the currently
9
+ requested snip, in its rendered form, within the page.
10
+
11
+ It can also be used to determine the name of the current snip in a consistent way:
12
+
13
+ &#123;current_snip name&#125;
14
+
15
+ will output the name of the current snip, or the name of the snip currently being edited.
@@ -0,0 +1,5 @@
1
+ --- # Soup attributes
2
+ :name: system
3
+ :created_at: 2009-10-12 17:39:26.757197 +01:00
4
+ :updated_at: 2009-10-12 17:39:26.757199 +01:00
5
+ :main_template: "{current_snip}"
@@ -0,0 +1,38 @@
1
+ require File.join(File.dirname(__FILE__), 'spec_helper')
2
+
3
+ describe Vanilla::App do
4
+ describe "when behaving as a Rack application" do
5
+ it "should return an array of status code, headers and response" do
6
+ create_snip(:name => "test", :content => "content")
7
+ result = @app.call(mock_env_for_url("/test.text"))
8
+ result.should be_a_kind_of(Array)
9
+ result[0].should == 200
10
+ result[1].should be_a_kind_of(Hash)
11
+ result[2].each{ |output| output.should == "content" }
12
+ end
13
+ end
14
+
15
+ describe "when being configured" do
16
+ it "should load a config file from the current working directory by default" do
17
+ File.should_receive(:open).with("config.yml").and_return(StringIO.new({:soup => soup_path}.to_yaml))
18
+ Vanilla::App.new
19
+ end
20
+
21
+ it "should load a config file given" do
22
+ File.open("/tmp/vanilla_config.yml", "w") { |f| f.write({:soup => soup_path, :hello => true}.to_yaml) }
23
+ app = Vanilla::App.new("/tmp/vanilla_config.yml")
24
+ app.config[:hello].should be_true
25
+ end
26
+
27
+ it "should allow saving of configuration to the same file it was loaded from" do
28
+ config_file = "/tmp/vanilla_config.yml"
29
+ File.open(config_file, "w") { |f| f.write({:soup => soup_path, :hello => true}.to_yaml) }
30
+ app = Vanilla::App.new(config_file)
31
+ app.config[:saved] = true
32
+ app.config.save!
33
+
34
+ config = YAML.load(File.open(config_file))
35
+ config[:saved].should be_true
36
+ end
37
+ end
38
+ end
@@ -0,0 +1,84 @@
1
+ require File.join(File.dirname(__FILE__), "spec_helper")
2
+
3
+ describe Vanilla::App do
4
+ before(:each) do
5
+ @app.soup << LinkTo.snip_attributes
6
+ set_main_template "<tag>{current_snip}</tag>"
7
+ create_snip :name => "test", :content => "blah {other_snip}", :part => 'part content'
8
+ create_snip :name => "other_snip", :content => "blah!"
9
+ end
10
+
11
+ describe "when presenting as HTML" do
12
+ it "should render the snip's content in the system template if no format or part is given" do
13
+ response_body_for("/test").should == "<tag>blah blah!</tag>"
14
+ end
15
+
16
+ it "should render the snip's content in the system template if the HTML format is given" do
17
+ response_body_for("/test.html").should == "<tag>blah blah!</tag>"
18
+ end
19
+
20
+ it "should render the requested part within the main template when a part is given" do
21
+ response_body_for("/test/part").should == "<tag>part content</tag>"
22
+ end
23
+
24
+ it "should have a response code of 200" do
25
+ response_code_for("/test").should == 200
26
+ response_code_for("/test.html").should == 200
27
+ response_code_for("/test/part").should == 200
28
+ response_code_for("/test/part.html").should == 200
29
+ end
30
+ end
31
+
32
+ describe "when presenting content as text" do
33
+ it "should render the snip's content outside of the main template with its default renderer" do
34
+ response_body_for("/test.text").should == "blah blah!"
35
+ end
36
+
37
+ it "should render the snip part outside the main template when a format is given" do
38
+ response_body_for("/test/part.text").should == "part content"
39
+ end
40
+
41
+ it "should have a response code of 200" do
42
+ response_code_for("/test.text").should == 200
43
+ response_code_for("/test/part.text").should == 200
44
+ end
45
+ end
46
+
47
+
48
+ describe "when presenting raw content" do
49
+ it "should render the snips contents exactly as they are" do
50
+ response_body_for("/test.raw").should == "blah {other_snip}"
51
+ end
52
+
53
+ it "should render the snip content exactly even if a render_as attribute exists" do
54
+ response_body_for("/current_snip.raw").should == "CurrentSnip"
55
+ end
56
+
57
+ it "should render a snips part if requested" do
58
+ response_body_for("/test/part.raw").should == "part content"
59
+ end
60
+
61
+ it "should have a response code of 200" do
62
+ response_code_for("/test.raw").should == 200
63
+ response_code_for("/test/part.raw").should == 200
64
+ end
65
+ end
66
+
67
+
68
+ describe "when a missing snip is requested" do
69
+ it "should render missing snip content in the main template" do
70
+ response_body_for("/missing_snip").should == "<tag>Couldn't find snip #{LinkTo.new(@app).handle("missing_snip")}</tag>"
71
+ end
72
+
73
+ it "should have a 404 response code" do
74
+ response_code_for("/missing_snip").should == 404
75
+ end
76
+ end
77
+
78
+
79
+ describe "when requesting an unknown format" do
80
+ it "should return a 500 status code" do
81
+ response_code_for("/test.monkey").should == 500
82
+ end
83
+ end
84
+ end