inversion 0.12.3 → 0.14.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (59) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +2 -1
  3. data.tar.gz.sig +0 -0
  4. data/ChangeLog +305 -9
  5. data/Examples.rdoc +134 -0
  6. data/GettingStarted.rdoc +44 -0
  7. data/Guide.rdoc +47 -0
  8. data/History.rdoc +15 -0
  9. data/Manifest.txt +7 -2
  10. data/README.rdoc +9 -10
  11. data/Rakefile +23 -10
  12. data/Tags.rdoc +561 -0
  13. data/lib/inversion.rb +2 -2
  14. data/lib/inversion/renderstate.rb +46 -11
  15. data/lib/inversion/template.rb +85 -7
  16. data/lib/inversion/template/attrtag.rb +1 -1
  17. data/lib/inversion/template/begintag.rb +8 -8
  18. data/lib/inversion/template/fragmenttag.rb +60 -0
  19. data/lib/inversion/template/rescuetag.rb +1 -1
  20. data/spec/{lib/helpers.rb → helpers.rb} +7 -30
  21. data/spec/inversion/mixins_spec.rb +55 -65
  22. data/spec/inversion/monkeypatches_spec.rb +2 -12
  23. data/spec/inversion/parser_spec.rb +34 -44
  24. data/spec/inversion/renderstate_spec.rb +123 -69
  25. data/spec/inversion/sinatra_spec.rb +6 -19
  26. data/spec/inversion/template/attrtag_spec.rb +56 -76
  27. data/spec/inversion/template/begintag_spec.rb +24 -41
  28. data/spec/inversion/template/calltag_spec.rb +1 -18
  29. data/spec/inversion/template/codetag_spec.rb +6 -24
  30. data/spec/inversion/template/commenttag_spec.rb +9 -27
  31. data/spec/inversion/template/configtag_spec.rb +5 -16
  32. data/spec/inversion/template/containertag_spec.rb +4 -21
  33. data/spec/inversion/template/defaulttag_spec.rb +6 -23
  34. data/spec/inversion/template/elsetag_spec.rb +9 -26
  35. data/spec/inversion/template/elsiftag_spec.rb +7 -24
  36. data/spec/inversion/template/endtag_spec.rb +6 -23
  37. data/spec/inversion/template/escapetag_spec.rb +10 -25
  38. data/spec/inversion/template/fortag_spec.rb +20 -37
  39. data/spec/inversion/template/fragmenttag_spec.rb +40 -0
  40. data/spec/inversion/template/iftag_spec.rb +23 -40
  41. data/spec/inversion/template/importtag_spec.rb +8 -25
  42. data/spec/inversion/template/includetag_spec.rb +27 -42
  43. data/spec/inversion/template/node_spec.rb +6 -15
  44. data/spec/inversion/template/pptag_spec.rb +10 -23
  45. data/spec/inversion/template/publishtag_spec.rb +4 -21
  46. data/spec/inversion/template/rescuetag_spec.rb +12 -29
  47. data/spec/inversion/template/subscribetag_spec.rb +8 -25
  48. data/spec/inversion/template/tag_spec.rb +24 -37
  49. data/spec/inversion/template/textnode_spec.rb +8 -24
  50. data/spec/inversion/template/timedeltatag_spec.rb +31 -43
  51. data/spec/inversion/template/unlesstag_spec.rb +7 -24
  52. data/spec/inversion/template/uriencodetag_spec.rb +6 -23
  53. data/spec/inversion/template/yieldtag_spec.rb +3 -20
  54. data/spec/inversion/template_spec.rb +155 -108
  55. data/spec/inversion/tilt_spec.rb +7 -16
  56. data/spec/inversion_spec.rb +7 -22
  57. metadata +63 -40
  58. metadata.gz.sig +0 -0
  59. data/spec/lib/constants.rb +0 -9
@@ -1,19 +1,10 @@
1
1
  #!/usr/bin/env rspec -cfd -b
