temple 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +2 -8
  3. data/.gitignore +1 -0
  4. data/CHANGES +5 -0
  5. data/README.md +1 -1
  6. data/Rakefile +3 -11
  7. data/lib/temple/erb/parser.rb +1 -1
  8. data/lib/temple/generator.rb +11 -5
  9. data/lib/temple/version.rb +1 -1
  10. data/spec/engine_spec.rb +189 -0
  11. data/{test/test_erb.rb → spec/erb_spec.rb} +11 -11
  12. data/spec/filter_spec.rb +29 -0
  13. data/{test/filters/test_code_merger.rb → spec/filters/code_merger_spec.rb} +7 -7
  14. data/{test/filters/test_control_flow.rb → spec/filters/control_flow_spec.rb} +13 -13
  15. data/{test/filters/test_dynamic_inliner.rb → spec/filters/dynamic_inliner_spec.rb} +18 -18
  16. data/{test/filters/test_eraser.rb → spec/filters/eraser_spec.rb} +9 -9
  17. data/{test/filters/test_escapable.rb → spec/filters/escapable_spec.rb} +10 -10
  18. data/{test/filters/test_multi_flattener.rb → spec/filters/multi_flattener_spec.rb} +4 -4
  19. data/{test/filters/test_static_analyzer.rb → spec/filters/static_analyzer_spec.rb} +6 -8
  20. data/{test/filters/test_static_merger.rb → spec/filters/static_merger_spec.rb} +7 -7
  21. data/{test/filters/test_string_splitter.rb → spec/filters/string_splitter_spec.rb} +4 -5
  22. data/spec/generator_spec.rb +167 -0
  23. data/spec/grammar_spec.rb +47 -0
  24. data/{test/html/test_attribute_merger.rb → spec/html/attribute_merger_spec.rb} +11 -11
  25. data/{test/html/test_attribute_remover.rb → spec/html/attribute_remover_spec.rb} +7 -7
  26. data/{test/html/test_attribute_sorter.rb → spec/html/attribute_sorter_spec.rb} +7 -7
  27. data/{test/html/test_fast.rb → spec/html/fast_spec.rb} +23 -23
  28. data/{test/html/test_pretty.rb → spec/html/pretty_spec.rb} +7 -7
  29. data/spec/map_spec.rb +39 -0
  30. data/{test/mixins/test_dispatcher.rb → spec/mixins/dispatcher_spec.rb} +12 -12
  31. data/{test/mixins/test_grammar_dsl.rb → spec/mixins/grammar_dsl_spec.rb} +19 -19
  32. data/{test/helper.rb → spec/spec_helper.rb} +3 -4
  33. data/{test/test_static_analyzer.rb → spec/static_analyzer_spec.rb} +6 -6
  34. data/spec/utils_spec.rb +39 -0
  35. data/temple.gemspec +1 -1
  36. metadata +28 -28
  37. data/test/test_engine.rb +0 -189
  38. data/test/test_filter.rb +0 -29
  39. data/test/test_generator.rb +0 -158
  40. data/test/test_grammar.rb +0 -47
  41. data/test/test_map.rb +0 -39
  42. data/test/test_utils.rb +0 -39
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 527609e09539e1854fc16e48ac864d23ce89584ec8c0cb3f3cf1f4ee4d6e8101
4
- data.tar.gz: eee6b6dd3a38dde73365469c10b5cf7f8b6a35dd6797268b104e50cef27b4863
3
+ metadata.gz: ec5bd4c914592e35029369b132ae55d5ae56771b73d5c8710d3b6cbaf8c1409d
4
+ data.tar.gz: 379717f7a2b6580cfe6e3732dcb8da6ff76f6adf2ec725cfc32eacd988f8471a
5
5
  SHA512:
6
- metadata.gz: 17e8c7410950492aa3fdc41cb91f1ad40613324a411d77fcded2667ecb6ac137956e4bee64a9d0b038bb7cd9dc1098ae9e095ca59ba2a4a370e7a7a3cd62a4bd
7
- data.tar.gz: 317d066d2e989072f0182d688845691573a74a31a7365883534c66571986bc2f0503df0a6a389d086cfba1eb0da69734a751a91691efa49772ebfb7a6c58f1b2
6
+ metadata.gz: 938451e922d130af494c37d73612b35c53e05a94143d1cabff3e725b4512fbc4a04e1bf7acc27be0e8b37ebc7b00a2d9859e4f073c0941aeada7a1ed396889db
7
+ data.tar.gz: f2925b82e2fb217f63d0afa4890c71f7ff6e209ee7775e33b9fb4a3885dce9bd638e46b8280f58f3f5002b020fd3e07792c560c3e44ed4b182dbfcefa2c66978
@@ -30,11 +30,5 @@ jobs:
30
30
  uses: ruby/setup-ruby@v1
31
31
  with:
32
32
  ruby-version: ${{ matrix.ruby }}
33
- - uses: actions/cache@v2
34
- with:
35
- path: vendor/bundle
36
- key: ${{ runner.os }}-${{ matrix.ruby }}-gems-${{ hashFiles('**/Gemfile.lock') }}
37
- restore-keys: ${{ runner.os }}-gems-
38
- - name: bundle install
39
- run: bundle config path vendor/bundle && bundle install -j$(nproc) --retry 3
40
- - run: bundle exec rake test
33
+ bundler-cache: true
34
+ - run: bundle exec rake spec
data/.gitignore CHANGED
@@ -2,3 +2,4 @@ coverage
2
2
  .yardoc
3
3
  doc
4
4
  Gemfile.lock
