temple 0.9.0 → 0.10.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +2 -8
  3. data/.gitignore +1 -0
  4. data/CHANGES +12 -0
  5. data/Gemfile +0 -1
  6. data/README.md +1 -1
  7. data/Rakefile +3 -11
  8. data/lib/temple/erb/engine.rb +2 -0
  9. data/lib/temple/erb/parser.rb +1 -1
  10. data/lib/temple/filters/string_splitter.rb +1 -1
  11. data/lib/temple/generator.rb +2 -2
  12. data/lib/temple/generators/rails_output_buffer.rb +6 -3
  13. data/lib/temple/templates/rails.rb +2 -2
  14. data/lib/temple/utils.rb +2 -1
  15. data/lib/temple/version.rb +1 -1
  16. data/spec/engine_spec.rb +189 -0
  17. data/{test/test_erb.rb → spec/erb_spec.rb} +11 -11
  18. data/spec/filter_spec.rb +29 -0
  19. data/{test/filters/test_code_merger.rb → spec/filters/code_merger_spec.rb} +7 -7
  20. data/{test/filters/test_control_flow.rb → spec/filters/control_flow_spec.rb} +13 -13
  21. data/{test/filters/test_dynamic_inliner.rb → spec/filters/dynamic_inliner_spec.rb} +18 -18
  22. data/{test/filters/test_eraser.rb → spec/filters/eraser_spec.rb} +9 -9
  23. data/{test/filters/test_escapable.rb → spec/filters/escapable_spec.rb} +10 -10
  24. data/{test/filters/test_multi_flattener.rb → spec/filters/multi_flattener_spec.rb} +4 -4
  25. data/{test/filters/test_static_analyzer.rb → spec/filters/static_analyzer_spec.rb} +6 -8
  26. data/{test/filters/test_static_merger.rb → spec/filters/static_merger_spec.rb} +7 -7
  27. data/{test/filters/test_string_splitter.rb → spec/filters/string_splitter_spec.rb} +5 -6
  28. data/spec/generator_spec.rb +158 -0
  29. data/spec/grammar_spec.rb +47 -0
  30. data/{test/html/test_attribute_merger.rb → spec/html/attribute_merger_spec.rb} +11 -11
  31. data/{test/html/test_attribute_remover.rb → spec/html/attribute_remover_spec.rb} +7 -7
  32. data/{test/html/test_attribute_sorter.rb → spec/html/attribute_sorter_spec.rb} +7 -7
  33. data/{test/html/test_fast.rb → spec/html/fast_spec.rb} +23 -23
  34. data/{test/html/test_pretty.rb → spec/html/pretty_spec.rb} +7 -7
  35. data/spec/map_spec.rb +39 -0
  36. data/{test/mixins/test_dispatcher.rb → spec/mixins/dispatcher_spec.rb} +12 -12
  37. data/{test/mixins/test_grammar_dsl.rb → spec/mixins/grammar_dsl_spec.rb} +19 -19
  38. data/{test/helper.rb → spec/spec_helper.rb} +3 -4
  39. data/{test/test_static_analyzer.rb → spec/static_analyzer_spec.rb} +6 -6
  40. data/spec/utils_spec.rb +39 -0
  41. data/temple.gemspec +1 -2
  42. metadata +29 -29
  43. data/test/test_engine.rb +0 -189
  44. data/test/test_filter.rb +0 -29
  45. data/test/test_generator.rb +0 -158
  46. data/test/test_grammar.rb +0 -47
  47. data/test/test_map.rb +0 -39
  48. 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: c7475d628203a95d9ec067ac1388f8428cb213f4534a2fd2ed1b9cf0be7d3293
4
+ data.tar.gz: d828006ab486aee65e70e8e321022d28191deba994d43c1141dccad2815f41f2
5
5
  SHA512:
6
- metadata.gz: 17e8c7410950492aa3fdc41cb91f1ad40613324a411d77fcded2667ecb6ac137956e4bee64a9d0b038bb7cd9dc1098ae9e095ca59ba2a4a370e7a7a3cd62a4bd
7
- data.tar.gz: 317d066d2e989072f0182d688845691573a74a31a7365883534c66571986bc2f0503df0a6a389d086cfba1eb0da69734a751a91691efa49772ebfb7a6c58f1b2
6
+ metadata.gz: d74cc956889989a4d65f6727d7f521cbcbf3d9c2de1a6abda92b4957a7e3992de2b7de6c7634b4dfafe9d4ce1a505f22b8f5af1ef9a217876d6d67f276e04557
7
+ data.tar.gz: 1958e441fbab605e06f560db0f4c26e5fecf7c673a12a5aad843a3bd5bb4c0ce77e3c2ea13f46b22d962770898587b7f76bd0ad2b11377898e61924e7bc20c87
@@ -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,15 @@
1
+ 0.10.0
2
+
3
+ * Regression: Revert changes to :capture_generator since 0.8.2 (#112, #113, #137)
4
+ * Regression: Ensure that output buffer is not reused for capturing in Rails (#135)
5
+ * Drop support for Rails 4.x
6
+
7
+ 0.9.1
8
+
9
+ * Fix Slim's error in AttributeMerger due to 0.9.0's :capture_generator (#137)
10
+ * Use specified :capture_generator for nested captures (#112)
11
+ * Fix Temple::ERB::Engine's <%= to not escape and <%== to escape expressions
12
+
1
13
  0.9.0
2
14
 
3
15
  * Require Ruby 2.5+ (#131)
data/Gemfile CHANGED
@@ -1,3 +1,2 @@
1
1
  source 'https://rubygems.org/'
2
2
  gemspec
3
- gem 'escape_utils' if ENV['ESCAPE_UTILS']
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'
@@ -7,6 +7,8 @@ module Temple
7
7
  use Temple::ERB::Parser
8
8
  use Temple::ERB::Trimming
9
9
  filter :Escapable
10
+ filter :StringSplitter
11
+ filter :StaticAnalyzer
10
12
  filter :MultiFlattener
11
13
  filter :StaticMerger
12
14
  generator :ArrayBuffer
@@ -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
@@ -7,7 +7,7 @@ module Temple
7
7
  module Filters
8
8
  # Compile [:dynamic, "foo#{bar}"] to [:multi, [:static, 'foo'], [:dynamic, 'bar']]
9
9
  class StringSplitter < Filter
10
- if defined?(Ripper) && RUBY_VERSION >= "2.0.0" && Ripper.respond_to?(:lex)
10
+ if defined?(Ripper) && Ripper.respond_to?(:lex)
11
11
  class << self
12
12
  # `code` param must be valid string literal
13
13
  def compile(code)
@@ -10,9 +10,9 @@ module Temple
10
10
  include Mixins::Options
11
11
 
12
12
  define_options :save_buffer,
13
- capture_generator: self,
13
+ capture_generator: 'StringBuffer',
14
14
  buffer: '_buf',
15
- freeze_static: RUBY_VERSION >= '2.1'
15
+ freeze_static: true
16
16
 
17
17
  def call(exp)
18
18
  [preamble, compile(exp), postamble].flatten.compact.join('; ')
@@ -9,10 +9,9 @@ module Temple
9
9
  #
10
10
  # @api public
11
11
  class RailsOutputBuffer < StringBuffer
12
- define_options :streaming,
12
+ define_options :streaming, # ignored
13
13
  buffer_class: 'ActionView::OutputBuffer',
14
14
  buffer: '@output_buffer',
15
- # output_buffer is needed for Rails 3.1 Streaming support
16
15
  capture_generator: RailsOutputBuffer
17
16
 
18
17
  def call(exp)
@@ -20,7 +19,11 @@ module Temple
20
19
  end
21
20
 
22
21
  def create_buffer
23
- "#{buffer} = output_buffer || #{options[:buffer_class]}.new"
22
+ if buffer == '@output_buffer'
23
+ "#{buffer} = output_buffer || #{options[:buffer_class]}.new"
24
+ else
25
+ "#{buffer} = #{options[:buffer_class]}.new"
26
+ end
24
27
  end
25
28
 
26
29
  def concat(str)
@@ -18,8 +18,8 @@ module Temple
18
18
 
19
19
  def self.register_as(*names)
20
20
  raise 'Rails is not loaded - Temple::Templates::Rails cannot be used' unless defined?(::ActionView)
21
- if ::ActiveSupport::VERSION::MAJOR < 3 || ::ActiveSupport::VERSION::MAJOR == 3 && ::ActiveSupport::VERSION::MINOR < 1
22
- raise "Temple supports only Rails 3.1 and greater, your Rails version is #{::ActiveSupport::VERSION::STRING}"
21
+ if ::ActiveSupport::VERSION::MAJOR < 5
22
+ raise "Temple supports only Rails 5 and greater, your Rails version is #{::ActiveSupport::VERSION::STRING}"
23
23
  end
24
24
  names.each do |name|
25
25
  ::ActionView::Template.register_template_handler name.to_sym, new
data/lib/temple/utils.rb CHANGED
@@ -14,7 +14,8 @@ module Temple
14
14
  # @param html [String] The string to escape
15
15
  # @return [String] The escaped string
16
16
  def escape_html_safe(html)
17
- html.html_safe? ? html : escape_html(html)
17
+ s = html.to_s
18
+ s.html_safe? || html.html_safe? ? s : escape_html(s)
18
19
  end
19
20
 
20
21
  if defined?(CGI.escapeHTML)
@@ -1,3 +1,3 @@
1
1
  module Temple
2
- VERSION = '0.9.0'
2
+ VERSION = '0.10.0'
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],