2
2
  # vim: set noet nosta sw=4 ts=4 :
3
3
 
4
- BEGIN {
5
- require 'pathname'
6
- basedir = Pathname( __FILE__ ).dirname.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
- }
12
-
13
- require 'rspec'
14
- require 'spec/lib/helpers'
4
+ require_relative '../helpers'
15
5
 
16
6
  begin
7
+ require 'sinatra'
17
8
  require 'rack/test'
18
9
  require 'inversion/sinatra'
19
10
  $sinatra_support = true
@@ -25,21 +16,17 @@ end
25
16
  describe "Sinatra support", :if => $sinatra_support do
26
17
  include Rack::Test::Methods if defined?( ::Rack )
27
18
 
28
- before( :all ) do
29
- setup_logging( :fatal )
30
- end
31
-
32
19
  before( :each ) do
33
20
  @datadir = Pathname( __FILE__ ).dirname.parent + 'data'
34
- Sinatra::Base.set :environment, :test
35
21
  end
36
22
 
37
23
  def app
24
+ Sinatra::Base.set :environment, :test
38
25
  @app
39
26
  end
40
27
 
41
28
  it "extends the Sinatra DSL with an #inversion helper method" do
42
- Sinatra::Base.instance_methods.should include( :inversion )
29
+ expect( Sinatra::Base.instance_methods ).to include( :inversion )
43
30
  end
44
31
 
45
32
  it "renders .inversion files in views path" do
@@ -51,8 +38,8 @@ describe "Sinatra support", :if => $sinatra_support do
51
38
  end
52
39
 
53
40
  get '/'
54
- last_response.should be_ok
55
- last_response.body.should == 'Hello, Sinatra!'
41
+ expect( last_response ).to be_ok
42
+ expect( last_response.body ).to eq( 'Hello, Sinatra!' )
56
43
  end
57
44
 
58
45
  end
@@ -1,120 +1,103 @@
1
1
  #!/usr/bin/env rspec -cfd -b
2
2
  # vim: set noet nosta sw=4 ts=4 :
3
3
 
4
- BEGIN {
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/attrtag'
16
7
 
17
8
  describe Inversion::Template::AttrTag 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
  describe "parsing" do
28
11
 
29
12
  it "can have a simple attribute name" do
30
- Inversion::Template::AttrTag.new( 'foo' ).name.should == :foo
13
+ expect( described_class.new( 'foo' ).name ).to eq( :foo )
31
14
  end
32
15
 
33
16
  it "can have an attribute name and a format string" do
34
- tag = Inversion::Template::AttrTag.new( '"%0.2f" % foo' )
35
- tag.name.should == :foo
36
- tag.format.should == '%0.2f'
17
+ tag = described_class.new( '"%0.2f" % foo' )
18
+ expect( tag.name ).to eq( :foo )
19
+ expect( tag.format ).to eq( '%0.2f' )
37
20
  end
38
21
 
39
22
  it "raises an exception with an unknown operator" do
40
23
  expect {
41
- Inversion::Template::AttrTag.new( '"%0.2f" + foo' )
42
- }.to raise_exception( Inversion::ParseError, /expected/ )
24
+ described_class.new( '"%0.2f" + foo' )
25
+ }.to raise_error( Inversion::ParseError, /expected/ )
43
26
  end
44
27
 
45
28
  it "raises an exception if it has more than one identifier" do
46
29
  expect {
47
- Inversion::Template::AttrTag.new( '"%0.2f" % [ foo, bar ]' )
48
- }.to raise_exception( Inversion::ParseError, /expected/ )
30
+ described_class.new( '"%0.2f" % [ foo, bar ]' )
31
+ }.to raise_error( Inversion::ParseError, /expected/ )
49
32
  end
50
33
 
51
34
  it "supports simple <identifier>.<methodname> syntax" do