5
+ /pkg/
data/CHANGES CHANGED
@@ -1,3 +1,8 @@
1
+ 0.9.1
2
+
3
+ * Fix Slim's error in AttributeMerger due to 0.9.0's :capture_generator (#137)
4
+ * Fix Temple::ERB::Engine's <%= to not escape and <%== to escape expressions
5
+
1
6
  0.9.0
2
7
 
3
8
  * Require Ruby 2.5+ (#131)
data/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  Temple
2
2
  ======
3
3
 
4
- [![Build Status](https://secure.travis-ci.org/judofyr/temple.svg?branch=master)](http://travis-ci.org/judofyr/temple) [![Code Climate](https://codeclimate.com/github/judofyr/temple.svg)](https://codeclimate.com/github/judofyr/temple) [![Gem Version](https://badge.fury.io/rb/temple.svg)](https://rubygems.org/gems/temple)
4
+ [![test](https://github.com/judofyr/temple/actions/workflows/test.yml/badge.svg)](https://github.com/judofyr/temple/actions/workflows/test.yml) [![Code Climate](https://codeclimate.com/github/judofyr/temple.svg)](https://codeclimate.com/github/judofyr/temple) [![Gem Version](https://badge.fury.io/rb/temple.svg)](https://rubygems.org/gems/temple) [![Yard Docs](https://img.shields.io/badge/yard-docs-blue.svg)](http://rubydoc.info/gems/temple/frames)
5
5
 
6
6
  Temple is an abstraction and a framework for compiling templates to pure Ruby.
7
7
  It's all about making it easier to experiment, implement and optimize template
data/Rakefile CHANGED
@@ -1,16 +1,8 @@
1
1
  require 'bundler/gem_tasks'
2
- require 'rake/testtask'
2
+ require 'rspec/core/rake_task'
3
3
 
4
- task default: :test
5
- task :test do
6
- sh "bacon -Ilib -Itest --automatic --quiet"
7
- end
8
-
9
- #Rake::TestTask.new(:test) do |t|
10
- # t.libs << 'lib' << 'test'
11
- # t.pattern = 'test/**/test_*.rb'
12
- # t.verbose = false
13
- #end
4
+ RSpec::Core::RakeTask.new(:spec)
5
+ task default: :spec
14
6
 
15
7
  begin
16
8
  require 'rcov/rcovtask'
@@ -27,7 +27,7 @@ module Temple
27
27
  when '#'
28
28
  result << [:code, "\n" * code.count("\n")]
29
29
  when /=/
30
- result << [:escape, indicator.size <= 1, [:dynamic, code]]
30
+ result << [:escape, indicator.size == 2, [:dynamic, code]]
31
31
  else
32
32
  result << [:code, code]
33
33
  end
@@ -10,7 +10,7 @@ module Temple
10
10
  include Mixins::Options
11
11
 
12
12
  define_options :save_buffer,
13
- capture_generator: self,
13
+ capture_generator: :self,
14
14
  buffer: '_buf',
15
15
  freeze_static: RUBY_VERSION >= '2.1'
16
16
 
@@ -54,7 +54,7 @@ module Temple
54
54
  end
55
55
 
56
56
  def on_capture(name, exp)
57
- capture_generator.new(buffer: name).call(exp)
57
+ capture_generator.new(**options, buffer: name).call(exp)
58
58
  end
59
59
 
60
60
  def on_static(text)
@@ -76,9 +76,15 @@ module Temple
76
76
  end
77
77
 
78
78
  def capture_generator
79
- @capture_generator ||= Class === options[:capture_generator] ?
80
- options[:capture_generator] :
81
- Generators.const_get(options[:capture_generator])
79
+ @capture_generator ||=
80
+ case options[:capture_generator]
81
+ when :self
82
+ self.class
83
+ when Class
84
+ options[:capture_generator]
85
+ else
86
+ Generators.const_get(options[:capture_generator])
87
+ end
82
88
  end
83
89
 
84
90
  def concat(str)
@@ -1,3 +1,3 @@
1
1
  module Temple
2
- VERSION = '0.9.0'
2
+ VERSION = '0.9.1'
3
3
  end
@@ -0,0 +1,189 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ class Callable1
5
+ def call(exp)
6
+ exp
7
+ end
8
+ end
9
+
10
+ class Callable2
11
+ def call(exp)
12
+ exp
13
+ end
14
+ end
15
+
16
+ class MySpecialFilter
17
+ def initialize(opts = {})
18
+ end
19
+
20
+ def call(exp)
21
+ exp
22
+ end
23
+ end
24
+
25
+ class TestEngine < Temple::Engine
26
+ use(:Parser) do |input|
27
+ [:static, input]
28
+ end
29
+ use :MyFilter1, proc {|exp| exp }
30
+ use :MyFilter2, proc {|exp| exp }
31
+ use Temple::HTML::Pretty, pretty: true
32
+ filter :MultiFlattener
33
+ generator :ArrayBuffer
34
+ use(:BeforeBeforeLast) { MySpecialFilter }
35
+ use :BeforeLast, Callable1.new
36
+ use(:Last) { Callable2.new }
37
+ end
38
+
39
+ describe Temple::Engine do
40
+ it 'should build chain' do
41
+ expect(TestEngine.chain.size).to eq(9)
42
+
43
+ expect(TestEngine.chain[0].first).to eq(:Parser)
44
+ expect(TestEngine.chain[0].size).to eq(2)
45
+ expect(TestEngine.chain[0].last).to be_a(Proc)
46
+
47
+ expect(TestEngine.chain[1].first).to eq(:MyFilter1)
48
+ expect(TestEngine.chain[1].size).to eq(2)
49
+ expect(TestEngine.chain[1].last).to be_a(Proc)
50
+
51
+ expect(TestEngine.chain[2].first).to eq(:MyFilter2)
52
+ expect(TestEngine.chain[2].size).to eq(2)
53
+ expect(TestEngine.chain[2].last).to be_a(Proc)
54
+
55
+ expect(TestEngine.chain[3].first).to eq(:'Temple::HTML::Pretty')
56
+ expect(TestEngine.chain[3].size).to eq(2)
57
+ expect(TestEngine.chain[3].last).to be_a(Proc)
58
+
59
+ expect(TestEngine.chain[4].first).to eq(:MultiFlattener)
60
+ expect(TestEngine.chain[4].size).to eq(2)
61
+ expect(TestEngine.chain[4].last).to be_a(Proc)
62
+
63
+ expect(TestEngine.chain[5].first).to eq(:ArrayBuffer)
64
+ expect(TestEngine.chain[5].size).to eq(2)
65
+ expect(TestEngine.chain[5].last).to be_a(Proc)
66
+
67
+ expect(TestEngine.chain[6].first).to eq(:BeforeBeforeLast)
68
+ expect(TestEngine.chain[6].size).to eq(2)
69
+ expect(TestEngine.chain[6].last).to be_a(Proc)
70
+
71
+ expect(TestEngine.chain[7].first).to eq(:BeforeLast)
72
+ expect(TestEngine.chain[7].size).to eq(2)
73
+ expect(TestEngine.chain[7].last).to be_a(Proc)
74
+
75
+ expect(TestEngine.chain[8].first).to eq(:Last)
76
+ expect(TestEngine.chain[8].size).to eq(2)
77
+ expect(TestEngine.chain[8].last).to be_a(Proc)
78
+ end
79
+
80
+ it 'should instantiate chain' do
81
+ call_chain = TestEngine.new.send(:call_chain)
82
+ expect(call_chain[0]).to be_a(Method)
83
+ expect(call_chain[1]).to be_a(Method)
84
+ expect(call_chain[2]).to be_a(Method)
85
+ expect(call_chain[3]).to be_a(Temple::HTML::Pretty)
86
+ expect(call_chain[4]).to be_a(Temple::Filters::MultiFlattener)
87
+ expect(call_chain[5]).to be_a(Temple::Generators::ArrayBuffer)
88
+ expect(call_chain[6]).to be_a(MySpecialFilter)
89
+ expect(call_chain[7]).to be_a(Callable1)
90
+ expect(call_chain[8]).to be_a(Callable2)
91
+ end
92
+
93
+ it 'should have #append' do
94
+ engine = TestEngine.new
95
+ call_chain = engine.send(:call_chain)
96
+ expect(call_chain.size).to eq(9)
97
+
98
+ engine.append :MyFilter3 do |exp|
99
+ exp
100
+ end
101
+
102
+ expect(TestEngine.chain.size).to eq(9)
103
+ expect(engine.chain.size).to eq(10)
104
+ expect(engine.chain[9].first).to eq(:MyFilter3)
105
+ expect(engine.chain[9].size).to eq(2)
106
+ expect(engine.chain[9].last).to be_a(Proc)
107
+
108
+ call_chain = engine.send(:call_chain)
109
+ expect(call_chain.size).to eq(10)
110
+ expect(call_chain[9]).to be_a(Method)
111
+ end
112
+
113
+ it 'should have #prepend' do
114
+ engine = TestEngine.new
115
+ call_chain = engine.send(:call_chain)
116
+ expect(call_chain.size).to eq(9)
117
+
118
+ engine.prepend :MyFilter0 do |exp|
119
+ exp
120
+ end
121
+
122
+ expect(TestEngine.chain.size).to eq(9)
123
+ expect(engine.chain.size).to eq(10)
124
+ expect(engine.chain[0].first).to eq(:MyFilter0)
125
+ expect(engine.chain[0].size).to eq(2)
126
+ expect(engine.chain[0].last).to be_a(Proc)
127
+ expect(engine.chain[1].first).to eq(:Parser)
128
+
129
+ call_chain = engine.send(:call_chain)
130
+ expect(call_chain.size).to eq(10)
131
+ expect(call_chain[0]).to be_a(Method)
132
+ end
133
+
134
+ it 'should have #after' do
135
+ engine = TestEngine.new
136
+ engine.after :Parser, :MyFilter0 do |exp|
137
+ exp
138
+ end
139
+ expect(TestEngine.chain.size).to eq(9)
140
+ expect(engine.chain.size).to eq(10)
141
+ expect(engine.chain[0].first).to eq(:Parser)
142
+ expect(engine.chain[1].first).to eq(:MyFilter0)
143
+ expect(engine.chain[2].first).to eq(:MyFilter1)
144
+ end
145
+
146
+ it 'should have #before' do
147
+ engine = TestEngine.new
148
+ engine.before :MyFilter1, :MyFilter0 do |exp|
149
+ exp
150
+ end
151
+ expect(TestEngine.chain.size).to eq(9)
152
+ expect(engine.chain.size).to eq(10)
153
+ expect(engine.chain[0].first).to eq(:Parser)
154
+ expect(engine.chain[1].first).to eq(:MyFilter0)
155
+ expect(engine.chain[2].first).to eq(:MyFilter1)
156
+ end
157
+
158
+ it 'should have #remove' do
159
+ engine = TestEngine.new
160
+ engine.remove :MyFilter1
161
+ expect(TestEngine.chain.size).to eq(9)
162
+ expect(engine.chain.size).to eq(8)
163
+ expect(engine.chain[0].first).to eq(:Parser)
164
+ expect(engine.chain[1].first).to eq(:MyFilter2)
165
+
166
+ engine = TestEngine.new
167
+ engine.remove /Last/
168
+ expect(engine.chain.size).to eq(6)
169
+ end
170
+
171
+ it 'should have #replace' do
172
+ engine = TestEngine.new
173
+ engine.replace :Parser, :MyParser do |exp|
174
+ exp
175
+ end
176
+ expect(engine.chain.size).to eq(9)
177
+ expect(engine.chain[0].first).to eq(:MyParser)
178
+ end
179
+
180
+ it 'should work with inheritance' do
181
+ inherited_engine = Class.new(TestEngine)
182
+ expect(inherited_engine.chain.size).to eq(9)
183
+ inherited_engine.append :MyFilter3 do |exp|
184
+ exp
185
+ end
186
+ expect(inherited_engine.chain.size).to eq(10)
187
+ expect(TestEngine.chain.size).to eq(9)
188
+ end
189
+ end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'spec_helper'
2
2
  require 'tilt/erubi'
3
3
 
4
4
  describe Temple::ERB::Engine do
@@ -11,7 +11,7 @@ describe Temple::ERB::Engine do
11
11
  <% end %>
12
12
  }
13
13
 
14
- erb(src).should.equal erubi(src)
14
+ expect(erb(src)).to eq(erubi(src))
15
15
  end
16
16
 
17
17
  it 'should recognize comments' do
@@ -20,7 +20,7 @@ hello
20
20
  <%# comment -- ignored -- useful in testing %>
21
21
  world}
22
22
 
23
- erb(src).should.equal erubi(src)
23
+ expect(erb(src)).to eq(erubi(src))
24
24
  end
25
25
 
26
26
  it 'should recognize <%% and %%>' do
@@ -31,19 +31,19 @@ world}
31
31
  <% end %>
32
32
  }
33
33
 
34
- erb(src).should.equal "\n<%\n %>\n"
34
+ expect(erb(src)).to eq("\n<%\n %>\n")
35
35
  end
36
36
 
37
37
  it 'should escape automatically' do
38
- src = '<%= "<" %>'
38
+ src = '<%== "<" %>'
39
39
  ans = '&lt;'
40
- erb(src).should.equal ans
40
+ expect(erb(src)).to eq(ans)
41
41
  end
42
42
 
43
- it 'should support == to disable automatic escape' do
44
- src = '<%== "<" %>'
43
+ it 'should support = to disable automatic escape' do
44
+ src = '<%= "<" %>'
45
45
  ans = '<'
46
- erb(src).should.equal ans
46
+ expect(erb(src)).to eq(ans)
47
47
  end
48
48
 
49
49
  it 'should support trim mode' do
@@ -55,7 +55,7 @@ world}
55
55
  <% end %>
56
56
  }
