flavour_saver 0.3.7 → 2.0.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 +5 -5
- data/.github/workflows/ci.yml +47 -0
- data/CHANGELOG.md +40 -0
- data/Gemfile.lock +34 -62
- data/README.md +34 -11
- data/flavour_saver.gemspec +14 -9
- data/lib/flavour_saver/helpers.rb +28 -13
- data/lib/flavour_saver/lexer.rb +19 -6
- data/lib/flavour_saver/nodes.rb +1 -1
- data/lib/flavour_saver/parser.rb +8 -7
- data/lib/flavour_saver/runtime.rb +8 -8
- data/lib/flavour_saver/version.rb +1 -1
- data/spec/acceptance/backtrack_spec.rb +1 -1
- data/spec/acceptance/comment_spec.rb +1 -1
- data/spec/acceptance/custom_block_helper_spec.rb +2 -2
- data/spec/acceptance/custom_helper_spec.rb +1 -1
- data/spec/acceptance/ensure_no_rce_spec.rb +2 -2
- data/spec/acceptance/handlebars_qunit_spec.rb +299 -214
- data/spec/acceptance/if_else_spec.rb +37 -6
- data/spec/acceptance/multi_level_with_spec.rb +1 -1
- data/spec/acceptance/one_character_identifier_spec.rb +2 -2
- data/spec/acceptance/raw_block_spec.rb +1 -1
- data/spec/acceptance/runtime_run_spec.rb +1 -1
- data/spec/acceptance/sections_spec.rb +3 -3
- data/spec/acceptance/segment_literals_spec.rb +3 -3
- data/spec/acceptance/simple_expression_spec.rb +3 -3
- data/spec/acceptance/subexpression_spec.rb +37 -0
- data/spec/acceptance/unless_spec.rb +48 -0
- data/spec/fixtures/if_else.hbs +3 -3
- data/spec/fixtures/unless.hbs +5 -0
- data/spec/lib/flavour_saver/lexer_spec.rb +104 -28
- data/spec/lib/flavour_saver/parser_spec.rb +115 -82
- data/spec/lib/flavour_saver/runtime_spec.rb +44 -33
- metadata +27 -72
- data/.travis.yml +0 -14
- data/Guardfile +0 -12
@@ -3,15 +3,46 @@ require 'flavour_saver'
|
|
3
3
|
|
4
4
|
describe 'Fixture: if_else.hbs' do
|
5
5
|
subject { Tilt.new(template).render(context).gsub(/[\s\r\n]+/, ' ').strip }
|
6
|
-
let(:context) { Struct.new(:
|
6
|
+
let(:context) { Struct.new(:value).new }
|
7
7
|
let(:template) { File.expand_path('../../fixtures/if_else.hbs', __FILE__) }
|
8
8
|
|
9
|
-
it
|
10
|
-
context.
|
11
|
-
subject.
|
9
|
+
it "renders the if block when given a string" do
|
10
|
+
context.value = "Alan"
|
11
|
+
expect(subject).to eq "The given value is truthy: Alan."
|
12
12
|
end
|
13
13
|
|
14
|
-
it
|
15
|
-
|
14
|
+
it "renders the if block when given a number greater than zero" do
|
15
|
+
context.value = 1
|
16
|
+
expect(subject).to eq "The given value is truthy: 1."
|
17
|
+
end
|
18
|
+
|
19
|
+
it "renders the if block when given an array that is not empty" do
|
20
|
+
context.value = [1]
|
21
|
+
expect(subject).to eq "The given value is truthy: [1]."
|
22
|
+
end
|
23
|
+
|
24
|
+
it "renders the else block when given false" do
|
25
|
+
context.value = false
|
26
|
+
expect(subject).to eq "The given value is falsy: false."
|
27
|
+
end
|
28
|
+
|
29
|
+
it 'renders the else block when given nil' do
|
30
|
+
context.value = nil
|
31
|
+
expect(subject).to eq "The given value is falsy: ."
|
32
|
+
end
|
33
|
+
|
34
|
+
it "renders the else block when given an empty string" do
|
35
|
+
context.value = ""
|
36
|
+
expect(subject).to eq "The given value is falsy: ."
|
37
|
+
end
|
38
|
+
|
39
|
+
it "renders the else block when given a zero" do
|
40
|
+
context.value = 0
|
41
|
+
expect(subject).to eq "The given value is falsy: 0."
|
42
|
+
end
|
43
|
+
|
44
|
+
it "renders the else block when given an empty array" do
|
45
|
+
context.value = []
|
46
|
+
expect(subject).to eq "The given value is falsy: []."
|
16
47
|
end
|
17
48
|
end
|
@@ -9,7 +9,7 @@ describe 'Fixture: multi_level_with.hbs' do
|
|
9
9
|
it 'renders correctly when person has a name' do
|
10
10
|
context.person = Struct.new(:name).new('Alan')
|
11
11
|
context.company = Struct.new(:name).new('Rad, Inc.')
|
12
|
-
subject.
|
12
|
+
expect(subject).to eq 'Alan - Rad, Inc.'
|
13
13
|
end
|
14
14
|
|
15
15
|
end
|
@@ -7,7 +7,7 @@ describe 'Fixture: one_character_identifier.hbs' do
|
|
7
7
|
let(:context) { double(:context) }
|
8
8
|
|
9
9
|
it 'renders correctly' do
|
10
|
-
context.
|
11
|
-
subject.
|
10
|
+
expect(context).to receive(:a).and_return('foo')
|
11
|
+
expect(subject).to eq "foo"
|
12
12
|
end
|
13
13
|
end
|
@@ -8,18 +8,18 @@ describe 'Fixture: sections.hbs' do
|
|
8
8
|
|
9
9
|
it 'renders correctly when given a name' do
|
10
10
|
context.name = 'Alan'
|
11
|
-
subject.
|
11
|
+
expect(subject).to eq "Say hello to Alan."
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'renders correctly when given a list of names' do
|
15
15
|
context.names = ['Foo', 'Bar']
|
16
|
-
subject.
|
16
|
+
expect(subject).to eq "* Foo * Bar"
|
17
17
|
end
|
18
18
|
|
19
19
|
it 'renders correctly when given an order' do
|
20
20
|
class Order; def number; 1234; end; end
|
21
21
|
context.order = Order.new
|
22
|
-
subject.
|
22
|
+
expect(subject).to eq 'Number: 1234'
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
@@ -17,10 +17,10 @@ describe FlavourSaver do
|
|
17
17
|
foos = []
|
18
18
|
foos << double(:foo)
|
19
19
|
foos << double(:foo)
|
20
|
-
foos[1].
|
20
|
+
expect(foos[1]).to receive(:bar).and_return('two')
|
21
21
|
|
22
|
-
context.
|
23
|
-
subject.
|
22
|
+
allow(context).to receive(:foos).and_return(foos)
|
23
|
+
expect(subject).to eq 'two'
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -7,11 +7,11 @@ describe 'Fixture: simple_expression.hbs' do
|
|
7
7
|
let(:context) { double(:context) }
|
8
8
|
|
9
9
|
it 'renders correctly' do
|
10
|
-
context.
|
11
|
-
subject.
|
10
|
+
expect(context).to receive(:hello).and_return('hello world')
|
11
|
+
expect(subject).to eq "hello world"
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'renders nothing if undefined' do
|
15
|
-
subject.
|
15
|
+
expect(subject).to eq ""
|
16
16
|
end
|
17
17
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'flavour_saver'
|
3
|
+
|
4
|
+
describe 'Subexpressions' do
|
5
|
+
|
6
|
+
subject { Tilt['handlebars'].new{ template }.render(context).gsub(/[\s\r\n]+/, ' ').strip }
|
7
|
+
|
8
|
+
let(:context) { double(:context) }
|
9
|
+
before(:all) do
|
10
|
+
FlavourSaver.register_helper(:sum) { |a,b| a + b}
|
11
|
+
end
|
12
|
+
context "simple subexpression" do
|
13
|
+
let(:template) { "{{sum 1 (sum 1 1)}}" }
|
14
|
+
specify{expect(subject).to eq "3"}
|
15
|
+
end
|
16
|
+
|
17
|
+
context "nested subexpressions" do
|
18
|
+
let(:template) { "{{sum 1 (sum 1 (sum 1 1))}}" }
|
19
|
+
specify{expect(subject).to eq "4"}
|
20
|
+
end
|
21
|
+
|
22
|
+
context "subexpression as argument" do
|
23
|
+
before {FlavourSaver.register_helper(:cents) { |a| a[:total] + 10}}
|
24
|
+
let(:template) { "{{cents total=(sum 1 1)}}" }
|
25
|
+
specify{expect(subject).to eq "12"}
|
26
|
+
end
|
27
|
+
|
28
|
+
context "subexpression in block" do
|
29
|
+
before {FlavourSaver.register_helper(:repeat) do |a, &block|
|
30
|
+
s = ''
|
31
|
+
a.times {s += block.call.contents}
|
32
|
+
s
|
33
|
+
end}
|
34
|
+
let(:template) { "{{#repeat (sum 1 2)}}*{{/repeat}}" }
|
35
|
+
specify{expect(subject).to eq "***"}
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
require 'tilt'
|
2
|
+
require 'flavour_saver'
|
3
|
+
|
4
|
+
describe 'Fixture: unless.hbs' do
|
5
|
+
subject { Tilt.new(template).render(context).gsub(/[\s\r\n]+/, ' ').strip }
|
6
|
+
let(:context) { Struct.new(:value).new }
|
7
|
+
let(:template) { File.expand_path('../../fixtures/unless.hbs', __FILE__) }
|
8
|
+
|
9
|
+
it "renders the unless block when given false" do
|
10
|
+
context.value = false
|
11
|
+
expect(subject).to eq "The given value is falsy: false."
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'renders the unless block when given nil' do
|
15
|
+
context.value = nil
|
16
|
+
expect(subject).to eq "The given value is falsy: ."
|
17
|
+
end
|
18
|
+
|
19
|
+
it "renders the unless block when given an empty string" do
|
20
|
+
context.value = ""
|
21
|
+
expect(subject).to eq "The given value is falsy: ."
|
22
|
+
end
|
23
|
+
|
24
|
+
it "renders the unless block when given a zero" do
|
25
|
+
context.value = 0
|
26
|
+
expect(subject).to eq "The given value is falsy: 0."
|
27
|
+
end
|
28
|
+
|
29
|
+
it "renders the unless block when given an empty array" do
|
30
|
+
context.value = []
|
31
|
+
expect(subject).to eq "The given value is falsy: []."
|
32
|
+
end
|
33
|
+
|
34
|
+
it "renders the else block when given a string" do
|
35
|
+
context.value = "Alan"
|
36
|
+
expect(subject).to eq "The given value is truthy: Alan."
|
37
|
+
end
|
38
|
+
|
39
|
+
it "renders the else block when given a number greater than zero" do
|
40
|
+
context.value = 1
|
41
|
+
expect(subject).to eq "The given value is truthy: 1."
|
42
|
+
end
|
43
|
+
|
44
|
+
it "renders the else block when given an array that is not empty" do
|
45
|
+
context.value = [1]
|
46
|
+
expect(subject).to eq "The given value is truthy: [1]."
|
47
|
+
end
|
48
|
+
end
|
data/spec/fixtures/if_else.hbs
CHANGED
@@ -2,7 +2,7 @@ require 'flavour_saver/lexer'
|
|
2
2
|
|
3
3
|
describe FlavourSaver::Lexer do
|
4
4
|
it 'is an RLTK lexer' do
|
5
|
-
subject.
|
5
|
+
expect(subject).to be_a(RLTK::Lexer)
|
6
6
|
end
|
7
7
|
|
8
8
|
describe 'Tokens' do
|
@@ -11,17 +11,17 @@ describe FlavourSaver::Lexer do
|
|
11
11
|
subject { FlavourSaver::Lexer.lex "{{foo}}" }
|
12
12
|
|
13
13
|
it 'begins with an EXPRST' do
|
14
|
-
subject.first.type.
|
14
|
+
expect(subject.first.type).to eq :EXPRST
|
15
15
|
end
|
16
16
|
|
17
17
|
it 'ends with an EXPRE' do
|
18
|
-
subject[-2].type.
|
18
|
+
expect(subject[-2].type).to eq :EXPRE
|
19
19
|
end
|
20
20
|
|
21
21
|
it 'contains only the identifier "foo"' do
|
22
|
-
subject[1..-3].size.
|
23
|
-
subject[1].type.
|
24
|
-
subject[1].value.
|
22
|
+
expect(subject[1..-3].size).to eq 1
|
23
|
+
expect(subject[1].type).to eq :IDENT
|
24
|
+
expect(subject[1].value).to eq 'foo'
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -29,11 +29,11 @@ describe FlavourSaver::Lexer do
|
|
29
29
|
subject { FlavourSaver::Lexer.lex "{{foo bar}}" }
|
30
30
|
|
31
31
|
it 'has tokens in the correct order' do
|
32
|
-
subject.map(&:type).
|
32
|
+
expect(subject.map(&:type)).to eq [ :EXPRST, :IDENT, :WHITE, :IDENT, :EXPRE, :EOS ]
|
33
33
|
end
|
34
34
|
|
35
35
|
it 'has values in the correct order' do
|
36
|
-
subject.map(&:value).compact.
|
36
|
+
expect(subject.map(&:value).compact).to eq [ 'foo', 'bar' ]
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -41,11 +41,23 @@ describe FlavourSaver::Lexer do
|
|
41
41
|
subject { FlavourSaver::Lexer.lex "{{foo \"bar\"}}" }
|
42
42
|
|
43
43
|
it 'has tokens in the correct order' do
|
44
|
-
subject.map(&:type).
|
44
|
+
expect(subject.map(&:type)).to eq [ :EXPRST, :IDENT, :WHITE, :STRING, :EXPRE, :EOS ]
|
45
45
|
end
|
46
46
|
|
47
47
|
it 'has values in the correct order' do
|
48
|
-
subject.map(&:value).compact.
|
48
|
+
expect(subject.map(&:value).compact).to eq [ 'foo', 'bar' ]
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe '{{foo (bar "baz")}}' do
|
53
|
+
subject { FlavourSaver::Lexer.lex "{{foo (bar 'baz')}}" }
|
54
|
+
|
55
|
+
it 'has tokens in the correct order' do
|
56
|
+
expect(subject.map(&:type)).to eq [ :EXPRST, :IDENT, :WHITE, :OPAR, :IDENT, :WHITE, :S_STRING, :CPAR, :EXPRE, :EOS ]
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'has values in the correct order' do
|
60
|
+
expect(subject.map(&:value).compact).to eq [ 'foo', 'bar', 'baz' ]
|
49
61
|
end
|
50
62
|
end
|
51
63
|
|
@@ -53,13 +65,77 @@ describe FlavourSaver::Lexer do
|
|
53
65
|
subject { FlavourSaver::Lexer.lex '{{foo bar="baz" hello="goodbye"}}' }
|
54
66
|
|
55
67
|
it 'has tokens in the correct order' do
|
56
|
-
subject.map(&:type).
|
68
|
+
expect(subject.map(&:type)).to eq [ :EXPRST, :IDENT, :WHITE, :IDENT, :EQ, :STRING, :WHITE, :IDENT, :EQ, :STRING, :EXPRE, :EOS ]
|
57
69
|
end
|
58
70
|
|
59
71
|
it 'has values in the correct order' do
|
60
|
-
subject.map(&:value).compact.
|
72
|
+
expect(subject.map(&:value).compact).to eq [ 'foo', 'bar', 'baz', 'hello', 'goodbye' ]
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
describe '{{0}}' do
|
77
|
+
subject { FlavourSaver::Lexer.lex "{{0}}" }
|
78
|
+
|
79
|
+
it 'properly lexes the expression' do
|
80
|
+
expect(subject.map(&:type)).to eq(
|
81
|
+
[:EXPRST, :NUMBER, :EXPRE, :EOS]
|
82
|
+
)
|
83
|
+
end
|
84
|
+
|
85
|
+
it 'contains only the number "0"' do
|
86
|
+
expect(subject[1..-3].size).to eq 1
|
87
|
+
expect(subject[1].type).to eq :NUMBER
|
88
|
+
expect(subject[1].value).to eq '0'
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
describe '{{0.0123456789}}' do
|
93
|
+
subject { FlavourSaver::Lexer.lex "{{0.0123456789}}" }
|
94
|
+
|
95
|
+
it 'properly lexes the expression' do
|
96
|
+
expect(subject.map(&:type)).to eq(
|
97
|
+
[:EXPRST, :NUMBER, :EXPRE, :EOS]
|
98
|
+
)
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'contains only the number "0.0123456789"' do
|
102
|
+
expect(subject[1..-3].size).to eq 1
|
103
|
+
expect(subject[1].type).to eq :NUMBER
|
104
|
+
expect(subject[1].value).to eq '0.0123456789'
|
61
105
|
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
describe 'Identities' do
|
110
|
+
|
111
|
+
it 'supports as ruby methods' do
|
112
|
+
ids = %w( _ __ __123__ __ABC__ ABC123 Abc134def )
|
113
|
+
ids.each do |id|
|
114
|
+
subject = FlavourSaver::Lexer.lex "{{#{id}}}"
|
115
|
+
expect(subject[1].type).to eq :IDENT
|
116
|
+
expect(subject[1].value).to eq id
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
it 'maps non-ruby identities to literals' do
|
121
|
+
ids = %w( A-B 12_Mine - :example 0A test? )
|
122
|
+
ids.each do |id|
|
123
|
+
subject = FlavourSaver::Lexer.lex "{{#{id}}}"
|
124
|
+
expect(subject[1].type).to eq :LITERAL
|
125
|
+
expect(subject[1].value).to eq id
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
describe '{{foo bar=(baz qux)}}' do
|
131
|
+
subject { FlavourSaver::Lexer.lex '{{foo bar=(baz qux)}}' }
|
132
|
+
|
133
|
+
it 'has tokens in the correct order' do
|
134
|
+
expect(subject.map(&:type)).to eq [:EXPRST, :IDENT, :WHITE, :IDENT, :EQ, :OPAR, :IDENT, :WHITE, :IDENT, :CPAR, :EXPRE, :EOS]
|
135
|
+
end
|
62
136
|
|
137
|
+
it 'has values in the correct order' do
|
138
|
+
expect(subject.map(&:value).compact).to eq [ 'foo', 'bar', 'baz', 'qux' ]
|
63
139
|
end
|
64
140
|
end
|
65
141
|
|
@@ -67,7 +143,7 @@ describe FlavourSaver::Lexer do
|
|
67
143
|
subject { FlavourSaver::Lexer.lex '{{else}}' }
|
68
144
|
|
69
145
|
it 'has tokens in the correct order' do
|
70
|
-
subject.map(&:type).
|
146
|
+
expect(subject.map(&:type)).to eq [ :EXPRST, :ELSE, :EXPRE, :EOS ]
|
71
147
|
end
|
72
148
|
end
|
73
149
|
|
@@ -76,11 +152,11 @@ describe FlavourSaver::Lexer do
|
|
76
152
|
subject { FlavourSaver::Lexer.lex "{{foo.bar}}" }
|
77
153
|
|
78
154
|
it 'has tokens in the correct order' do
|
79
|
-
subject.map(&:type).
|
155
|
+
expect(subject.map(&:type)).to eq [ :EXPRST, :IDENT, :DOT, :IDENT, :EXPRE, :EOS ]
|
80
156
|
end
|
81
157
|
|
82
158
|
it 'has the correct values' do
|
83
|
-
subject.map(&:value).compact.
|
159
|
+
expect(subject.map(&:value).compact).to eq ['foo', 'bar']
|
84
160
|
end
|
85
161
|
end
|
86
162
|
|
@@ -88,11 +164,11 @@ describe FlavourSaver::Lexer do
|
|
88
164
|
subject { FlavourSaver::Lexer.lex "{{foo.[10].bar}}" }
|
89
165
|
|
90
166
|
it 'has tokens in the correct order' do
|
91
|
-
subject.map(&:type).
|
167
|
+
expect(subject.map(&:type)).to eq [ :EXPRST, :IDENT, :DOT, :LITERAL, :DOT, :IDENT, :EXPRE, :EOS ]
|
92
168
|
end
|
93
169
|
|
94
170
|
it 'has the correct values' do
|
95
|
-
subject.map(&:value).compact.
|
171
|
+
expect(subject.map(&:value).compact).to eq ['foo', '10', 'bar']
|
96
172
|
end
|
97
173
|
end
|
98
174
|
|
@@ -100,11 +176,11 @@ describe FlavourSaver::Lexer do
|
|
100
176
|
subject { FlavourSaver::Lexer.lex '{{foo.[he!@#$(&@klA)].bar}}' }
|
101
177
|
|
102
178
|
it 'has tokens in the correct order' do
|
103
|
-
subject.map(&:type).
|
179
|
+
expect(subject.map(&:type)).to eq [ :EXPRST, :IDENT, :DOT, :LITERAL, :DOT, :IDENT, :EXPRE, :EOS ]
|
104
180
|
end
|
105
181
|
|
106
182
|
it 'has the correct values' do
|
107
|
-
subject.map(&:value).compact.
|
183
|
+
expect(subject.map(&:value).compact).to eq ['foo', 'he!@#$(&@klA)', 'bar']
|
108
184
|
end
|
109
185
|
end
|
110
186
|
end
|
@@ -113,7 +189,7 @@ describe FlavourSaver::Lexer do
|
|
113
189
|
subject { FlavourSaver::Lexer.lex "{{{foo}}}" }
|
114
190
|
|
115
191
|
it 'has tokens in the correct order' do
|
116
|
-
subject.map(&:type).
|
192
|
+
expect(subject.map(&:type)).to eq [ :TEXPRST, :IDENT, :TEXPRE, :EOS ]
|
117
193
|
end
|
118
194
|
end
|
119
195
|
|
@@ -121,7 +197,7 @@ describe FlavourSaver::Lexer do
|
|
121
197
|
subject { FlavourSaver::Lexer.lex "{{! WAT}}" }
|
122
198
|
|
123
199
|
it 'has tokens in the correct order' do
|
124
|
-
subject.map(&:type).
|
200
|
+
expect(subject.map(&:type)).to eq [ :EXPRST, :BANG, :COMMENT, :EXPRE, :EOS ]
|
125
201
|
end
|
126
202
|
end
|
127
203
|
|
@@ -129,7 +205,7 @@ describe FlavourSaver::Lexer do
|
|
129
205
|
subject { FlavourSaver::Lexer.lex "{{../foo}}" }
|
130
206
|
|
131
207
|
it 'has tokens in the correct order' do
|
132
|
-
subject.map(&:type).
|
208
|
+
expect(subject.map(&:type)).to eq [:EXPRST, :DOT, :DOT, :FWSL, :IDENT, :EXPRE, :EOS]
|
133
209
|
end
|
134
210
|
end
|
135
211
|
|
@@ -137,7 +213,7 @@ describe FlavourSaver::Lexer do
|
|
137
213
|
subject { FlavourSaver::Lexer.lex "{{foo}}\n{{bar}}\r{{baz}}" }
|
138
214
|
|
139
215
|
it 'has tokens in the correct order' do
|
140
|
-
subject.map(&:type).
|
216
|
+
expect(subject.map(&:type)).to eq [:EXPRST,:IDENT,:EXPRE,:OUT,:EXPRST,:IDENT,:EXPRE,:OUT,:EXPRST,:IDENT,:EXPRE,:EOS]
|
141
217
|
end
|
142
218
|
end
|
143
219
|
|
@@ -146,7 +222,7 @@ describe FlavourSaver::Lexer do
|
|
146
222
|
|
147
223
|
describe '{{#foo}}{{bar}}{{/foo}}' do
|
148
224
|
it 'has tokens in the correct order' do
|
149
|
-
subject.map(&:type).
|
225
|
+
expect(subject.map(&:type)).to eq [
|
150
226
|
:EXPRST, :HASH, :IDENT, :EXPRE,
|
151
227
|
:EXPRST, :IDENT, :EXPRE,
|
152
228
|
:EXPRST, :FWSL, :IDENT, :EXPRE,
|
@@ -155,7 +231,7 @@ describe FlavourSaver::Lexer do
|
|
155
231
|
end
|
156
232
|
|
157
233
|
it 'has identifiers in the correct order' do
|
158
|
-
subject.map(&:value).compact.
|
234
|
+
expect(subject.map(&:value).compact).to eq [ 'foo', 'bar', 'foo' ]
|
159
235
|
end
|
160
236
|
end
|
161
237
|
end
|
@@ -164,7 +240,7 @@ describe FlavourSaver::Lexer do
|
|
164
240
|
subject { FlavourSaver::Lexer.lex "\r" }
|
165
241
|
|
166
242
|
it 'has tokens in the correct order' do
|
167
|
-
subject.map(&:type).
|
243
|
+
expect(subject.map(&:type)).to eq [:OUT,:EOS]
|
168
244
|
end
|
169
245
|
end
|
170
246
|
|
@@ -172,7 +248,7 @@ describe FlavourSaver::Lexer do
|
|
172
248
|
subject { FlavourSaver::Lexer.lex "\n" }
|
173
249
|
|
174
250
|
it 'has tokens in the correct order' do
|
175
|
-
subject.map(&:type).
|
251
|
+
expect(subject.map(&:type)).to eq [:OUT,:EOS]
|
176
252
|
end
|
177
253
|
end
|
178
254
|
|
@@ -180,7 +256,7 @@ describe FlavourSaver::Lexer do
|
|
180
256
|
subject { FlavourSaver::Lexer.lex "{" }
|
181
257
|
|
182
258
|
it 'has tokens in the correct order' do
|
183
|
-
subject.map(&:type).
|
259
|
+
expect(subject.map(&:type)).to eq [:OUT,:EOS]
|
184
260
|
end
|
185
261
|
end
|
186
262
|
end
|