52
- tag = Inversion::Template::AttrTag.new( 'foo.bar' )
35
+ tag = described_class.new( 'foo.bar' )
53
36
 
54
- tag.name.should == :foo
55
- tag.methodchain.should == '.bar'
37
+ expect( tag.name ).to eq( :foo )
38
+ expect( tag.methodchain ).to eq( '.bar' )
56
39
  end
57
40
 
58
41
  it "supports index operator (<identifier>.methodname[ <arguments> ]) syntax" do
59
- tag = Inversion::Template::AttrTag.new( 'foo.bar[8]' )
42
+ tag = described_class.new( 'foo.bar[8]' )
60
43
 
61
- tag.name.should == :foo
62
- tag.methodchain.should == '.bar[8]'
44
+ expect( tag.name ).to eq( :foo )
45
+ expect( tag.methodchain ).to eq( '.bar[8]' )
63
46
  end
64
47
 
65
48
  it "supports index operator (<identifier>[ <arguments> ]) syntax" do
66
- tag = Inversion::Template::AttrTag.new( 'foo[8]' )
49
+ tag = described_class.new( 'foo[8]' )
67
50
 
68
- tag.name.should == :foo
69
- tag.methodchain.should == '[8]'
51
+ expect( tag.name ).to eq( :foo )
52
+ expect( tag.methodchain ).to eq( '[8]' )
70
53
  end
71
54
 
72
55
  it "supports <identifier>.<methodname>( <arguments> ) syntax" do
73
- tag = Inversion::Template::AttrTag.new( 'foo.bar( 8, :baz )' )
56
+ tag = described_class.new( 'foo.bar( 8, :baz )' )
74
57
 
75
- tag.name.should == :foo
76
- tag.methodchain.should == '.bar( 8, :baz )'
58
+ expect( tag.name ).to eq( :foo )
59
+ expect( tag.methodchain ).to eq( '.bar( 8, :baz )' )
77
60
  end
78
61
 
79
62
  it "can have a format with a methodchain" do
80
- tag = Inversion::Template::AttrTag.new( '"%0.02f" % foo.bar( 8 )' )
63
+ tag = described_class.new( '"%0.02f" % foo.bar( 8 )' )
81
64
 
82
- tag.name.should == :foo
83
- tag.methodchain.should == '.bar( 8 )'
84
- tag.format.should == '%0.02f'
65
+ expect( tag.name ).to eq( :foo )
66
+ expect( tag.methodchain ).to eq( '.bar( 8 )' )
67
+ expect( tag.format ).to eq( '%0.02f' )
85
68
  end
86
69
  end
87
70
 
88
71
  describe "rendering" do
89
72
 
90
73
  it "can render itself as a comment for template debugging" do
91
- tag = Inversion::Template::AttrTag.new( 'foo.bar( 8, :baz )' )
92
- tag.as_comment_body.should == "Attr: { template.foo.bar( 8, :baz ) }"
74
+ tag = described_class.new( 'foo.bar( 8, :baz )' )
75
+ expect( tag.as_comment_body ).to eq( "Attr: { template.foo.bar( 8, :baz ) }" )
93
76
  end
94
77
 
95
78
  context "without a format" do
96
79
 
97
80
  before( :each ) do
98
- @tag = Inversion::Template::AttrTag.new( 'foo' )
81
+ @tag = described_class.new( 'foo' )
99
82
  end
100
83
 
101
84
  it "renders as the stringified contents of the template attribute with the same name" do
102
85
  state = Inversion::RenderState.new( :foo => %w[floppy the turtle] )
103
- @tag.render( state ).should == ["floppy", "the", "turtle"]
86
+ expect( @tag.render( state ) ).to eq( ["floppy", "the", "turtle"] )
104
87
  end
105
88
 
106
89
  it "doesn't error if the attribute isn't set on the template" do
107
90
  state = Inversion::RenderState.new( :foo => nil )