57
57
 
58
- erb(src, trim: true).should.equal erubi(src, trim: true)
59
- erb(src, trim: false).should.equal erubi(src, trim: false)
58
+ expect(erb(src, trim: true)).to eq(erubi(src, trim: true))
59
+ expect(erb(src, trim: false)).to eq(erubi(src, trim: false))
60
60
  end
61
61
  end
@@ -0,0 +1,29 @@
1
+ require 'spec_helper'
2
+
3
+ class SimpleFilter < Temple::Filter
4
+ define_options :key
5
+
6
+ def on_test(arg)
7
+ [:on_test, arg]
8
+ end
9
+ end
10
+
11
+ describe Temple::Filter do
12
+ it 'should support options' do
13
+ expect(Temple::Filter).to respond_to(:default_options)
14
+ expect(Temple::Filter).to respond_to(:set_default_options)
15
+ expect(Temple::Filter).to respond_to(:define_options)
16
+ expect(Temple::Filter.new.options).to be_a(Temple::ImmutableMap)
17
+ expect(SimpleFilter.new(key: 3).options[:key]).to eq(3)
18
+ end
19
+
20
+ it 'should implement call' do
21
+ expect(Temple::Filter.new.call([:exp])).to eq([:exp])
22
+ end
23
+
24
+ it 'should process expressions' do
25
+ filter = SimpleFilter.new
26
+ expect(filter.call([:unhandled])).to eq([:unhandled])
27
+ expect(filter.call([:test, 42])).to eq([:on_test, 42])
28
+ end
29
+ end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Temple::Filters::CodeMerger do
4
4
  before do
