curlybars 1.2.0 → 1.2.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7aaafd32b96d9cdf8e9af98ebe3636fc14d4df85761eea4ac804d4b623e1d186
4
- data.tar.gz: f177926ffc2cf7c9026a15f6ba7f43089cc9bab4da6e3318ab29a38003f4afdd
3
+ metadata.gz: 0fbfe78e305b68cad9c83ab0deafe39a1814b519ede424de8459dfe8f096bee1
4
+ data.tar.gz: 7fb5ee604e9379a73ef24cd607aea3a847656a3ecc6f3fddbedd0c4031b398fc
5
5
  SHA512:
6
- metadata.gz: 25125dc3e0887ee7878a09f29e96c56f6d863d4aea21cb4c37e226d032cd9b5006c6a512837a9893b95188308d72de426673c8d8815c6d942bdad1ca60032403
7
- data.tar.gz: 2cc5791470872a77703979523e3de41a0db3491b8dd453628dc2c68ffe00dbef6374db91feb2da56ddae6edf75d5e6c21c5da3947048a3e320eb67da4d6a10c6
6
+ metadata.gz: 1f3d779a0858270de68a2715f6badb08290cf977ad792ea019ee8d5b6f20ecc837371129d98a97f2a118df2edff352ec41d71023b4789b05321315fac5847526
7
+ data.tar.gz: baeb86fd6563d5baca979bcc6cdd08f3a3a66b75bc29692fcbf366b7b3518725e2bd1fbdd6afa6b66567d95436f6d2d241c3d4c1cb81c6315a337df0aa9fc0aa
@@ -15,9 +15,9 @@ module Curlybars
15
15
  end
16
16
 
17
17
  def validate(branches)
18
- catch(:skip_item_validation) do
19
- item.validate(branches)
20
- end
18
+ item.validate(branches)
19
+ rescue Curlybars::Error::Validate => path_error
20
+ path_error
21
21
  end
22
22
 
23
23
  def cache_key
@@ -60,10 +60,10 @@ module Curlybars
60
60
  path_split_by_slashes = path.split('/')
61
61
  backward_steps_on_branches = path_split_by_slashes.count - 1
62
62
  base_tree_position = branches.length - backward_steps_on_branches
63
+ base_tree_index = base_tree_position - 1
63
64
 
64
- throw :skip_item_validation unless base_tree_position > 0
65
+ raise Curlybars::Error::Validate.new('unallowed_path', "'#{path}' goes out of scope", position) if base_tree_index < 0
65
66
 
66
- base_tree_index = base_tree_position - 1
67
67
  base_tree = branches[base_tree_index]
68
68
 
69
69
  dotted_path_side = path_split_by_slashes.last
@@ -1,3 +1,3 @@
1
1
  module Curlybars
2
- VERSION = '1.2.0'.freeze
2
+ VERSION = '1.2.1'.freeze
3
3
  end
@@ -137,5 +137,36 @@ describe "{{#if}}...{{else}}...{{/if}}" do
137
137
 
138
138
  expect(errors).not_to be_empty
139
139
  end
140
+
141
+ it "validates errors the nested else_template when out of context" do
142
+ dependency_tree = { condition: nil }
143
+
144
+ source = <<-HBS
145
+ {{#if ../condition}}
146
+ {{else}}
147
+ {{unallowed_ELSE_method}}
148
+ {{/if}}
149
+ HBS
150
+
151
+ errors = Curlybars.validate(dependency_tree, source)
152
+
153
+ expect(errors.count).to eq(2)
154
+ end
155
+
156
+ it "gives all possible errors found in validation" do
157
+ dependency_tree = { condition: nil }
158
+
159
+ source = <<-HBS
160
+ {{#if ../condition}}
161
+ {{unallowed_IF_method}}
162
+ {{else}}
163
+ {{unallowed_ELSE_method}}
164
+ {{/if}}
165
+ HBS
166
+
167
+ errors = Curlybars.validate(dependency_tree, source)
168
+
169
+ expect(errors.count).to eq(3)
170
+ end
140
171
  end
141
172
  end
@@ -139,7 +139,7 @@ describe "{{path}}" do
139
139
  expect(errors).to be_empty
140
140
  end
141
141
 
142
- it "without errors when it goes out of context" do
142
+ it "gives errors errors when it goes out of context" do
143
143
  dependency_tree = {}
144
144
 
145
145
  source = <<-HBS
@@ -148,7 +148,7 @@ describe "{{path}}" do
148
148
 
149
149
  errors = Curlybars.validate(dependency_tree, source)
150
150
 
151
- expect(errors).to be_empty
151
+ expect(errors).not_to be_empty
152
152
  end
153
153
 
154
154
  it "without errors using `this`" do
@@ -257,6 +257,18 @@ describe "{{path}}" do
257
257
  end
258
258
  end
259
259
 
260
+ it "with errors when going outside of scope" do
261
+ dependency_tree = { ok: { ok: { ok: nil } } }
262
+
263
+ source = <<~HBS
264
+ {{../ok.ok.ok}}
265
+ HBS
266
+
267
+ errors = Curlybars.validate(dependency_tree, source)
268
+
269
+ expect(errors.first.message).to eq("'../ok.ok.ok' goes out of scope")
270
+ end
271
+
260
272
  describe "raises exact location of unallowed steps" do
261
273
  let(:dependency_tree) { { ok: { allowed: { ok: nil } } } }
262
274
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: curlybars
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Libo Cannici
@@ -13,7 +13,7 @@ authors:
13
13
  autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
- date: 2019-03-15 00:00:00.000000000 Z
16
+ date: 2019-11-14 00:00:00.000000000 Z
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency
19
19
  name: actionpack
@@ -292,8 +292,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
292
292
  - !ruby/object:Gem::Version
293
293
  version: '0'
294
294
  requirements: []
295
- rubyforge_project:
296
- rubygems_version: 2.7.6
295
+ rubygems_version: 3.0.6
297
296
  signing_key:
298
297
  specification_version: 4
299
298
  summary: Create your views using Handlebars templates!