108
- @tag.render( state ).should == nil
91
+ expect( @tag.render( state ) ).to eq( nil )
109
92
  end
110
93
 
111
94
  it "returns false when the rendered value is false" do
112
95
  state = Inversion::RenderState.new( :foo => false )
113
- @tag.render( state ).should equal( false )
96
+ expect( @tag.render( state ) ).to equal( false )
114
97
  end
115
98
 
116
99
  it "can render itself as a comment for template debugging" do
117
- @tag.as_comment_body.should == 'Attr: { template.foo }'
100
+ expect( @tag.as_comment_body ).to eq( 'Attr: { template.foo }' )
118
101
  end
119
102
 
120
103
  end
@@ -122,25 +105,22 @@ describe Inversion::Template::AttrTag do
122
105
  context "with a format" do
123
106
 
124
107
  before( :each ) do
125
- @tag = Inversion::Template::AttrTag.new( 'foo' )
108
+ @tag = described_class.new( 'foo' )
126
109
  @tag.format = "%0.2f"
127
110
  end
128
111
 
129
112
  it "renders as the formatted contents of the template attribute with the same name" do
130
113
  state = Inversion::RenderState.new( :foo => Math::PI )
131
- @tag.render( state ).should == '3.14'
114
+ expect( @tag.render( state ) ).to eq( '3.14' )
132
115
  end
133
116
 
134
117
  it "doesn't error if the attribute isn't set on the template" do
135
- pending "recalling why we did this" do
136
- state = Inversion::RenderState.new( :foo => nil )
137
- @tag.render( state ).should == nil
138
- end
118
+ state = Inversion::RenderState.new( :foo => nil )
119
+ expect( @tag.render(state) ).to eq( nil )
139
120
  end
140
121
 
141
122
  it "can render itself as a comment for template debugging" do
142
- @tag.as_comment_body.
143
- should == 'Attr: { template.foo } with format: "%0.2f"'
123
+ expect( @tag.as_comment_body ).to eq( 'Attr: { template.foo } with format: "%0.2f"' )
144
124
  end
145
125
 
146
126
  end
@@ -148,69 +128,69 @@ describe Inversion::Template::AttrTag do
148
128
  context "with a methodchain" do
149
129
 
150
130
  before( :each ) do
151
- @attribute_object = mock( "template attribute" )
131
+ @attribute_object = double( "template attribute" )
152
132
  end
153
133
 
154
134
  it "renders a single method call with no arguments" do
155
135
  template = Inversion::Template.new( 'this is <?attr foo.bar ?>' )
156
136
  template.foo = @attribute_object
157
- @attribute_object.should_receive( :bar ).with( no_args() ).and_return( "the result" )
137
+ expect( @attribute_object ).to receive( :bar ).with( no_args() ).and_return( "the result" )
158
138
 
159
- template.render.should == "this is the result"
139
+ expect( template.render ).to eq( "this is the result" )
160
140
  end
161
141
 
162
142
  it "renders a single method call with one argument" do
163
143
  template = Inversion::Template.new( 'this is <?attr foo.bar(8) ?>' )
164
144
  template.foo = @attribute_object
165
- @attribute_object.should_receive( :bar ).with( 8 ).and_return( "the result" )
145
+ expect( @attribute_object ).to receive( :bar ).with( 8 ).and_return( "the result" )
166
146
 
167
- template.render.should == "this is the result"
147
+ expect( template.render ).to eq( "this is the result" )
168
148
  end
169
149
 
170
150
  it "renders a call with a single index operator" do
171
151
  template = Inversion::Template.new( 'lines end with <?attr config[:line_ending] ?>' )
172
152
  template.config = { :line_ending => 'newline' }
173
153
 
174
- template.render.should == "lines end with newline"
154
+ expect( template.render ).to eq( "lines end with newline" )
175
155
  end
176
156
 
177
157
  it "renders a single method call with multiple arguments" do