@@ -6,21 +6,21 @@ describe Temple::Filters::CodeMerger do
6
6
  end
7
7
 
8
8
  it 'should merge serveral codes' do
9
- @filter.call([:multi,
9
+ expect(@filter.call([:multi,
10
10
  [:code, "a"],
11
11
  [:code, "b"],
12
12
  [:code, "c"]
13
- ]).should.equal [:code, "a; b; c"]
13
+ ])).to eq [:code, "a; b; c"]
14
14
  end
15
15
 
16
16
  it 'should merge serveral codes around static' do
17
- @filter.call([:multi,
17
+ expect(@filter.call([:multi,
18
18
  [:code, "a"],
19
19
  [:code, "b"],
20
20
  [:static, "123"],
21
21
  [:code, "a"],
22
22
  [:code, "b"]
23
- ]).should.equal [:multi,
23
+ ])).to eq [:multi,
24
24
  [:code, "a; b"],
25
25
  [:static, "123"],
26
26
  [:code, "a; b"]
@@ -28,11 +28,11 @@ describe Temple::Filters::CodeMerger do
28
28
  end
29
29
 
30
30
  it 'should merge serveral codes with newlines' do
31
- @filter.call([:multi,
31
+ expect(@filter.call([:multi,
32
32
  [:code, "a"],
33
33
  [:code, "b"],
34
34
  [:newline],
35
35
  [:code, "c"]
36
- ]).should.equal [:code, "a; b\nc"]
36
+ ])).to eq [:code, "a; b\nc"]
37
37
  end
38
38
  end
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Temple::Filters::ControlFlow do
4
4
  before do
@@ -6,18 +6,18 @@ describe Temple::Filters::ControlFlow do
6
6
  end
7
7
 
8
8
  it 'should process blocks' do
9
- @filter.call([:block, 'loop do',
9
+ expect(@filter.call([:block, 'loop do',
10
10
  [:static, 'Hello']
11
- ]).should.equal [:multi,
11
+ ])).to eq [:multi,
12
12
  [:code, 'loop do'],
13
13
  [:static, 'Hello'],
14
14
  [:code, 'end']]
15
15
  end
16
16
 
17
17
  it 'should process if' do
18
- @filter.call([:if, 'condition',
18
+ expect(@filter.call([:if, 'condition',
19
19
  [:static, 'Hello']
20
- ]).should.equal [:multi,
20
+ ])).to eq [:multi,
21
21
  [:code, 'if condition'],
22
22
  [:static, 'Hello'],
23
23
  [:code, 'end']
@@ -25,10 +25,10 @@ describe Temple::Filters::ControlFlow do
25
25
  end
26
26
 
27
27
  it 'should process if with else' do
28
- @filter.call([:if, 'condition',
28
+ expect(@filter.call([:if, 'condition',
29
29
  [:static, 'True'],
30
30
  [:static, 'False']
31
- ]).should.equal [:multi,
31
+ ])).to eq [:multi,
32
32
  [:code, 'if condition'],
33
33
  [:static, 'True'],
34
34
  [:code, 'else'],
@@ -38,12 +38,12 @@ describe Temple::Filters::ControlFlow do
38
38
  end
39
39
 
40
40
  it 'should create elsif' do
41
- @filter.call([:if, 'condition1',
41
+ expect(@filter.call([:if, 'condition1',
42
42
  [:static, '1'],
43
43
  [:if, 'condition2',
44
44
  [:static, '2'],
45
45
  [:static, '3']]
46
- ]).should.equal [:multi,
46
+ ])).to eq [:multi,
47
47
  [:code, 'if condition1'],
48
48
  [:static, '1'],
49
49
  [:code, 'elsif condition2'],
@@ -55,11 +55,11 @@ describe Temple::Filters::ControlFlow do
55
55
  end
56
56
 
57
57
  it 'should process cond' do
58
- @filter.call([:cond,
58
+ expect(@filter.call([:cond,
59
59
  ['cond1', [:exp1]],
60
60
  ['cond2', [:exp2]],
61
61
  [:else, [:exp3]],
62
- ]).should.equal [:multi,
62
+ ])).to eq [:multi,
63
63
  [:code, 'case'],
64
64
  [:code, 'when cond1'],
65
65
  [:exp1],
@@ -72,11 +72,11 @@ describe Temple::Filters::ControlFlow do
72
72
  end
73
73
 
74
74
  it 'should process case' do
75
- @filter.call([:case, 'var',
75
+ expect(@filter.call([:case, 'var',
76
76
  ['Array', [:exp1]],
77
77
  ['String', [:exp2]],
78
78
  [:else, [:exp3]],
79
- ]).should.equal [:multi,
79
+ ])).to eq [:multi,
80
80
  [:code, 'case (var)'],
81
81
  [:code, 'when Array'],
82
82
  [:exp1],
@@ -1,4 +1,4 @@
1
- require 'helper'
1
+ require 'spec_helper'
2
2
 
3
3
  describe Temple::Filters::DynamicInliner do
4
4
  before do
@@ -6,38 +6,38 @@ describe Temple::Filters::DynamicInliner do
6
6
  end
7
7
 
8
8
  it 'should compile several statics into dynamic' do
9
- @filter.call([:multi,
9
+ expect(@filter.call([:multi,
10
10
  [:static, "Hello "],
11
11
  [:static, "World\n "],
12
12
  [:static, "Have a nice day"]
13
- ]).should.equal [:dynamic, '"Hello World\n Have a nice day"']
13
+ ])).to eq [:dynamic, '"Hello World\n Have a nice day"']
14
14
  end
15
15
 
16
16
  it 'should compile several dynamics into dynamic' do
17
- @filter.call([:multi,
17
+ expect(@filter.call([:multi,
18
18
  [:dynamic, "@hello"],
19
19
  [:dynamic, "@world"],
20
20
  [:dynamic, "@yeah"]
21
- ]).should.equal [:dynamic, '"#{@hello}#{@world}#{@yeah}"']
21
+ ])).to eq [:dynamic, '"#{@hello}#{@world}#{@yeah}"']
22
22
  end
23
23
 
24
24
  it 'should compile static and dynamic into dynamic' do
25
- @filter.call([:multi,
25
+ expect(@filter.call([:multi,
26
26
  [:static, "Hello"],
27
27
  [:dynamic, "@world"],
28
28
  [:dynamic, "@yeah"],
29
29
  [:static, "Nice"]
30
- ]).should.equal [:dynamic, '"Hello#{@world}#{@yeah}Nice"']
30
+ ])).to eq [:dynamic, '"Hello#{@world}#{@yeah}Nice"']
31
31
  end
32
32
 
33
33
  it 'should merge statics and dynamics around a code' do
34
- exp = @filter.call([:multi,
34
+ expect(@filter.call([:multi,
35
35
  [:static, "Hello "],
36
36
  [:dynamic, "@world"],
37
37
  [:code, "Oh yeah"],
38
38
  [:dynamic, "@yeah"],
39
39
  [:static, "Once more"]
40
- ]).should.equal [:multi,
40
+ ])).to eq [:multi,
41
41
  [:dynamic, '"Hello #{@world}"'],
42
42
  [:code, "Oh yeah"],
43
43
  [:dynamic, '"#{@yeah}Once more"']
@@ -45,19 +45,19 @@ describe Temple::Filters::DynamicInliner do
45
45
  end
46
46
 
47
47
  it 'should keep codes intact' do
48
- @filter.call([:multi, [:code, 'foo']]).should.equal [:code, 'foo']
48
+ expect(@filter.call([:multi, [:code, 'foo']])).to eq([:code, 'foo'])
49
49
  end
50
50
 
51
51
  it 'should keep single statics intact' do
52
- @filter.call([:multi, [:static, 'foo']]).should.equal [:static, 'foo']
52
+ expect(@filter.call([:multi, [:static, 'foo']])).to eq([:static, 'foo'])
53
53
  end
54
54
 
55
55
  it 'should keep single dynamic intact' do
56
- @filter.call([:multi, [:dynamic, 'foo']]).should.equal [:dynamic, 'foo']
56
+ expect(@filter.call([:multi, [:dynamic, 'foo']])).to eq([:dynamic, 'foo'])
57
57
  end
58
58
 
59
59
  it 'should inline inside multi' do
60
- @filter.call([:multi,
60
+ expect(@filter.call([:multi,
61
61
  [:static, "Hello "],
62
62
  [:dynamic, "@world"],
63
63
  [:multi,
@@ -65,7 +65,7 @@ describe Temple::Filters::DynamicInliner do
65
65
  [:dynamic, "@world"]],
66
66
  [:static, "Hello "],
67
67
  [:dynamic, "@world"]
68
- ]).should.equal [:multi,
68
+ ])).to eq [:multi,
69
69
  [:dynamic, '"Hello #{@world}"'],
70
70
  [:dynamic, '"Hello #{@world}"'],
71
71
  [:dynamic, '"Hello #{@world}"']
@@ -73,20 +73,20 @@ describe Temple::Filters::DynamicInliner do
73
73
  end
74
74
 
75
75
  it 'should merge across newlines' do
76
- exp = @filter.call([:multi,
76
+ exp = expect(@filter.call([:multi,
77
77
  [:static, "Hello \n"],
78
78
  [:newline],
79
79
  [:dynamic, "@world"],
80
80
  [:newline]
81
- ]).should.equal [:dynamic, ['"Hello \n"', '"#{@world}"', '""'].join("\\\n")]
81
+ ])).to eq [:dynamic, ['"Hello \n"', '"#{@world}"', '""'].join("\\\n")]
82
82
  end
83
83
 
84
84
  it 'should compile static followed by newline' do
85
- @filter.call([:multi,
85
+ expect(@filter.call([:multi,
86
86
  [:static, "Hello \n"],
87
87
  [:newline],
88
88
  [:code, "world"]
89
- ]).should.equal [:multi,
89
+ ])).to eq [:multi,
90
90
  [:static, "Hello \n"],
91
91
  [:newline],
92
92
  [:code, "world"]