volt 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Readme.md +47 -40
- data/VERSION +1 -1
- data/app/volt/controllers/notices_controller.rb +3 -3
- data/app/volt/tasks/live_query/data_store.rb +2 -2
- data/app/volt/tasks/live_query/live_query.rb +20 -20
- data/app/volt/tasks/live_query/live_query_pool.rb +6 -6
- data/app/volt/tasks/live_query/query_tracker.rb +15 -15
- data/app/volt/tasks/query_tasks.rb +13 -13
- data/app/volt/tasks/store_tasks.rb +7 -7
- data/app/volt/views/notices/index.html +17 -18
- data/lib/volt/assets/test.rb +2 -2
- data/lib/volt/benchmark/benchmark.rb +25 -23
- data/lib/volt/cli/asset_compile.rb +11 -0
- data/lib/volt/cli/new_gem.rb +16 -16
- data/lib/volt/cli.rb +14 -12
- data/lib/volt/console.rb +5 -6
- data/lib/volt/controllers/model_controller.rb +18 -18
- data/lib/volt/extra_core/array.rb +4 -4
- data/lib/volt/extra_core/hash.rb +3 -3
- data/lib/volt/extra_core/object.rb +6 -6
- data/lib/volt/extra_core/string.rb +6 -6
- data/lib/volt/extra_core/symbol.rb +5 -5
- data/lib/volt/extra_core/time.rb +4 -4
- data/lib/volt/extra_core/true_false.rb +6 -6
- data/lib/volt/extra_core/try.rb +9 -9
- data/lib/volt/models/array_model.rb +26 -26
- data/lib/volt/models/model.rb +35 -35
- data/lib/volt/models/model_hash_behaviour.rb +15 -15
- data/lib/volt/models/model_helpers.rb +8 -8
- data/lib/volt/models/model_wrapper.rb +6 -6
- data/lib/volt/models/persistors/array_store.rb +36 -36
- data/lib/volt/models/persistors/base.rb +6 -6
- data/lib/volt/models/persistors/flash.rb +5 -5
- data/lib/volt/models/persistors/model_identity_map.rb +2 -2
- data/lib/volt/models/persistors/model_store.rb +22 -22
- data/lib/volt/models/persistors/params.rb +3 -3
- data/lib/volt/models/persistors/query/query_listener.rb +14 -14
- data/lib/volt/models/persistors/query/query_listener_pool.rb +2 -2
- data/lib/volt/models/persistors/store.rb +8 -8
- data/lib/volt/models/persistors/store_factory.rb +2 -2
- data/lib/volt/models/url.rb +37 -37
- data/lib/volt/page/bindings/attribute_binding.rb +14 -14
- data/lib/volt/page/bindings/base_binding.rb +9 -9
- data/lib/volt/page/bindings/component_binding.rb +7 -7
- data/lib/volt/page/bindings/content_binding.rb +3 -3
- data/lib/volt/page/bindings/each_binding.rb +13 -13
- data/lib/volt/page/bindings/event_binding.rb +4 -4
- data/lib/volt/page/bindings/if_binding.rb +12 -12
- data/lib/volt/page/bindings/template_binding.rb +30 -30
- data/lib/volt/page/channel.rb +19 -19
- data/lib/volt/page/channel_stub.rb +6 -6
- data/lib/volt/page/document.rb +2 -2
- data/lib/volt/page/document_events.rb +4 -4
- data/lib/volt/page/draw_cycle.rb +3 -3
- data/lib/volt/page/memory_test.rb +6 -6
- data/lib/volt/page/page.rb +19 -19
- data/lib/volt/page/reactive_template.rb +9 -9
- data/lib/volt/page/sub_context.rb +5 -5
- data/lib/volt/page/targets/attribute_section.rb +9 -9
- data/lib/volt/page/targets/attribute_target.rb +3 -3
- data/lib/volt/page/targets/base_section.rb +2 -2
- data/lib/volt/page/targets/binding_document/component_node.rb +23 -23
- data/lib/volt/page/targets/binding_document/html_node.rb +2 -2
- data/lib/volt/page/targets/dom_section.rb +40 -38
- data/lib/volt/page/targets/dom_target.rb +2 -2
- data/lib/volt/page/tasks.rb +12 -12
- data/lib/volt/page/template_renderer.rb +4 -4
- data/lib/volt/page/url_tracker.rb +6 -6
- data/lib/volt/reactive/array_extensions.rb +2 -2
- data/lib/volt/reactive/destructive_methods.rb +5 -5
- data/lib/volt/reactive/event_chain.rb +25 -25
- data/lib/volt/reactive/events.rb +33 -33
- data/lib/volt/reactive/object_tracker.rb +21 -21
- data/lib/volt/reactive/object_tracking.rb +2 -2
- data/lib/volt/reactive/reactive_array.rb +57 -57
- data/lib/volt/reactive/reactive_tags.rb +16 -16
- data/lib/volt/reactive/reactive_value.rb +72 -72
- data/lib/volt/reactive/string_extensions.rb +3 -3
- data/lib/volt/router/routes.rb +22 -23
- data/lib/volt/server/component_handler.rb +5 -5
- data/lib/volt/server/component_templates.rb +14 -11
- data/lib/volt/server/html_parser/attribute_scope.rb +116 -0
- data/lib/volt/server/html_parser/each_scope.rb +18 -0
- data/lib/volt/server/html_parser/if_view_scope.rb +71 -0
- data/lib/volt/server/html_parser/sandlebars_parser.rb +219 -0
- data/lib/volt/server/html_parser/textarea_scope.rb +31 -0
- data/lib/volt/server/html_parser/view_handler.rb +82 -0
- data/lib/volt/server/html_parser/view_parser.rb +23 -0
- data/lib/volt/server/html_parser/view_scope.rb +145 -0
- data/lib/volt/server/rack/asset_files.rb +17 -17
- data/lib/volt/server/rack/component_paths.rb +18 -18
- data/lib/volt/server/rack/index_files.rb +8 -8
- data/lib/volt/server/rack/opal_files.rb +11 -11
- data/lib/volt/server/socket_connection_handler.rb +13 -13
- data/lib/volt/server/socket_connection_handler_stub.rb +2 -2
- data/lib/volt/server.rb +18 -18
- data/lib/volt/tasks/dispatcher.rb +5 -5
- data/lib/volt/utils/ejson.rb +2 -2
- data/lib/volt/utils/generic_counting_pool.rb +8 -8
- data/lib/volt/utils/generic_pool.rb +16 -16
- data/lib/volt/volt/environment.rb +4 -4
- data/lib/volt.rb +6 -6
- data/spec/integration/test_integration_spec.rb +2 -2
- data/spec/models/event_chain_spec.rb +38 -38
- data/spec/models/model_spec.rb +128 -128
- data/spec/models/old_model_spec.rb +17 -17
- data/spec/models/persistors/params_spec.rb +3 -3
- data/spec/models/persistors/store_spec.rb +7 -7
- data/spec/models/reactive_array_spec.rb +82 -82
- data/spec/models/reactive_generator_spec.rb +11 -11
- data/spec/models/reactive_tags_spec.rb +6 -6
- data/spec/models/reactive_value_spec.rb +70 -70
- data/spec/models/store_spec.rb +4 -4
- data/spec/models/string_extensions_spec.rb +13 -13
- data/spec/page/bindings/content_binding_spec.rb +6 -6
- data/spec/page/sub_context_spec.rb +1 -1
- data/spec/router/routes_spec.rb +3 -3
- data/spec/server/html_parser/sample_page.html +595 -0
- data/spec/server/html_parser/sandlebars_parser_spec.rb +192 -0
- data/spec/server/html_parser/view_parser_spec.rb +286 -0
- data/spec/server/rack/asset_files_spec.rb +6 -6
- data/spec/server/rack/component_paths_spec.rb +5 -5
- data/spec/spec_helper.rb +4 -5
- data/spec/store/mongo_spec.rb +3 -3
- data/spec/tasks/live_query_spec.rb +6 -6
- data/spec/tasks/query_tasks.rb +4 -4
- data/spec/tasks/query_tracker_spec.rb +20 -20
- data/spec/templates/targets/binding_document/component_node_spec.rb +4 -4
- data/spec/templates/template_binding_spec.rb +28 -28
- data/spec/utils/generic_counting_pool_spec.rb +5 -5
- data/spec/utils/generic_pool_spec.rb +14 -14
- data/templates/newgem/app/newgem/views/index/index.html +1 -2
- data/templates/project/app/home/config/dependencies.rb +1 -1
- data/templates/project/app/home/controllers/index_controller.rb +1 -1
- data/templates/project/app/home/views/index/about.html +4 -6
- data/templates/project/app/home/views/index/home.html +4 -5
- data/templates/project/app/home/views/index/index.html +8 -9
- data/templates/project/spec/spec_helper.rb +1 -1
- metadata +17 -8
- data/lib/volt/server/binding_setup.rb +0 -2
- data/lib/volt/server/if_binding_setup.rb +0 -31
- data/lib/volt/server/scope.rb +0 -43
- data/lib/volt/server/template_parser.rb +0 -453
- data/spec/server/template_parser_spec.rb +0 -50
@@ -10,25 +10,25 @@ class TestYield
|
|
10
10
|
end
|
11
11
|
class SampleClass
|
12
12
|
include ReactiveTags
|
13
|
-
|
13
|
+
|
14
14
|
tag_method(:break_stuff) do
|
15
15
|
destructive!
|
16
16
|
end
|
17
17
|
def break_stuff
|
18
18
|
5
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
tag_method(:receive_reactive?) do
|
22
22
|
pass_reactive!
|
23
23
|
end
|
24
24
|
def receive_reactive?(arg1)
|
25
25
|
return arg1.reactive?
|
26
26
|
end
|
27
|
-
|
27
|
+
|
28
28
|
def receive_non_reactive?(arg1)
|
29
29
|
return arg1.reactive?
|
30
30
|
end
|
31
|
-
|
31
|
+
|
32
32
|
tag_method(:destructive_receive_non_reactive?) do
|
33
33
|
destructive!
|
34
34
|
end
|
@@ -40,7 +40,7 @@ end
|
|
40
40
|
|
41
41
|
class SampleTriggerClass
|
42
42
|
include ReactiveTags
|
43
|
-
|
43
|
+
|
44
44
|
tag_method(:method_that_triggers) { destructive! }
|
45
45
|
def method_that_triggers
|
46
46
|
trigger!('changed')
|
@@ -49,16 +49,16 @@ end
|
|
49
49
|
|
50
50
|
class SampleNonTriggerClass
|
51
51
|
include ReactiveTags
|
52
|
-
|
52
|
+
|
53
53
|
tag_method(:method_that_triggers) { destructive! }
|
54
54
|
def method_that_triggers
|
55
55
|
# does not trigger
|
56
|
-
end
|
56
|
+
end
|
57
57
|
end
|
58
58
|
|
59
59
|
class SampleTriggerClass2
|
60
60
|
include ReactiveTags
|
61
|
-
|
61
|
+
|
62
62
|
tag_method(:method_that_triggers) { destructive! }
|
63
63
|
def method_that_triggers
|
64
64
|
trigger!('other')
|
@@ -73,32 +73,32 @@ describe ReactiveValue do
|
|
73
73
|
b = a.with { |a| a + 1 }
|
74
74
|
expect(a.cur).to eq(1)
|
75
75
|
expect(b.cur).to eq(2)
|
76
|
-
|
76
|
+
|
77
77
|
a.cur = 5
|
78
78
|
expect(b.cur).to eq(6)
|
79
79
|
end
|
80
|
-
|
80
|
+
|
81
81
|
it "should say its reactive" do
|
82
82
|
a = 1
|
83
83
|
b = ReactiveValue.new(a)
|
84
|
-
|
84
|
+
|
85
85
|
expect(a.reactive?).to eq(false)
|
86
86
|
expect(b.reactive?).to eq(true)
|
87
87
|
end
|
88
|
-
|
88
|
+
|
89
89
|
it "should return a reactive value from any method call" do
|
90
90
|
a = ReactiveValue.new(5)
|
91
91
|
b = 10
|
92
|
-
|
92
|
+
|
93
93
|
c = a + b
|
94
94
|
d = b + a
|
95
95
|
e = c + d
|
96
|
-
|
96
|
+
|
97
97
|
expect(c.reactive?).to eq(true)
|
98
98
|
expect(d.reactive?).to eq(true)
|
99
99
|
expect(e.reactive?).to eq(true)
|
100
100
|
end
|
101
|
-
|
101
|
+
|
102
102
|
it "should work with objects not just numbers" do
|
103
103
|
a = ReactiveValue.new([1,2,3])
|
104
104
|
b = [4]
|
@@ -111,37 +111,37 @@ describe ReactiveValue do
|
|
111
111
|
expect(d.reactive?).to eq(true)
|
112
112
|
expect(e.reactive?).to eq(true)
|
113
113
|
end
|
114
|
-
|
114
|
+
|
115
115
|
it "should return different listeners" do
|
116
116
|
a = ReactiveValue.new(1)
|
117
|
-
|
117
|
+
|
118
118
|
count = 0
|
119
119
|
listener1 = a.on('changed') { count += 1 }
|
120
120
|
listener2 = a.on('changed') { count += 1 }
|
121
|
-
|
121
|
+
|
122
122
|
expect(listener1).not_to eq(listener2)
|
123
123
|
end
|
124
|
-
|
124
|
+
|
125
125
|
it "should return a reactive on .is_a?" do
|
126
126
|
a = ReactiveValue.new(1)
|
127
127
|
b = a.is_a?(Fixnum)
|
128
|
-
|
128
|
+
|
129
129
|
expect(b.reactive?).to eq(true)
|
130
130
|
expect(b.cur).to eq(true)
|
131
131
|
end
|
132
|
-
|
132
|
+
|
133
133
|
it "should return true for a nil? on a nil value" do
|
134
134
|
a = ReactiveValue.new(nil)
|
135
135
|
b = a.nil?
|
136
136
|
expect(b.reactive?).to eq(true)
|
137
137
|
expect(a.cur).to eq(nil)
|
138
|
-
|
138
|
+
|
139
139
|
a = ReactiveValue.new(1)
|
140
140
|
b = a.nil?
|
141
141
|
expect(b.reactive?).to eq(true)
|
142
142
|
expect(a.cur).not_to eq(nil)
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
it "should only chain one event up" do
|
146
146
|
a = ReactiveValue.new('1')
|
147
147
|
b = a.to_i
|
@@ -149,34 +149,34 @@ describe ReactiveValue do
|
|
149
149
|
count = 0
|
150
150
|
b.on('changed') { count += 1 }
|
151
151
|
b.on('changed') { count += 1 }
|
152
|
-
|
152
|
+
|
153
153
|
expect(a.reactive_manager.listeners[:changed].size).to eq(1)
|
154
154
|
end
|
155
155
|
end
|
156
|
-
|
156
|
+
|
157
157
|
describe "events" do
|
158
158
|
it "should bind and trigger" do
|
159
159
|
a = ReactiveValue.new(1)
|
160
160
|
count = 0
|
161
161
|
a.on('changed') { count += 1 }
|
162
162
|
expect(count).to eq(0)
|
163
|
-
|
163
|
+
|
164
164
|
a.trigger!('changed')
|
165
165
|
expect(count).to eq(1)
|
166
166
|
end
|
167
|
-
|
167
|
+
|
168
168
|
it "should bind and trigger on children" do
|
169
169
|
a = ReactiveValue.new(1)
|
170
170
|
b = a + 10
|
171
|
-
|
171
|
+
|
172
172
|
count = 0
|
173
173
|
b.on('changed') { count += 1 }
|
174
174
|
expect(count).to eq(0)
|
175
|
-
|
175
|
+
|
176
176
|
a.trigger!('changed')
|
177
177
|
expect(count).to eq(1)
|
178
178
|
end
|
179
|
-
|
179
|
+
|
180
180
|
it "should handle events, even when triggered from the parent" do
|
181
181
|
a = ReactiveValue.new(5)
|
182
182
|
b = ReactiveValue.new(20)
|
@@ -189,144 +189,144 @@ describe ReactiveValue do
|
|
189
189
|
|
190
190
|
a.trigger!('changed')
|
191
191
|
expect(@called).to eq(true)
|
192
|
-
|
192
|
+
|
193
193
|
@called = false
|
194
|
-
|
194
|
+
|
195
195
|
b.trigger!('changed')
|
196
196
|
expect(@called).to eq(true)
|
197
|
-
|
197
|
+
|
198
198
|
end
|
199
199
|
end
|
200
|
-
|
200
|
+
|
201
201
|
describe "arrays" do
|
202
202
|
it "should add wrapped arrays" do
|
203
203
|
a = ReactiveValue.new([1,2])
|
204
204
|
b = ReactiveValue.new([3,4])
|
205
|
-
|
205
|
+
|
206
206
|
c = a + b
|
207
207
|
expect(c.size.cur).to eq(4)
|
208
208
|
end
|
209
209
|
end
|
210
|
-
|
210
|
+
|
211
211
|
describe "tagged methods" do
|
212
|
-
|
212
|
+
|
213
213
|
it "should let a class specify methods as destructive" do
|
214
214
|
a = ReactiveValue.new(SampleClass.new)
|
215
215
|
result = a.break_stuff
|
216
216
|
expect(result).to eq(5)
|
217
217
|
expect(result.reactive?).to eq(false)
|
218
218
|
end
|
219
|
-
|
219
|
+
|
220
220
|
it "should pass reactive values when asked" do
|
221
221
|
a = ReactiveValue.new(SampleClass.new)
|
222
222
|
expect(a.receive_reactive?(ReactiveValue.new(1)).cur).to eq(true)
|
223
223
|
end
|
224
|
-
|
224
|
+
|
225
225
|
it "should not pass reactive when not asked" do
|
226
226
|
a = ReactiveValue.new(SampleClass.new)
|
227
227
|
expect(a.receive_non_reactive?(ReactiveValue.new(1)).cur).to eq(false)
|
228
228
|
end
|
229
|
-
|
229
|
+
|
230
230
|
it "should not pass a reactive value to a destructive method unless it asked for it" do
|
231
231
|
a = ReactiveValue.new(SampleClass.new)
|
232
232
|
expect(a.destructive_receive_non_reactive?(ReactiveValue.new(1)).cur).to eq(false)
|
233
233
|
end
|
234
234
|
end
|
235
|
-
|
235
|
+
|
236
236
|
describe "triggers from methods" do
|
237
|
-
|
237
|
+
|
238
238
|
it "should trigger on any ReactiveValue's that are wrapping it" do
|
239
239
|
a = ReactiveValue.new(SampleTriggerClass.new)
|
240
|
-
|
240
|
+
|
241
241
|
count = 0
|
242
|
-
a.on('changed') { count += 1 }
|
242
|
+
a.on('changed') { count += 1 }
|
243
243
|
expect(count).to eq(0)
|
244
|
-
|
244
|
+
|
245
245
|
a.method_that_triggers
|
246
246
|
expect(count).to eq(1)
|
247
247
|
end
|
248
|
-
|
248
|
+
|
249
249
|
it "should trigger on any ReactiveValue's that are wrapping it" do
|
250
250
|
a = ReactiveValue.new(SampleNonTriggerClass.new)
|
251
|
-
|
251
|
+
|
252
252
|
count = 0
|
253
253
|
a.on('changed') { count += 1 }
|
254
254
|
expect(count).to eq(0)
|
255
|
-
|
255
|
+
|
256
256
|
a.method_that_triggers
|
257
257
|
expect(count).to eq(0)
|
258
|
-
|
258
|
+
|
259
259
|
a.cur = SampleTriggerClass.new
|
260
260
|
expect(count).to eq(1)
|
261
|
-
|
261
|
+
|
262
262
|
a.method_that_triggers
|
263
263
|
expect(count).to eq(2)
|
264
264
|
end
|
265
|
-
|
265
|
+
|
266
266
|
it "should trigger the correct event" do
|
267
267
|
a = ReactiveValue.new(SampleNonTriggerClass.new)
|
268
|
-
|
268
|
+
|
269
269
|
count = 0
|
270
270
|
other_count = 0
|
271
271
|
a.on('changed') { count += 1 }
|
272
272
|
a.on('other') { other_count += 1 }
|
273
273
|
expect(count).to eq(0)
|
274
|
-
|
274
|
+
|
275
275
|
a.method_that_triggers
|
276
276
|
expect(count).to eq(0)
|
277
|
-
|
277
|
+
|
278
278
|
a.cur = SampleTriggerClass.new
|
279
279
|
expect(count).to eq(1)
|
280
|
-
|
280
|
+
|
281
281
|
a.method_that_triggers
|
282
282
|
expect(count).to eq(2)
|
283
283
|
|
284
284
|
# Note: .cur= triggers changed
|
285
285
|
a.cur = SampleTriggerClass2.new
|
286
286
|
expect(other_count).to eq(0)
|
287
|
-
|
287
|
+
|
288
288
|
a.method_that_triggers
|
289
289
|
expect(count).to eq(3)
|
290
290
|
expect(other_count).to eq(1)
|
291
291
|
end
|
292
|
-
|
293
|
-
it "should trigger through two different paths" do
|
292
|
+
|
293
|
+
it "should trigger through two different paths" do
|
294
294
|
source = SampleTriggerClass.new
|
295
295
|
a = ReactiveValue.new(source)
|
296
296
|
b = ReactiveValue.new(source)
|
297
|
-
|
297
|
+
|
298
298
|
count = 0
|
299
299
|
count2 = 0
|
300
300
|
a.on('changed') { count += 1 }
|
301
301
|
b.on('changed') { count2 += 1 }
|
302
|
-
|
302
|
+
|
303
303
|
expect(count).to eq(0)
|
304
304
|
expect(count2).to eq(0)
|
305
|
-
|
305
|
+
|
306
306
|
a.method_that_triggers
|
307
|
-
|
307
|
+
|
308
308
|
expect(count).to eq(1)
|
309
309
|
expect(count2).to eq(1)
|
310
310
|
end
|
311
311
|
end
|
312
|
-
|
312
|
+
|
313
313
|
it "should setup a ReactiveManager" do
|
314
314
|
a = ReactiveValue.new(1)
|
315
315
|
expect(a.reactive_manager.class).to eq(ReactiveManager)
|
316
316
|
end
|
317
|
-
|
317
|
+
|
318
318
|
describe "similar to base object" do
|
319
319
|
it "should return a reactive comparator" do
|
320
320
|
a = ReactiveValue.new(1)
|
321
321
|
b = ReactiveValue.new(2)
|
322
|
-
|
322
|
+
|
323
323
|
compare = (a == b)
|
324
324
|
expect(compare.cur).to eq(false)
|
325
325
|
b.cur = 1
|
326
326
|
expect(compare.cur).to eq(true)
|
327
327
|
end
|
328
328
|
end
|
329
|
-
|
329
|
+
|
330
330
|
describe "blocks" do
|
331
331
|
before do
|
332
332
|
|
@@ -340,14 +340,14 @@ describe ReactiveValue do
|
|
340
340
|
# value.reactive?.should == true
|
341
341
|
# value.even?
|
342
342
|
end.cur
|
343
|
-
|
343
|
+
|
344
344
|
expect(count).to eq(2)
|
345
345
|
end
|
346
346
|
end
|
347
|
-
|
347
|
+
|
348
348
|
it "should give you back the object without any ReactiveValue's if you call .deep_cur on it." do
|
349
349
|
a = ReactiveValue.new({_names: [ReactiveValue.new('bob'), ReactiveValue.new('jim')]})
|
350
|
-
|
350
|
+
|
351
351
|
expect(a.deep_cur).to eq({_names: ['bob', 'jim']})
|
352
352
|
end
|
353
|
-
end
|
353
|
+
end
|
data/spec/models/store_spec.rb
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
# require 'volt/models'
|
2
|
-
#
|
2
|
+
#
|
3
3
|
# describe Store do
|
4
4
|
# # it "should stay as store classes when used" do
|
5
5
|
# # a = Store.new
|
6
6
|
# # expect(a._test.class).to eq(Store)
|
7
|
-
# #
|
7
|
+
# #
|
8
8
|
# # expect(a._test._cool.class).to eq(Store)
|
9
|
-
# #
|
9
|
+
# #
|
10
10
|
# # a._items << {_name: 'Test'}
|
11
|
-
# #
|
11
|
+
# #
|
12
12
|
# # expect(a._items.class).to eq(StoreArray)
|
13
13
|
# # expect(a._items[0].class).to eq(Store)
|
14
14
|
# # expect(a._items[0]._name.class).to eq(String)
|
@@ -4,45 +4,45 @@ describe ReactiveValue do
|
|
4
4
|
it "should concat reactive strings" do
|
5
5
|
a = ReactiveValue.new('cool')
|
6
6
|
b = ReactiveValue.new('beans')
|
7
|
-
|
7
|
+
|
8
8
|
c = a + b
|
9
9
|
expect(c.cur).to eq('coolbeans')
|
10
10
|
expect(c.reactive?).to eq(true)
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
it "should concat reactive and non-reactive" do
|
14
14
|
a = ReactiveValue.new('cool')
|
15
15
|
b = 'beans'
|
16
|
-
|
16
|
+
|
17
17
|
c = a + b
|
18
18
|
expect(c.cur).to eq('coolbeans')
|
19
|
-
expect(c.reactive?).to eq(true)
|
19
|
+
expect(c.reactive?).to eq(true)
|
20
20
|
end
|
21
|
-
|
21
|
+
|
22
22
|
it "should concat non-reactive and reactive" do
|
23
23
|
a = 'cool'
|
24
24
|
b = ReactiveValue.new('beans')
|
25
|
-
|
25
|
+
|
26
26
|
c = a + b
|
27
27
|
expect(c.cur).to eq('coolbeans')
|
28
|
-
expect(c.reactive?).to eq(true)
|
28
|
+
expect(c.reactive?).to eq(true)
|
29
29
|
end
|
30
|
-
|
30
|
+
|
31
31
|
if RUBY_PLATFORM != 'opal'
|
32
32
|
it "should append reactive to reactive" do
|
33
33
|
a = ReactiveValue.new('cool')
|
34
34
|
b = ReactiveValue.new('beans')
|
35
|
-
|
35
|
+
|
36
36
|
a << b
|
37
37
|
expect(a.cur).to eq('coolbeans')
|
38
38
|
expect(a.reactive?).to eq(true)
|
39
39
|
end
|
40
40
|
end
|
41
|
-
|
41
|
+
|
42
42
|
it "should raise an exception when appending non-reactive and reactive" do
|
43
43
|
a = 'cool'
|
44
44
|
b = ReactiveValue.new('beans')
|
45
|
-
|
45
|
+
|
46
46
|
exception_count = 0
|
47
47
|
begin
|
48
48
|
a << b
|
@@ -50,8 +50,8 @@ describe ReactiveValue do
|
|
50
50
|
expect(e.message[/Cannot append a reactive/].cur.true?).to eq(true)
|
51
51
|
exception_count += 1
|
52
52
|
end
|
53
|
-
|
53
|
+
|
54
54
|
expect(exception_count).to eq(1)
|
55
55
|
end
|
56
56
|
|
57
|
-
end
|
57
|
+
end
|
@@ -4,15 +4,15 @@ require 'volt/page/targets/attribute_target'
|
|
4
4
|
require 'volt/page/template_renderer'
|
5
5
|
|
6
6
|
|
7
|
-
describe ContentBinding do
|
7
|
+
describe ContentBinding do
|
8
8
|
it "should render the content in a content binding" do
|
9
9
|
dom = AttributeTarget.new(0)
|
10
10
|
context = {:name => 'jimmy'}
|
11
11
|
binding = ContentBinding.new(nil, dom, context, 0, Proc.new { self[:name] })
|
12
|
-
|
12
|
+
|
13
13
|
expect(dom.to_html).to eq('jimmy')
|
14
14
|
end
|
15
|
-
|
15
|
+
|
16
16
|
it "should render with a template" do
|
17
17
|
context = {:name => 'jimmy'}
|
18
18
|
binding = lambda {|page, target, context, id| ContentBinding.new(page, target, context, id, Proc.new { self[:name] }) }
|
@@ -28,9 +28,9 @@ describe ContentBinding do
|
|
28
28
|
expect(page).to receive(:templates).and_return(templates)
|
29
29
|
|
30
30
|
dom = AttributeTarget.new(0)
|
31
|
-
|
31
|
+
|
32
32
|
TemplateRenderer.new(page, dom, context, 'main', 'home/index')
|
33
|
-
|
33
|
+
|
34
34
|
expect(dom.to_html).to eq('hello jimmy')
|
35
35
|
end
|
36
|
-
end
|
36
|
+
end
|
@@ -3,7 +3,7 @@ require 'volt/page/sub_context'
|
|
3
3
|
describe SubContext do
|
4
4
|
it "should respond_to correctly on locals" do
|
5
5
|
sub_context = SubContext.new({:name => 'Name'})
|
6
|
-
|
6
|
+
|
7
7
|
expect(sub_context.respond_to?(:name)).to eq(true)
|
8
8
|
expect(sub_context.respond_to?(:missing)).to eq(false)
|
9
9
|
end
|
data/spec/router/routes_spec.rb
CHANGED
@@ -11,14 +11,14 @@ describe Routes do
|
|
11
11
|
params = Model.new({}, persistor: Persistors::Params)
|
12
12
|
params._controller = 'blog'
|
13
13
|
params._index = '5'
|
14
|
-
|
14
|
+
|
15
15
|
routes do
|
16
16
|
get '/', _controller: 'index'
|
17
17
|
get '/blog', _controller: 'blog'
|
18
18
|
end
|
19
|
-
|
19
|
+
|
20
20
|
path, cleaned_params = @routes.url_for_params(params)
|
21
21
|
expect(path).to eq('/blog')
|
22
22
|
expect(cleaned_params).to eq({_index: '5'})
|
23
23
|
end
|
24
|
-
end
|
24
|
+
end
|