178
158
  template = Inversion::Template.new( 'this is <?attr foo.bar(8, :woo) ?>' )
179
159
  template.foo = @attribute_object
180
- @attribute_object.should_receive( :bar ).with( 8, :woo ).and_return( "the result" )
160
+ expect( @attribute_object ).to receive( :bar ).with( 8, :woo ).and_return( "the result" )
181
161
 
182
- template.render.should == "this is the result"
162
+ expect( template.render ).to eq( "this is the result" )
183
163
  end
184
164
 
185
165
  it "renders multiple method calls with no arguments" do
186
- additional_object = mock( 'additional template attribute' )
166
+ additional_object = double( 'additional template attribute' )
187
167
  template = Inversion::Template.new( 'this is <?attr foo.bar.baz ?>' )
188
168
  template.foo = @attribute_object
189
- template.foo.should_receive( :bar ).and_return( additional_object )
190
- additional_object.should_receive( :baz ).with( no_args() ).and_return( "the result" )
169
+ expect( template.foo ).to receive( :bar ).and_return( additional_object )
170
+ expect( additional_object ).to receive( :baz ).with( no_args() ).and_return( "the result" )
191
171
 
192
- template.render.should == "this is the result"
172
+ expect( template.render ).to eq( "this is the result" )
193
173
  end
194
174
 
195
175
  it "renders multiple method calls with arguments" do
196
- additional_object = mock( 'additional template attribute' )
176
+ additional_object = double( 'additional template attribute' )
197
177
  template = Inversion::Template.new( 'this is <?attr foo.bar( 8 ).baz( :woo ) ?>' )
198
178
  template.foo = @attribute_object
199
- template.foo.should_receive( :bar ).with( 8 ).and_return( additional_object )
200
- additional_object.should_receive( :baz ).with( :woo ).and_return( "the result" )
179
+ expect( template.foo ).to receive( :bar ).with( 8 ).and_return( additional_object )
180
+ expect( additional_object ).to receive( :baz ).with( :woo ).and_return( "the result" )
201
181
 
202
- template.render.should == "this is the result"
182
+ expect( template.render ).to eq( "this is the result" )
203
183
  end
204
184
 
205
185
  it "renders method calls with template attribute arguments" do
206
186
  template = Inversion::Template.new( 'this is <?attr foo.bar( baz ) ?>' )
207
- foo = mock( "foo attribute object" )
187
+ foo = double( "foo attribute object" )
208
188
 
209
189
  template.foo = foo
210
190
  template.baz = 18
211
- foo.should_receive( :bar ).with( 18 ).and_return( "the result of calling bar" )
191
+ expect( foo ).to receive( :bar ).with( 18 ).and_return( "the result of calling bar" )
212
192
 
213
- template.render.should == "this is the result of calling bar"
193
+ expect( template.render ).to eq( "this is the result of calling bar" )
214
194
  end
215
195
  end
216
196
 
@@ -1,18 +1,9 @@
1
1
  #!/usr/bin/env rspec -cfd -b
2
2
  # vim: set noet nosta sw=4 ts=4 :
3
3
 
