vanilla 1.17.13 → 2.0.0.beta
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.
- checksums.yaml +4 -4
- data/README +8 -6
- data/Rakefile +8 -8
- data/bin/vanilla +2 -3
- data/lib/vanilla.rb +1 -1
- data/lib/vanilla/app.rb +1 -1
- data/lib/vanilla/atom_feed.rb +2 -2
- data/lib/vanilla/config.rb +8 -8
- data/lib/vanilla/dynasnip.rb +2 -2
- data/lib/vanilla/renderers/base.rb +2 -1
- data/lib/vanilla/renderers/erb.rb +2 -3
- data/lib/vanilla/snip_reference_parser.rb +9 -9
- data/pristine_app/Gemfile +1 -1
- data/pristine_app/README +6 -6
- data/pristine_app/config.ru +3 -1
- data/pristine_app/soups/extras/comments.rb +6 -6
- data/pristine_app/soups/extras/kind.rb +4 -4
- data/pristine_app/soups/extras/url_to.rb +1 -1
- data/test/core/atom_feed_test.rb +39 -39
- data/test/core/configuration_test.rb +2 -2
- data/test/core/snip_inclusion_test.rb +9 -9
- data/test/core/snip_reference_parser_test.rb +66 -66
- data/test/core/test_helper.rb +2 -2
- data/test/core/vanilla_app_test.rb +7 -7
- data/test/core/vanilla_presenting_test.rb +13 -13
- data/test/pristine_app/current_snip_test.rb +8 -8
- data/test/pristine_app/feed_test.rb +8 -8
- data/test/pristine_app/index_test.rb +8 -8
- data/test/pristine_app/link_to_current_snip_test.rb +3 -3
- data/test/pristine_app/link_to_test.rb +5 -5
- data/test/pristine_app/page_title_test.rb +4 -4
- data/test/pristine_app/raise_errors_test.rb +6 -6
- data/test/pristine_app/raw_test.rb +10 -10
- metadata +9 -9
@@ -91,7 +91,7 @@ context "Configuring a Vanilla app" do
|
|
91
91
|
TestConfigurationApp.configure do |c|
|
92
92
|
c.renderers[:my_renderer] = "MyRenderer"
|
93
93
|
end
|
94
|
-
snip = create_snip(:
|
94
|
+
snip = create_snip(name: "blah", render_as: "my_renderer")
|
95
95
|
assert_equal MyRenderer, TestConfigurationApp.new.renderer_for(snip)
|
96
96
|
end
|
97
97
|
|
@@ -99,7 +99,7 @@ context "Configuring a Vanilla app" do
|
|
99
99
|
TestConfigurationApp.configure do |c|
|
100
100
|
c.renderers["markdown"] = "Vanilla::Renderers::Bold"
|
101
101
|
end
|
102
|
-
snip = create_snip(:
|
102
|
+
snip = create_snip(name: "blah", extension: "markdown")
|
103
103
|
assert_equal Vanilla::Renderers::Bold, TestConfigurationApp.new.renderer_for(snip)
|
104
104
|
end
|
105
105
|
end
|
@@ -2,7 +2,7 @@ require "test_helper"
|
|
2
2
|
|
3
3
|
context "When including snips in other snips" do
|
4
4
|
setup do
|
5
|
-
create_snip :
|
5
|
+
create_snip name: "test", content: "snip content"
|
6
6
|
end
|
7
7
|
|
8
8
|
should "match simple snips" do
|
@@ -18,34 +18,34 @@ context "When including snips in other snips" do
|
|
18
18
|
end
|
19
19
|
|
20
20
|
should "match snips with hyphens" do
|
21
|
-
create_snip :
|
21
|
+
create_snip name: "test-snip", content: "snip content"
|
22
22
|
assert_equal "rendering snip content", render("rendering {test-snip}")
|
23
23
|
end
|
24
24
|
|
25
25
|
should "match snips with underscores" do
|
26
|
-
create_snip :
|
26
|
+
create_snip name: "test_snip", content: "snip content"
|
27
27
|
assert_equal "rendering snip content", render("rendering {test_snip}")
|
28
28
|
end
|
29
29
|
|
30
30
|
should "match snips with numbers" do
|
31
|
-
create_snip :
|
31
|
+
create_snip name: "test1", content: "snip content"
|
32
32
|
assert_equal "rendering snip content", render("rendering {test1}")
|
33
33
|
end
|
34
34
|
|
35
35
|
should "match snips with dots in their arguments" do
|
36
|
-
create_snip :
|
36
|
+
create_snip name: "test", content: "dot arguments"
|
37
37
|
assert_equal %{allow dot arguments}, render(%|allow {test "allow but ignore this argument..."}|)
|
38
38
|
end
|
39
39
|
|
40
40
|
should "match snips with ruby 1.9 style hashes" do
|
41
|
-
create_snip :
|
41
|
+
create_snip name: "test", content: %{
|
42
42
|
class Blah
|
43
43
|
def handle(args)
|
44
44
|
args.inspect
|
45
45
|
end
|
46
46
|
self
|
47
47
|
end
|
48
|
-
}, :
|
48
|
+
}, render_as: "Ruby"
|
49
49
|
assert_equal %{rendering {:x=>"1"}}, render("rendering {test x:1}")
|
50
50
|
end
|
51
51
|
|
@@ -59,13 +59,13 @@ context "When including snips in other snips" do
|
|
59
59
|
end
|
60
60
|
|
61
61
|
should "render malformed snip inclusions for easier debugging" do
|
62
|
-
create_snip :
|
62
|
+
create_snip name: "some_dyna"
|
63
63
|
assert_equal %|this is a <span class="malformed_snip_inclusion">(malformed snip inclusion: {some_dyna blah! blah})</span>|,
|
64
64
|
render("this is a {some_dyna blah! blah}")
|
65
65
|
end
|
66
66
|
|
67
67
|
def render(content)
|
68
|
-
snip = create_snip :
|
68
|
+
snip = create_snip name: "test-content", content: content
|
69
69
|
Vanilla::Renderers::Base.new(app).render(snip)
|
70
70
|
end
|
71
71
|
end
|
@@ -9,88 +9,88 @@ context "The SnipReference parser" do
|
|
9
9
|
end
|
10
10
|
|
11
11
|
examples = {
|
12
|
-
:
|
13
|
-
%|{snip}| => {:
|
14
|
-
%|{Snip}| => {:
|
15
|
-
%|{123snip}| => {:
|
16
|
-
%|{Snip123}| => {:
|
17
|
-
%|{snip-with-dashes}| => {:
|
18
|
-
%|{snip_with_underscores}| => {:
|
12
|
+
snip_names: {
|
13
|
+
%|{snip}| => {snip: 'snip', attribute: nil, arguments: []},
|
14
|
+
%|{Snip}| => {snip: 'Snip', attribute: nil, arguments: []},
|
15
|
+
%|{123snip}| => {snip: '123snip', attribute: nil, arguments: []},
|
16
|
+
%|{Snip123}| => {snip: 'Snip123', attribute: nil, arguments: []},
|
17
|
+
%|{snip-with-dashes}| => {snip: 'snip-with-dashes', attribute: nil, arguments: []},
|
18
|
+
%|{snip_with_underscores}| => {snip: 'snip_with_underscores', attribute: nil, arguments: []},
|
19
19
|
},
|
20
20
|
|
21
|
-
:
|
22
|
-
%|{snip.snip_attribute}| => {:
|
23
|
-
%|{snip.snip_attribute arg}| => {:
|
24
|
-
%|{snip."spaced attribute"}| => {:
|
25
|
-
%|{snip.'spaced attribute'}| => {:
|
21
|
+
snip_attributes: {
|
22
|
+
%|{snip.snip_attribute}| => {snip: 'snip', attribute: 'snip_attribute', arguments: []},
|
23
|
+
%|{snip.snip_attribute arg}| => {snip: 'snip', attribute: 'snip_attribute', arguments: ['arg']},
|
24
|
+
%|{snip."spaced attribute"}| => {snip: 'snip', attribute: 'spaced attribute', arguments: []},
|
25
|
+
%|{snip.'spaced attribute'}| => {snip: 'snip', attribute: 'spaced attribute', arguments: []}
|
26
26
|
},
|
27
27
|
|
28
|
-
:
|
29
|
-
%|{snip argument}| => {:
|
30
|
-
%|{snip1 argument}| => {:
|
31
|
-
%|{snip arg-dashes}| => {:
|
32
|
-
%|{snip arg_underscores}| => {:
|
33
|
-
%|{snip arg1,arg2}| => {:
|
34
|
-
%|{snip arg1, arg2}| => {:
|
35
|
-
%|{snip arg1, arg2}| => {:
|
36
|
-
%|{snip 1ARG, arg_2, arg-3}| => {:
|
28
|
+
simple_arguments: {
|
29
|
+
%|{snip argument}| => {snip: 'snip', attribute: nil, arguments: ["argument"]},
|
30
|
+
%|{snip1 argument}| => {snip: 'snip1', attribute: nil, arguments: ["argument"]},
|
31
|
+
%|{snip arg-dashes}| => {snip: 'snip', attribute: nil, arguments: ["arg-dashes"]},
|
32
|
+
%|{snip arg_underscores}| => {snip: 'snip', attribute: nil, arguments: ["arg_underscores"]},
|
33
|
+
%|{snip arg1,arg2}| => {snip: 'snip', attribute: nil, arguments: ['arg1', 'arg2']},
|
34
|
+
%|{snip arg1, arg2}| => {snip: 'snip', attribute: nil, arguments: ['arg1', 'arg2']},
|
35
|
+
%|{snip arg1, arg2}| => {snip: 'snip', attribute: nil, arguments: ['arg1', 'arg2']},
|
36
|
+
%|{snip 1ARG, arg_2, arg-3}| => {snip: 'snip', attribute: nil, arguments: ['1ARG', 'arg_2', 'arg-3']}
|
37
37
|
},
|
38
38
|
|
39
|
-
:
|
40
|
-
%|{"snip with spaces"}| => {:
|
41
|
-
%|{'snip with spaces'}| => {:
|
42
|
-
%|{"snip with spaces" argument}| => {:
|
43
|
-
%|{'snip with spaces' argument}| => {:
|
44
|
-
%|{"snip with spaces" a, b}| => {:
|
45
|
-
%|{'snip with spaces' a, b}| => {:
|
46
|
-
%|{"snip with spaces".attribute}| => {:
|
47
|
-
%|{'snip with spaces'.attribute}| => {:
|
39
|
+
snip_name_spaces: {
|
40
|
+
%|{"snip with spaces"}| => {snip: 'snip with spaces', attribute: nil, arguments: []},
|
41
|
+
%|{'snip with spaces'}| => {snip: 'snip with spaces', attribute: nil, arguments: []},
|
42
|
+
%|{"snip with spaces" argument}| => {snip: 'snip with spaces', attribute: nil, arguments: ['argument']},
|
43
|
+
%|{'snip with spaces' argument}| => {snip: 'snip with spaces', attribute: nil, arguments: ['argument']},
|
44
|
+
%|{"snip with spaces" a, b}| => {snip: 'snip with spaces', attribute: nil, arguments: ['a', 'b']},
|
45
|
+
%|{'snip with spaces' a, b}| => {snip: 'snip with spaces', attribute: nil, arguments: ['a', 'b']},
|
46
|
+
%|{"snip with spaces".attribute}| => {snip: 'snip with spaces', attribute: 'attribute', arguments: []},
|
47
|
+
%|{'snip with spaces'.attribute}| => {snip: 'snip with spaces', attribute: 'attribute', arguments: []}
|
48
48
|
},
|
49
49
|
|
50
|
-
:
|
51
|
-
%|{snip arg spaces}| => {:
|
52
|
-
%|{snip arg spaces, and this}| => {:
|
53
|
-
%|{snip "arg spaces"}| => {:
|
54
|
-
%|{snip 'arg spaces'}| => {:
|
55
|
-
%|{snip "arg spaces", arg2}| => {:
|
50
|
+
arguments_with_spaces: {
|
51
|
+
%|{snip arg spaces}| => {snip: 'snip', attribute: nil, arguments: ['arg spaces']},
|
52
|
+
%|{snip arg spaces, and this}| => {snip: 'snip', attribute: nil, arguments: ['arg spaces', 'and this']},
|
53
|
+
%|{snip "arg spaces"}| => {snip: 'snip', attribute: nil, arguments: ['arg spaces']},
|
54
|
+
%|{snip 'arg spaces'}| => {snip: 'snip', attribute: nil, arguments: ['arg spaces']},
|
55
|
+
%|{snip "arg spaces", arg2}| => {snip: 'snip', attribute: nil, arguments: ['arg spaces', 'arg2']}
|
56
56
|
},
|
57
57
|
|
58
|
-
:
|
59
|
-
%|{snip arg1,nil,arg3}| => {:
|
60
|
-
%|{snip arg1, nil ,arg3}| => {:
|
58
|
+
nil_arguments: {
|
59
|
+
%|{snip arg1,nil,arg3}| => {snip: 'snip', attribute: nil, arguments: ['arg1', nil, 'arg3']},
|
60
|
+
%|{snip arg1, nil ,arg3}| => {snip: 'snip', attribute: nil, arguments: ['arg1', nil, 'arg3']}
|
61
61
|
},
|
62
62
|
|
63
|
-
:
|
64
|
-
%|{s key1=>value1, key2 => value2}| => {:
|
65
|
-
%|{s key1 => value1, key2 => value2}| => {:
|
66
|
-
%|{s :
|
67
|
-
%|{s key1 => "value with spaces"}| => {:
|
68
|
-
%|{s.attr key1=>value1}| => {:
|
69
|
-
%|{s "key with spaces" => value}| => {:
|
63
|
+
classic_ruby_hash_arguments: {
|
64
|
+
%|{s key1=>value1, key2 => value2}| => {snip: 's', arguments: {key1: 'value1', key2: 'value2'}},
|
65
|
+
%|{s key1 => value1, key2 => value2}| => {snip: 's', arguments: {key1: 'value1', key2: 'value2'}},
|
66
|
+
%|{s key1: value1, key2: value2}| => {snip: 's', arguments: {key1: 'value1', key2: 'value2'}},
|
67
|
+
%|{s key1 => "value with spaces"}| => {snip: 's', arguments: {key1: "value with spaces"}},
|
68
|
+
%|{s.attr key1=>value1}| => {snip: 's', attribute: 'attr', arguments: {key1: 'value1'}},
|
69
|
+
%|{s "key with spaces" => value}| => {snip: 's', arguments: {:"key with spaces" => "value"}}
|
70
70
|
},
|
71
71
|
|
72
|
-
:
|
73
|
-
%|{s key1:value1,key2:value2}| => {:
|
74
|
-
%|{s key1:value1, key2:value2}| => {:
|
75
|
-
%|{s key1: value1, key2: value2}| => {:
|
76
|
-
%|{s key1:"value with spaces"}| => {:
|
72
|
+
named_arguments: {
|
73
|
+
%|{s key1:value1,key2:value2}| => {snip: 's', arguments: {key1: 'value1', key2: 'value2'}},
|
74
|
+
%|{s key1:value1, key2:value2}| => {snip: 's', arguments: {key1: 'value1', key2: 'value2'}},
|
75
|
+
%|{s key1: value1, key2: value2}| => {snip: 's', arguments: {key1: 'value1', key2: 'value2'}},
|
76
|
+
%|{s key1:"value with spaces"}| => {snip: 's', arguments: {key1: 'value with spaces'}}
|
77
77
|
},
|
78
78
|
|
79
|
-
:
|
80
|
-
# %|{s "arg \\" double"}| => {:
|
81
|
-
# %|{s 'arg \\' single'}| => {:
|
82
|
-
%|{s "arg ' single"}| => {:
|
83
|
-
%|{s 'arg " double'}| => {:
|
84
|
-
%|{s "arg, comma"}| => {:
|
85
|
-
%|{s 'arg, comma'}| => {:
|
86
|
-
# %|{s "arg { open"}| => {:
|
87
|
-
# %|{s "arg } close"}| => {:
|
88
|
-
%|{s 'arg.with.fullstop'}| => {:
|
79
|
+
quoting_arguments: {
|
80
|
+
# %|{s "arg \\" double"}| => {snip: 's', attribute: nil, arguments: ['arg " double']},
|
81
|
+
# %|{s 'arg \\' single'}| => {snip: 's', attribute: nil, arguments: ["arg ' single"]},
|
82
|
+
%|{s "arg ' single"}| => {snip: 's', attribute: nil, arguments: ["arg ' single"]},
|
83
|
+
%|{s 'arg " double'}| => {snip: 's', attribute: nil, arguments: ['arg " double']},
|
84
|
+
%|{s "arg, comma"}| => {snip: 's', attribute: nil, arguments: ['arg, comma']},
|
85
|
+
%|{s 'arg, comma'}| => {snip: 's', attribute: nil, arguments: ['arg, comma']},
|
86
|
+
# %|{s "arg { open"}| => {snip: 's', attribute: nil, arguments: ['arg { open']},
|
87
|
+
# %|{s "arg } close"}| => {snip: 's', attribute: nil, arguments: ['arg } close']}
|
88
|
+
%|{s 'arg.with.fullstop'}| => {snip: 's', attribute: nil, arguments: ['arg.with.fullstop']},
|
89
89
|
},
|
90
90
|
|
91
|
-
:
|
92
|
-
%|{s “arg”}| => {:
|
93
|
-
%|{s “arg”}| => {:
|
91
|
+
html_quoting_arguments: {
|
92
|
+
%|{s “arg”}| => {snip: 's', attribute: nil, arguments: ['arg']},
|
93
|
+
%|{s “arg”}| => {snip: 's', attribute: nil, arguments: ['arg']}
|
94
94
|
}
|
95
95
|
}
|
96
96
|
|
@@ -122,13 +122,13 @@ context "The SnipReference parser" do
|
|
122
122
|
|
123
123
|
def assert_parsable_by_vanilla(example, expected)
|
124
124
|
create_snip_from_expected expected
|
125
|
-
create_snip :
|
125
|
+
create_snip name: "test", content: "alpha #{example} beta"
|
126
126
|
assert_response_body "alpha ok beta", "/test"
|
127
127
|
end
|
128
128
|
|
129
129
|
def create_snip_from_expected(expected)
|
130
130
|
simple_dyna = %|class SimpleDyna;def handle(*args); 'ok'; end;self;end|
|
131
|
-
attributes = {:
|
131
|
+
attributes = {name: expected[:snip], content: simple_dyna, render_as: "ruby"}
|
132
132
|
if expected[:attribute]
|
133
133
|
attributes[expected[:attribute]] = simple_dyna
|
134
134
|
end
|
data/test/core/test_helper.rb
CHANGED
@@ -12,7 +12,7 @@ module TestHelper
|
|
12
12
|
def create_simple_layout
|
13
13
|
require File.expand_path("../../../pristine_app/soups/system/current_snip", __FILE__)
|
14
14
|
app.soup << CurrentSnip.snip_attributes
|
15
|
-
create_snip :
|
15
|
+
create_snip name: "layout", content: "{current_snip}"
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
@@ -26,4 +26,4 @@ end
|
|
26
26
|
|
27
27
|
Kintama.teardown do
|
28
28
|
vanilla_teardown
|
29
|
-
end
|
29
|
+
end
|
@@ -4,7 +4,7 @@ require "tmpdir"
|
|
4
4
|
describe Vanilla::App do
|
5
5
|
context "when behaving as a Rack application" do
|
6
6
|
should "return a valid rack response" do
|
7
|
-
create_snip(:
|
7
|
+
create_snip(name: "test", content: "content")
|
8
8
|
get "/test.text"
|
9
9
|
assert_equal 200, last_response.status
|
10
10
|
assert_kind_of Hash, last_response.headers
|
@@ -12,7 +12,7 @@ describe Vanilla::App do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
should "return an empty body for HEAD request" do
|
15
|
-
create_snip(:
|
15
|
+
create_snip(name: "test", content: "content")
|
16
16
|
head "/test.text"
|
17
17
|
assert_equal 200, last_response.status
|
18
18
|
assert_kind_of Hash, last_response.headers
|
@@ -22,7 +22,7 @@ describe Vanilla::App do
|
|
22
22
|
|
23
23
|
context "when detecting the snip renderer" do
|
24
24
|
should "return the constant refered to in the render_as property of the snip" do
|
25
|
-
snip = create_snip(:
|
25
|
+
snip = create_snip(name: "blah", render_as: "Raw")
|
26
26
|
assert_equal Vanilla::Renderers::Raw, app.renderer_for(snip)
|
27
27
|
end
|
28
28
|
|
@@ -35,24 +35,24 @@ describe Vanilla::App do
|
|
35
35
|
"haml" => Vanilla::Renderers::Haml
|
36
36
|
}.each do |extension, renderer|
|
37
37
|
should "return the renderer #{renderer} when the snip has extension #{extension}" do
|
38
|
-
snip = create_snip(:
|
38
|
+
snip = create_snip(name: "blah", extension: extension)
|
39
39
|
assert_equal renderer, app.renderer_for(snip)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
44
|
should "return Vanilla::Renderers::Base if no render_as property exists" do
|
45
|
-
snip = create_snip(:
|
45
|
+
snip = create_snip(name: "blah")
|
46
46
|
assert_equal Vanilla::Renderers::Base, app.renderer_for(snip)
|
47
47
|
end
|
48
48
|
|
49
49
|
should "return Vanilla::Renderers::Base if the render_as property is blank" do
|
50
|
-
snip = create_snip(:
|
50
|
+
snip = create_snip(name: "blah", render_as: '')
|
51
51
|
assert_equal Vanilla::Renderers::Base, app.renderer_for(snip)
|
52
52
|
end
|
53
53
|
|
54
54
|
should "raise an error if the specified renderer doesn't exist" do
|
55
|
-
snip = create_snip(:
|
55
|
+
snip = create_snip(name: "blah", render_as: "NonExistentClass")
|
56
56
|
assert_raises(Vanilla::MissingRendererError) { app.renderer_for(snip) }
|
57
57
|
end
|
58
58
|
end
|
@@ -3,8 +3,8 @@ require "test_helper"
|
|
3
3
|
context "When presenting" do
|
4
4
|
setup do
|
5
5
|
set_main_template "<tag>{current_snip}</tag>"
|
6
|
-
create_snip :
|
7
|
-
create_snip :
|
6
|
+
create_snip name: "test", content: "blah {other_snip}", part: 'part content'
|
7
|
+
create_snip name: "other_snip", content: "blah!"
|
8
8
|
end
|
9
9
|
|
10
10
|
context "HTML" do
|
@@ -68,13 +68,13 @@ context "When presenting" do
|
|
68
68
|
|
69
69
|
context "the root URL" do
|
70
70
|
should "render the start snip by default" do
|
71
|
-
create_snip :
|
71
|
+
create_snip name: "start", content: "default"
|
72
72
|
assert_response_body "<tag>default</tag>", "/"
|
73
73
|
end
|
74
74
|
|
75
75
|
should "render any custom-set root snip if provided" do
|
76
|
-
create_snip :
|
77
|
-
create_snip :
|
76
|
+
create_snip name: "start", content: "default"
|
77
|
+
create_snip name: "custom", content: "custom"
|
78
78
|
app.config.root_snip = "custom"
|
79
79
|
assert_response_body "<tag>custom</tag>", "/"
|
80
80
|
end
|
@@ -82,8 +82,8 @@ context "When presenting" do
|
|
82
82
|
|
83
83
|
context "a snip with a custom layout" do
|
84
84
|
should "render the snips contents within that layout" do
|
85
|
-
create_snip :
|
86
|
-
create_snip :
|
85
|
+
create_snip name: "custom-layout", content: "<custom>{current_snip}</custom>"
|
86
|
+
create_snip name: "test", content: "this is a test", layout: "custom-layout"
|
87
87
|
assert_response_body "<custom>this is a test</custom>", "/test"
|
88
88
|
end
|
89
89
|
end
|
@@ -97,17 +97,17 @@ context "When presenting" do
|
|
97
97
|
context "a snip using a renderer that specifies a template" do
|
98
98
|
setup do
|
99
99
|
app.register_renderer CustomRenderer, "custom"
|
100
|
-
create_snip :
|
100
|
+
create_snip name: "custom-layout", content: "<custom>{current_snip}</custom>"
|
101
101
|
end
|
102
102
|
|
103
103
|
should "use the renderer's specified layout" do
|
104
|
-
create_snip :
|
104
|
+
create_snip name: "test", content: "this is a test", render_as: "custom"
|
105
105
|
assert_response_body "<custom>this is a test</custom>", "/test"
|
106
106
|
end
|
107
107
|
|
108
108
|
should "use the snips layout when given" do
|
109
|
-
create_snip :
|
110
|
-
create_snip :
|
109
|
+
create_snip name: "snip-custom-layout", content: "<snipcustom>{current_snip}</snipcustom>"
|
110
|
+
create_snip name: "test", content: "this is a test", render_as: "custom", layout: "snip-custom-layout"
|
111
111
|
assert_response_body "<snipcustom>this is a test</snipcustom>", "/test"
|
112
112
|
end
|
113
113
|
end
|
@@ -115,8 +115,8 @@ context "When presenting" do
|
|
115
115
|
context "and a custom default renderer has been provided" do
|
116
116
|
should "use that renderer" do
|
117
117
|
app.config.default_renderer = ::Vanilla::Renderers::Bold
|
118
|
-
create_snip :
|
119
|
-
create_snip :
|
118
|
+
create_snip name: "layout", content: "{test}", render_as: "base"
|
119
|
+
create_snip name: "test", content: "test"
|
120
120
|
assert_response_body "<b>test</b>", "/test"
|
121
121
|
end
|
122
122
|
end
|
@@ -3,28 +3,28 @@ require "test_helper"
|
|
3
3
|
context "The current_snip dynasnip" do
|
4
4
|
should "render the snip from the current request" do
|
5
5
|
set_main_template "<layout>{current_snip}</layout>"
|
6
|
-
create_snip :
|
6
|
+
create_snip name: "test", content: "test"
|
7
7
|
|
8
8
|
visit "/test"
|
9
9
|
|
10
|
-
assert page.has_css?("layout", :
|
10
|
+
assert page.has_css?("layout", text: "test")
|
11
11
|
end
|
12
12
|
|
13
13
|
should "render a given attribute of the current snip" do
|
14
|
-
create_snip :
|
14
|
+
create_snip name: "test", content: "this is my {current_snip part}", part: "underbelly"
|
15
15
|
visit "/test"
|
16
16
|
assert page.has_content?("this is my underbelly")
|
17
17
|
end
|
18
18
|
|
19
19
|
should "render based on the requested snip, not the including snip" do
|
20
|
-
create_snip :
|
21
|
-
create_snip :
|
20
|
+
create_snip name: "test", content: "this is my {current_snip part}", part: "underbelly"
|
21
|
+
create_snip name: "blah", content: "{test}", part: "flange"
|
22
22
|
visit "/blah"
|
23
23
|
assert page.has_content?("this is my flange")
|
24
24
|
end
|
25
25
|
|
26
26
|
should "be able to handle snips with spaces in their names" do
|
27
|
-
create_snip :
|
27
|
+
create_snip name: "test snip", content: "this is a test"
|
28
28
|
visit "/test+snip"
|
29
29
|
assert page.has_content?("this is a test")
|
30
30
|
end
|
@@ -58,7 +58,7 @@ context "The current_snip dynasnip" do
|
|
58
58
|
context "when the requested part of a snip is missing" do
|
59
59
|
setup do
|
60
60
|
set_main_template "<layout>{current_snip}</layout>"
|
61
|
-
create_snip :
|
61
|
+
create_snip name: "test", content: "test"
|
62
62
|
|
63
63
|
visit "/test/monkey"
|
64
64
|
end
|
@@ -71,4 +71,4 @@ context "The current_snip dynasnip" do
|
|
71
71
|
assert_equal 404, page.status_code
|
72
72
|
end
|
73
73
|
end
|
74
|
-
end
|
74
|
+
end
|
@@ -4,9 +4,9 @@ require "base/feed"
|
|
4
4
|
|
5
5
|
context "The feed dynasnip" do
|
6
6
|
should "include snips of the specified kind" do
|
7
|
-
stub_app_soup({:
|
8
|
-
{:
|
9
|
-
{:
|
7
|
+
stub_app_soup({name: "Hello", content: "This is the content", kind: "blog"},
|
8
|
+
{name: "Goodbye", content: "More content", kind: "blog"},
|
9
|
+
{name: "system", content: "not to be shown"},
|
10
10
|
Feed.snip_attributes)
|
11
11
|
|
12
12
|
visit "/feed.xml"
|
@@ -16,8 +16,8 @@ context "The feed dynasnip" do
|
|
16
16
|
end
|
17
17
|
|
18
18
|
should "included rendered snip contents" do
|
19
|
-
stub_app_soup({:
|
20
|
-
:
|
19
|
+
stub_app_soup({name: "Hello", content: "This is *the* content",
|
20
|
+
render_as: "markdown", kind: "blog"},
|
21
21
|
Feed.snip_attributes)
|
22
22
|
|
23
23
|
visit "/feed.xml"
|
@@ -27,8 +27,8 @@ context "The feed dynasnip" do
|
|
27
27
|
end
|
28
28
|
|
29
29
|
should "ensure relative links are made absolute" do
|
30
|
-
stub_app_soup({:
|
31
|
-
:
|
30
|
+
stub_app_soup({name: "Hello", content: "a [relative](/link)",
|
31
|
+
render_as: "markdown", kind: "blog"},
|
32
32
|
Feed.snip_attributes)
|
33
33
|
|
34
34
|
visit "/feed.xml"
|
@@ -36,4 +36,4 @@ context "The feed dynasnip" do
|
|
36
36
|
feed = Atom::Feed.load_feed(page.source)
|
37
37
|
assert_equal %{<p>a <a href="http://yourdomain.example.com/link">relative</a></p>}, feed.entries.first.content
|
38
38
|
end
|
39
|
-
end
|
39
|
+
end
|