inversion 0.12.3 → 0.14.0
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
- checksums.yaml.gz.sig +2 -1
- data.tar.gz.sig +0 -0
- data/ChangeLog +305 -9
- data/Examples.rdoc +134 -0
- data/GettingStarted.rdoc +44 -0
- data/Guide.rdoc +47 -0
- data/History.rdoc +15 -0
- data/Manifest.txt +7 -2
- data/README.rdoc +9 -10
- data/Rakefile +23 -10
- data/Tags.rdoc +561 -0
- data/lib/inversion.rb +2 -2
- data/lib/inversion/renderstate.rb +46 -11
- data/lib/inversion/template.rb +85 -7
- data/lib/inversion/template/attrtag.rb +1 -1
- data/lib/inversion/template/begintag.rb +8 -8
- data/lib/inversion/template/fragmenttag.rb +60 -0
- data/lib/inversion/template/rescuetag.rb +1 -1
- data/spec/{lib/helpers.rb → helpers.rb} +7 -30
- data/spec/inversion/mixins_spec.rb +55 -65
- data/spec/inversion/monkeypatches_spec.rb +2 -12
- data/spec/inversion/parser_spec.rb +34 -44
- data/spec/inversion/renderstate_spec.rb +123 -69
- data/spec/inversion/sinatra_spec.rb +6 -19
- data/spec/inversion/template/attrtag_spec.rb +56 -76
- data/spec/inversion/template/begintag_spec.rb +24 -41
- data/spec/inversion/template/calltag_spec.rb +1 -18
- data/spec/inversion/template/codetag_spec.rb +6 -24
- data/spec/inversion/template/commenttag_spec.rb +9 -27
- data/spec/inversion/template/configtag_spec.rb +5 -16
- data/spec/inversion/template/containertag_spec.rb +4 -21
- data/spec/inversion/template/defaulttag_spec.rb +6 -23
- data/spec/inversion/template/elsetag_spec.rb +9 -26
- data/spec/inversion/template/elsiftag_spec.rb +7 -24
- data/spec/inversion/template/endtag_spec.rb +6 -23
- data/spec/inversion/template/escapetag_spec.rb +10 -25
- data/spec/inversion/template/fortag_spec.rb +20 -37
- data/spec/inversion/template/fragmenttag_spec.rb +40 -0
- data/spec/inversion/template/iftag_spec.rb +23 -40
- data/spec/inversion/template/importtag_spec.rb +8 -25
- data/spec/inversion/template/includetag_spec.rb +27 -42
- data/spec/inversion/template/node_spec.rb +6 -15
- data/spec/inversion/template/pptag_spec.rb +10 -23
- data/spec/inversion/template/publishtag_spec.rb +4 -21
- data/spec/inversion/template/rescuetag_spec.rb +12 -29
- data/spec/inversion/template/subscribetag_spec.rb +8 -25
- data/spec/inversion/template/tag_spec.rb +24 -37
- data/spec/inversion/template/textnode_spec.rb +8 -24
- data/spec/inversion/template/timedeltatag_spec.rb +31 -43
- data/spec/inversion/template/unlesstag_spec.rb +7 -24
- data/spec/inversion/template/uriencodetag_spec.rb +6 -23
- data/spec/inversion/template/yieldtag_spec.rb +3 -20
- data/spec/inversion/template_spec.rb +155 -108
- data/spec/inversion/tilt_spec.rb +7 -16
- data/spec/inversion_spec.rb +7 -22
- metadata +63 -40
- metadata.gz.sig +0 -0
- data/spec/lib/constants.rb +0 -9
@@ -1,37 +1,20 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
4
|
+
require_relative '../../helpers'
|
8
5
|
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
require 'inversion/template/importtag'
|
16
7
|
|
17
8
|
describe Inversion::Template::ImportTag do
|
18
9
|
|
19
|
-
before( :all ) do
|
20
|
-
setup_logging( :fatal )
|
21
|
-
end
|
22
|
-
|
23
|
-
after( :all ) do
|
24
|
-
reset_logging()
|
25
|
-
end
|
26
|
-
|
27
10
|
it "can import a single attribute" do
|
28
11
|
tag = Inversion::Template::ImportTag.new( 'txn ' )
|
29
|
-
tag.attributes.
|
12
|
+
expect( tag.attributes ).to eq( [ :txn ] )
|
30
13
|
end
|
31
14
|
|
32
15
|
it "can import multiple attributes" do
|
33
16
|
tag = Inversion::Template::ImportTag.new( 'txn, applet' )
|
34
|
-
tag.attributes.
|
17
|
+
expect( tag.attributes ).to eq( [ :txn, :applet ] )
|
35
18
|
end
|
36
19
|
|
37
20
|
|
@@ -46,7 +29,7 @@ describe Inversion::Template::ImportTag do
|
|
46
29
|
outside.subtemplate = @subtemplate
|
47
30
|
outside.foo = 'Froo'
|
48
31
|
|
49
|
-
outside.render.
|
32
|
+
expect( outside.render ).to eq( 'FrooFroo' )
|
50
33
|
end
|
51
34
|
|
52
35
|
it "doesn't override values set explicitly on the subtemplate" do
|
@@ -56,7 +39,7 @@ describe Inversion::Template::ImportTag do
|
|
56
39
|
|
57
40
|
@subtemplate.foo = 'Frar'
|
58
41
|
|
59
|
-
outside.render.
|
42
|
+
expect( outside.render ).to eq( 'FrooFrar' )
|
60
43
|
end
|
61
44
|
|
62
45
|
end
|
@@ -76,7 +59,7 @@ describe Inversion::Template::ImportTag do
|
|
76
59
|
outside.foo = 'mission'
|
77
60
|
outside.bar = 'accomplished'
|
78
61
|
|
79
|
-
outside.render.
|
62
|
+
expect( outside.render ).to eq( 'Mission: Accomplished' )
|
80
63
|
end
|
81
64
|
|
82
65
|
it "doesn't override values set explicitly on the subtemplate" do
|
@@ -87,7 +70,7 @@ describe Inversion::Template::ImportTag do
|
|
87
70
|
|
88
71
|
@subtemplate.bar = 'abandoned'
|
89
72
|
|
90
|
-
outside.render.
|
73
|
+
expect( outside.render ).to eq( 'Mission: Abandoned' )
|
91
74
|
end
|
92
75
|
|
93
76
|
it "only imports listed attributes" do
|
@@ -97,7 +80,7 @@ describe Inversion::Template::ImportTag do
|
|
97
80
|
outside.bar = 'Just This One'
|
98
81
|
outside.baz = 'And Not This One'
|
99
82
|
|
100
|
-
outside.render.
|
83
|
+
expect( outside.render ).to eq( 'Attributes: Just this one' )
|
101
84
|
end
|
102
85
|
end
|
103
86
|
|
@@ -1,82 +1,67 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
8
|
-
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
4
|
+
require_relative '../../helpers'
|
12
5
|
|
13
6
|
require 'timeout'
|
14
|
-
require 'rspec'
|
15
|
-
require 'spec/lib/helpers'
|
16
7
|
require 'inversion/template'
|
17
8
|
require 'inversion/template/includetag'
|
18
9
|
|
19
10
|
describe Inversion::Template::IncludeTag do
|
20
11
|
|
21
|
-
before( :all ) do
|
22
|
-
setup_logging( :fatal )
|
23
|
-
end
|
24
|
-
|
25
|
-
after( :all ) do
|
26
|
-
reset_logging()
|
27
|
-
end
|
28
|
-
|
29
12
|
|
30
13
|
it "renders the IncludeTag as an empty string" do
|
31
14
|
included_path = Pathname.pwd + 'included.tmpl'
|
32
|
-
FileTest.
|
33
|
-
IO.
|
15
|
+
expect( FileTest ).to receive( :exist? ).with( included_path.to_s ).and_return( true )
|
16
|
+
expect( IO ).to receive( :read ).with( included_path.to_s ).and_return( 'there,' )
|
34
17
|
|
35
18
|
tmpl = Inversion::Template.new( "hi <?include included.tmpl ?> handsome!" )
|
36
|
-
tmpl.render.
|
19
|
+
expect( tmpl.render ).to eq( "hi there, handsome!" )
|
37
20
|
end
|
38
21
|
|
39
22
|
|
40
23
|
it "renders debugging comments with the included template path" do
|
41
24
|
included_path = Pathname.pwd + 'included.tmpl'
|
42
|
-
FileTest.
|
43
|
-
IO.
|
25
|
+
expect( FileTest ).to receive( :exist? ).with( included_path.to_s ).and_return( true )
|
26
|
+
expect( IO ).to receive( :read ).with( included_path.to_s ).and_return( 'there,' )
|
44
27
|
|
45
28
|
tmpl = Inversion::Template.
|
46
29
|
new( "hi <?include included.tmpl ?> handsome!", :debugging_comments => true )
|
47
|
-
tmpl.render.
|
30
|
+
expect( tmpl.render ).to match( /Include "included\.tmpl"/ )
|
48
31
|
end
|
49
32
|
|
50
33
|
|
51
34
|
it "appends the nodes from a separate template onto the including template" do
|
52
35
|
included_path = Pathname.pwd + 'included.tmpl'
|
53
|
-
FileTest.
|
54
|
-
IO.
|
36
|
+
expect( FileTest ).to receive( :exist? ).with( included_path.to_s ).and_return( true )
|
37
|
+
expect( IO ).to receive( :read ).with( included_path.to_s ).and_return( 'there,' )
|
55
38
|
|
56
39
|
tmpl = Inversion::Template.new( "hi <?include included.tmpl ?> handsome!" )
|
57
|
-
tmpl.node_tree.
|
58
|
-
tmpl.node_tree[0].
|
59
|
-
tmpl.node_tree[1].
|
60
|
-
tmpl.node_tree[2].
|
61
|
-
tmpl.node_tree[3].
|
40
|
+
expect( tmpl.node_tree.size ).to eq( 4 )
|
41
|
+
expect( tmpl.node_tree[0] ).to be_a( Inversion::Template::TextNode )
|
42
|
+
expect( tmpl.node_tree[1] ).to be_a( Inversion::Template::IncludeTag )
|
43
|
+
expect( tmpl.node_tree[2] ).to be_a( Inversion::Template::TextNode )
|
44
|
+
expect( tmpl.node_tree[3] ).to be_a( Inversion::Template::TextNode )
|
62
45
|
end
|
63
46
|
|
64
47
|
|
65
48
|
it "allows the same template to be included multiple times" do
|
66
49
|
included_path = Pathname.pwd + 'included.tmpl'
|
67
|
-
FileTest.
|
68
|
-
|
50
|
+
expect( FileTest ).to receive( :exist? ).
|
51
|
+
with( included_path.to_s ).twice.and_return( true )
|
52
|
+
expect( IO ).to receive( :read ).
|
53
|
+
with( included_path.to_s ).twice.and_return( ' hi' )
|
69
54
|
|
70
55
|
tmpl = Inversion::Template.
|
71
56
|
new( "hi<?include included.tmpl ?><?include included.tmpl ?> handsome!" )
|
72
|
-
tmpl.render.
|
57
|
+
expect( tmpl.render ).to eq( "hi hi hi handsome!" )
|
73
58
|
end
|
74
59
|
|
75
60
|
|
76
61
|
it "raises exception on include loops" do
|
77
62
|
included_path = Pathname.pwd + 'included.tmpl'
|
78
|
-
FileTest.
|
79
|
-
IO.
|
63
|
+
expect( FileTest ).to receive( :exist? ).with( included_path.to_s ).and_return( true )
|
64
|
+
expect( IO ).to receive( :read ).with( included_path.to_s ).and_return( "<?include included.tmpl ?>" )
|
80
65
|
|
81
66
|
expect {
|
82
67
|
Inversion::Template.new( "hi <?include included.tmpl ?> handsome!" )
|
@@ -89,14 +74,14 @@ describe Inversion::Template::IncludeTag do
|
|
89
74
|
middle_path = Pathname.pwd + 'middle.tmpl'
|
90
75
|
bottom_path = Pathname.pwd + 'bottom.tmpl'
|
91
76
|
|
92
|
-
FileTest.
|
93
|
-
IO.
|
77
|
+
expect( FileTest ).to receive( :exist? ).with( top_path.to_s ).and_return( true )
|
78
|
+
expect( IO ).to receive( :read ).with( top_path.to_s ).and_return( "<?include middle.tmpl ?>" )
|
94
79
|
|
95
|
-
FileTest.
|
96
|
-
IO.
|
80
|
+
expect( FileTest ).to receive( :exist? ).with( middle_path.to_s ).and_return( true )
|
81
|
+
expect( IO ).to receive( :read ).with( middle_path.to_s ).and_return( "<?include bottom.tmpl ?>" )
|
97
82
|
|
98
|
-
FileTest.
|
99
|
-
IO.
|
83
|
+
expect( FileTest ).to receive( :exist? ).with( bottom_path.to_s ).and_return( true )
|
84
|
+
expect( IO ).to receive( :read ).with( bottom_path.to_s ).and_return( "<?include top.tmpl ?>" )
|
100
85
|
|
101
86
|
expect {
|
102
87
|
Inversion::Template.new( "hi <?include top.tmpl ?> handsome!" )
|
@@ -1,17 +1,8 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
4
|
+
require_relative '../../helpers'
|
8
5
|
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
require 'inversion/template/node'
|
16
7
|
|
17
8
|
describe Inversion::Template::Node do
|
@@ -21,27 +12,27 @@ describe Inversion::Template::Node do
|
|
21
12
|
it "is an abstract class" do
|
22
13
|
expect {
|
23
14
|
Inversion::Template::Node.new( '' )
|
24
|
-
}.to
|
15
|
+
}.to raise_error( NoMethodError, /private method `new'/i )
|
25
16
|
end
|
26
17
|
|
27
18
|
it "defaults to using inspect to render itself as a comment" do
|
28
19
|
node = concrete_subclass.new( '' )
|
29
|
-
node.as_comment_body.
|
20
|
+
expect( node.as_comment_body ).to eq( node.inspect )
|
30
21
|
end
|
31
22
|
|
32
23
|
it "isn't a container" do
|
33
24
|
node = concrete_subclass.new( '' )
|
34
|
-
node.
|
25
|
+
expect( node ).to_not be_a_container()
|
35
26
|
end
|
36
27
|
|
37
28
|
it "knows where it was parsed from if constructed with a position" do
|
38
29
|
node = concrete_subclass.new( '', 4, 12 )
|
39
|
-
node.location.
|
30
|
+
expect( node.location ).to match( /line 4, column 12/ )
|
40
31
|
end
|
41
32
|
|
42
33
|
it "knows that it was created from an unknown location if created without a position" do
|
43
34
|
node = concrete_subclass.new( '' )
|
44
|
-
node.location.
|
35
|
+
expect( node.location ).to eq( 'line ??, column ??' )
|
45
36
|
end
|
46
37
|
|
47
38
|
it "doesn't raise an exception when the before_appending event callback is called" do
|
@@ -1,31 +1,14 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
4
|
+
require_relative '../../helpers'
|
8
5
|
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
require 'inversion/template/pptag'
|
16
7
|
|
17
8
|
describe Inversion::Template::PpTag do
|
18
9
|
|
19
|
-
before( :all ) do
|
20
|
-
setup_logging( :fatal )
|
21
|
-
end
|
22
|
-
|
23
|
-
after( :all ) do
|
24
|
-
reset_logging()
|
25
|
-
end
|
26
|
-
|
27
10
|
before( :each ) do
|
28
|
-
@attribute_object =
|
11
|
+
@attribute_object = double( "template attribute" )
|
29
12
|
end
|
30
13
|
|
31
14
|
|
@@ -33,19 +16,23 @@ describe Inversion::Template::PpTag do
|
|
33
16
|
template = Inversion::Template.
|
34
17
|
new( 'It looks like: <tt><?pp foo.bar ?></tt>.', :escape_format => :none )
|
35
18
|
template.foo = @attribute_object
|
36
|
-
@attribute_object.
|
19
|
+
expect( @attribute_object ).to receive( :bar ).with( no_args ).
|
37
20
|
and_return({ :a_complex => [:datastructure, :or, :something] })
|
38
21
|
|
39
|
-
|
22
|
+
expect(
|
23
|
+
template.render
|
24
|
+
).to eq( "It looks like: <tt>{:a_complex=>[:datastructure, :or, :something]}</tt>." )
|
40
25
|
end
|
41
26
|
|
42
27
|
it "escapes as HTML if the format is set to :html" do
|
43
28
|
template = Inversion::Template.
|
44
29
|
new( 'It looks like: <tt><?pp foo.bar ?></tt>.', :escape_format => :html )
|
45
30
|
template.foo = @attribute_object
|
46
|
-
@attribute_object.
|
31
|
+
expect( @attribute_object ).to receive( :bar ).with( no_args() ).
|
47
32
|
and_return({ :a_complex => [:datastructure, :or, :something] })
|
48
33
|
|
49
|
-
|
34
|
+
expect(
|
35
|
+
template.render
|
36
|
+
).to eq( "It looks like: <tt>{:a_complex=>[:datastructure, :or, :something]}</tt>." )
|
50
37
|
end
|
51
38
|
end
|
@@ -1,17 +1,8 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
4
|
+
require_relative '../../helpers'
|
8
5
|
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
require 'inversion/template/publishtag'
|
16
7
|
|
17
8
|
describe Inversion::Template::PublishTag do
|
@@ -29,24 +20,16 @@ describe Inversion::Template::PublishTag do
|
|
29
20
|
end # class TestSubscriber
|
30
21
|
|
31
22
|
|
32
|
-
before( :all ) do
|
33
|
-
setup_logging( :fatal )
|
34
|
-
end
|
35
|
-
|
36
|
-
after( :all ) do
|
37
|
-
reset_logging()
|
38
|
-
end
|
39
|
-
|
40
23
|
|
41
24
|
it "raises a parse error if the body isn't a simple attribute" do
|
42
25
|
expect {
|
43
26
|
Inversion::Template::PublishTag.new( 'a.non-identifier' )
|
44
|
-
}.to
|
27
|
+
}.to raise_error( Inversion::ParseError, /malformed key/i )
|
45
28
|
end
|
46
29
|
|
47
30
|
|
48
31
|
it "doesn't render its contents in the template it's declared in" do
|
49
|
-
Inversion::Template.new( "<?publish foo ?>Some stuff<?end ?>" ).render.
|
32
|
+
expect( Inversion::Template.new( "<?publish foo ?>Some stuff<?end ?>" ).render ).to eq( '' )
|
50
33
|
end
|
51
34
|
|
52
35
|
|
@@ -61,7 +44,7 @@ describe Inversion::Template::PublishTag do
|
|
61
44
|
|
62
45
|
publishtag.render( renderstate )
|
63
46
|
|
64
|
-
subscriber.published_nodes.
|
47
|
+
expect( subscriber.published_nodes ).to eq( [ 'elveses' ] )
|
65
48
|
end
|
66
49
|
|
67
50
|
end
|
@@ -1,17 +1,8 @@
|
|
1
1
|
#!/usr/bin/env rspec -cfd -b
|
2
2
|
# vim: set noet nosta sw=4 ts=4 :
|
3
3
|
|
4
|
-
|
5
|
-
require 'pathname'
|
6
|
-
basedir = Pathname( __FILE__ ).dirname.parent.parent.parent
|
7
|
-
libdir = basedir + 'lib'
|
4
|
+
require_relative '../../helpers'
|
8
5
|
|
9
|
-
$LOAD_PATH.unshift( basedir.to_s ) unless $LOAD_PATH.include?( basedir.to_s )
|
10
|
-
$LOAD_PATH.unshift( libdir.to_s ) unless $LOAD_PATH.include?( libdir.to_s )
|
11
|
-
}
|
12
|
-
|
13
|
-
require 'rspec'
|
14
|
-
require 'spec/lib/helpers'
|
15
6
|
require 'inversion/template/begintag'
|
16
7
|
require 'inversion/template/rescuetag'
|
17
8
|
require 'inversion/template/commenttag'
|
@@ -20,32 +11,24 @@ require 'inversion/renderstate'
|
|
20
11
|
|
21
12
|
describe Inversion::Template::RescueTag do
|
22
13
|
|
23
|
-
before( :all ) do
|
24
|
-
setup_logging( :fatal )
|
25
|
-
end
|
26
|
-
|
27
|
-
after( :all ) do
|
28
|
-
reset_logging()
|
29
|
-
end
|
30
|
-
|
31
14
|
it "handles a non-existant body" do
|
32
15
|
tag = Inversion::Template::RescueTag.new( nil )
|
33
|
-
tag.exception_types.
|
16
|
+
expect( tag.exception_types ).to eq( [ ::RuntimeError ] )
|
34
17
|
end
|
35
18
|
|
36
19
|
it "parses its body into classes" do
|
37
20
|
tag = Inversion::Template::RescueTag.new( 'ScriptError' )
|
38
|
-
tag.exception_types.
|
21
|
+
expect( tag.exception_types ).to eq( [ ::ScriptError ] )
|
39
22
|
end
|
40
23
|
|
41
24
|
it "handles fully-qualified class names" do
|
42
25
|
tag = Inversion::Template::RescueTag.new( '::ScriptError' )
|
43
|
-
tag.exception_types.
|
26
|
+
expect( tag.exception_types ).to eq( [ ::ScriptError ] )
|
44
27
|
end
|
45
28
|
|
46
29
|
it "can parse multiple exception class names" do
|
47
30
|
tag = Inversion::Template::RescueTag.new( '::ScriptError, Inversion::ParseError' )
|
48
|
-
tag.exception_types.
|
31
|
+
expect( tag.exception_types ).to eq( [ ::ScriptError, Inversion::ParseError ] )
|
49
32
|
end
|
50
33
|
|
51
34
|
it "can be appended to a 'begin' tag" do
|
@@ -58,8 +41,8 @@ describe Inversion::Template::RescueTag do
|
|
58
41
|
|
59
42
|
parserstate << begintag << rescuetag << textnode << endtag
|
60
43
|
|
61
|
-
parserstate.tree.
|
62
|
-
begintag.rescue_clauses.
|
44
|
+
expect( parserstate.tree ).to eq( [ begintag, endtag ] )
|
45
|
+
expect( begintag.rescue_clauses ).to eq( [ [[::RuntimeError], [textnode]] ] )
|
63
46
|
end
|
64
47
|
|
65
48
|
it "can be appended to a 'comment' tag" do
|
@@ -71,8 +54,8 @@ describe Inversion::Template::RescueTag do
|
|
71
54
|
|
72
55
|
parserstate << commenttag << rescuetag << endtag
|
73
56
|
|
74
|
-
parserstate.tree.
|
75
|
-
commenttag.subnodes.
|
57
|
+
expect( parserstate.tree ).to eq( [ commenttag, endtag ] )
|
58
|
+
expect( commenttag.subnodes ).to include( rescuetag )
|
76
59
|
end
|
77
60
|
|
78
61
|
it "raises an error if it's about to be appended to anything other than a 'begin' or " +
|
@@ -83,7 +66,7 @@ describe Inversion::Template::RescueTag do
|
|
83
66
|
|
84
67
|
expect {
|
85
68
|
parserstate << Inversion::Template::RescueTag.new
|
86
|
-
}.to
|
69
|
+
}.to raise_error( Inversion::ParseError, /'for' tags can't have 'rescue' clauses/i )
|
87
70
|
end
|
88
71
|
|
89
72
|
|
@@ -93,14 +76,14 @@ describe Inversion::Template::RescueTag do
|
|
93
76
|
|
94
77
|
expect {
|
95
78
|
parserstate << Inversion::Template::RescueTag.new
|
96
|
-
}.to
|
79
|
+
}.to raise_error( Inversion::ParseError, /orphaned 'rescue' tag/i )
|
97
80
|
end
|
98
81
|
|
99
82
|
|
100
83
|
it "doesn't render as anything by itself" do
|
101
84
|
renderstate = Inversion::RenderState.new
|
102
85
|
tag = Inversion::Template::RescueTag.new
|
103
|
-
tag.render( renderstate ).
|
86
|
+
expect( tag.render( renderstate ) ).to be_nil()
|
104
87
|
end
|
105
88
|
|
106
89
|
end
|