4
- BEGIN {
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
6
  require 'ostruct'
15
- require 'spec/lib/helpers'
16
7
  require 'inversion/template/begintag'
17
8
  require 'inversion/template/textnode'
18
9
  require 'inversion/template/attrtag'
@@ -22,14 +13,6 @@ require 'inversion/renderstate'
22
13
 
23
14
  describe Inversion::Template::BeginTag do
24
15
 
25
- before( :all ) do
26
- setup_logging( :fatal )
27
- end
28
-
29
- after( :all ) do
30
- reset_logging()
31
- end
32
-
33
16
 
34
17
  context "without any rescue clauses" do
35
18
 
@@ -42,14 +25,14 @@ describe Inversion::Template::BeginTag do
42
25
  it "renders its subnodes as-is if none of them raise an exception" do
43
26
  renderstate = Inversion::RenderState.new( :foo => OpenStruct.new(:baz => 'the body') )
44
27
  renderstate << @tag
45
- renderstate.to_s.should == 'the body:the stuff after the attr'
28
+ expect( renderstate.to_s ).to eq( 'the body:the stuff after the attr' )
46
29
  end
47
30
 
48
31
  it "uses the configured error behavior of the template if a subnode raises any exception" do
49
32
  renderstate = Inversion::RenderState.new
50
33
  renderstate << @tag
51
- renderstate.to_s.should =~ /NoMethodError/
52
- renderstate.to_s.should_not =~ /the stuff after the attr/i
34
+ expect( renderstate.to_s ).to match( /NoMethodError/ )
35
+ expect( renderstate.to_s ).to_not match( /the stuff after the attr/i )
53
36
  end
54
37
 
55
38
  end
@@ -71,13 +54,13 @@ describe Inversion::Template::BeginTag do
71
54
  end
72
55
 
73
56
  it "contains one rescue clause for RuntimeErrors" do
74
- @tag.rescue_clauses.should == [ [[::RuntimeError], [@rescue_textnode]] ]
57
+ expect( @tag.rescue_clauses ).to eq([ [[::RuntimeError], [@rescue_textnode]] ])
75
58
  end
76
59
 
77
60
  it "renders its subnodes as-is if none of them raise an exception" do
78
61
  renderstate = Inversion::RenderState.new( :foo => OpenStruct.new(:baz => 'the body') )
79
62
  renderstate << @tag
80
- renderstate.to_s.should == 'the body:the stuff after the attr'
63
+ expect( renderstate.to_s ).to eq( 'the body:the stuff after the attr' )
81
64
  end
82
65
 
83
66
  it "renders the rescue section if a subnode raises a RuntimeError" do
@@ -86,7 +69,7 @@ describe Inversion::Template::BeginTag do
86
69
 
87
70
  renderstate = Inversion::RenderState.new( :foo => fooobj )
88
71
  renderstate << @tag
89
- renderstate.to_s.should == 'rescue stuff'
72
+ expect( renderstate.to_s ).to eq( 'rescue stuff' )
90
73
  end
91
74
 
92
75
  it "uses the configured error behavior of the template if a subnode raises an " +
@@ -96,9 +79,9 @@ describe Inversion::Template::BeginTag do
96
79
 
97
80
  renderstate = Inversion::RenderState.new( :foo => fooobj )
98
81
  renderstate << @tag
99
- renderstate.to_s.should =~ /ENOENT/i
100
- renderstate.to_s.should_not =~ /rescue stuff/i
101
- renderstate.to_s.should_not =~ /the stuff after the attr/i
82
+ expect( renderstate.to_s ).to match( /ENOENT/i )
83
+ expect( renderstate.to_s ).to_not match( /rescue stuff/i )
84
+ expect( renderstate.to_s ).to_not match( /the stuff after the attr/i )
102
85
  end
103
86
  end
104
87
 
@@ -120,13 +103,13 @@ describe Inversion::Template::BeginTag do
120
103
  end
121
104
 
122
105
  it "contains one rescue clause for the specified exception type" do
123
- @tag.rescue_clauses.should == [ [[::SystemCallError], [@rescue_textnode]] ]
106
+ expect( @tag.rescue_clauses ).to eq( [ [[::SystemCallError], [@rescue_textnode]] ] )
124
107
  end
125
108
 
126
109
  it "renders its subnodes as-is if none of them raise an exception" do
127
110
  renderstate = Inversion::RenderState.new( :foo => OpenStruct.new(:baz => 'the body') )
128
111
  renderstate << @tag
129
- renderstate.to_s.should == 'the body:the stuff after the attr'
112
+ expect( renderstate.to_s ).to eq( 'the body:the stuff after the attr' )
130
113
  end
131
114
 
132
115
  it "renders the rescue section if a subnode raises the specified exception type" do
@@ -135,7 +118,7 @@ describe Inversion::Template::BeginTag do
135
118
 
136
119
  renderstate = Inversion::RenderState.new( :foo => fooobj )
137
120
  renderstate << @tag
138
- renderstate.to_s.should == 'rescue stuff'
121
+ expect( renderstate.to_s ).to eq( 'rescue stuff' )
139
122
  end
140
123
 
141
124
  it "uses the configured error behavior of the template if a subnode raises an " +
@@ -145,9 +128,9 @@ describe Inversion::Template::BeginTag do
145
128
 
146
129
  renderstate = Inversion::RenderState.new( :foo => fooobj )
147
130
  renderstate << @tag
148
- renderstate.to_s.should =~ /RuntimeError/i
149
- renderstate.to_s.should_not =~ /rescue stuff/i
150
- renderstate.to_s.should_not =~ /the stuff after the attr/i
131
+ expect( renderstate.to_s ).to match( /RuntimeError/i )
132
+ expect( renderstate.to_s ).to_not match( /rescue stuff/i )
133
+ expect( renderstate.to_s ).to_not match( /the stuff after the attr/i )
151
134
  end
152
135
  end
153
136
 
@@ -170,16 +153,16 @@ describe Inversion::Template::BeginTag do
170
153
  end
171
154
 
172
155
  it "contains a rescue tuple for each rescue tag" do
173
- @tag.rescue_clauses.should == [
156
+ expect( @tag.rescue_clauses ).to eq([
174
157
  [[::RuntimeError], [@rescue_textnode]],
175
158
  [[Errno::ENOENT, Errno::EWOULDBLOCK], [@rescue_textnode2]],
176
- ]
159
+ ])
177
160
  end
178
161
 
179
162
  it "renders its subnodes as-is if none of them raise an exception" do
180
163
  renderstate = Inversion::RenderState.new( :foo => OpenStruct.new(:baz => 'the body') )
181
164
  renderstate << @tag
182
- renderstate.to_s.should == 'the body:the stuff after the attr'
165
+ expect( renderstate.to_s ).to eq( 'the body:the stuff after the attr' )
183
166
  end
184
167
 
185
168
  it "renders the first rescue section if a subnode raises the exception it " +
@@ -189,7 +172,7 @@ describe Inversion::Template::BeginTag do
189
172
 
190
173
  renderstate = Inversion::RenderState.new( :foo => fooobj )
191
174
  renderstate << @tag
192
- renderstate.to_s.should == 'rescue stuff'
175
+ expect( renderstate.to_s ).to eq( 'rescue stuff' )
193
176
  end
194
177
 
195
178
  it "renders the second rescue section if a subnode raises the exception it " +
@@ -199,7 +182,7 @@ describe Inversion::Template::BeginTag do
199
182
 
200
183
  renderstate = Inversion::RenderState.new( :foo => fooobj )
201
184
  renderstate << @tag
202
- renderstate.to_s.should == 'alternative rescue stuff'
185
+ expect( renderstate.to_s ).to eq( 'alternative rescue stuff' )
203
186
  end
204
187
 
205
188
  it "uses the configured error behavior of the template if a subnode raises an " +
@@ -209,9 +192,9 @@ describe Inversion::Template::BeginTag do
209
192
 
210
193
  renderstate = Inversion::RenderState.new( :foo => fooobj )
211
194
  renderstate << @tag
212
- renderstate.to_s.should =~ /ENOMEM/i
213
- renderstate.to_s.should_not =~ /rescue stuff/i
214
- renderstate.to_s.should_not =~ /the stuff after the attr/i
195
+ expect( renderstate.to_s ).to match( /ENOMEM/i )
196
+ expect( renderstate.to_s ).to_not match( /rescue stuff/i )
197
+ expect( renderstate.to_s ).to_not match( /the stuff after the attr/i )
215
198
  end
216
199
  end
217
200