render_turbo_stream 0.1.32 → 0.1.33
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +3 -1
- data/lib/render_turbo_stream/request_test_helpers.rb +19 -3
- data/lib/render_turbo_stream/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7bdbd86f6a632d14466afe180d2a6f75dbf7fa852cc49719deb13bfa740ac74
|
4
|
+
data.tar.gz: 0bfb9d97fa310d9e1694d1797666424ad74258cbafe1ce53d04007402f79f81b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c36293efee4cca99176fbd40806f5d1d945329f86ef9a068d98e8f23945764be5bafabe2ece128a2e4afb41a7c40075ec736030d61f2ac2bbea9eb3b57639972
|
7
|
+
data.tar.gz: 040f42b9a0eabacc7150872a885b0576c64642016b2a63160ae13278b9a28533f8aa74e97959c5982bcc42b85c7db0091f0e9613f91653aa781b295502ea3bcc
|
data/README.md
CHANGED
@@ -111,6 +111,8 @@ RSpec.describe "Articles", type: :request do
|
|
111
111
|
|
112
112
|
post articles_path(params: invalid_params)
|
113
113
|
|
114
|
+
# --- BASIC TEST ---
|
115
|
+
|
114
116
|
# Which partials were rendered
|
115
117
|
expect(partials_count).to eq(2)
|
116
118
|
expect(partials).to include('layouts/flash', 'articles/form')
|
@@ -118,7 +120,7 @@ RSpec.describe "Articles", type: :request do
|
|
118
120
|
|
119
121
|
|
120
122
|
|
121
|
-
#
|
123
|
+
# --- MORE OPTIONS ---
|
122
124
|
|
123
125
|
# to which html-ids turbo-stream would point
|
124
126
|
expect(partials_ids).to include('flash-box', 'form')
|
@@ -26,7 +26,7 @@ module RenderTurboStream
|
|
26
26
|
else
|
27
27
|
raise 'missing parameter'
|
28
28
|
end
|
29
|
-
res.map{|r| Nokogiri::HTML(r['html_response']) }
|
29
|
+
res.map { |r| Nokogiri::HTML(r['html_response']) }
|
30
30
|
end
|
31
31
|
|
32
32
|
def partials_ids_count
|
@@ -41,7 +41,7 @@ module RenderTurboStream
|
|
41
41
|
def partials_ids
|
42
42
|
ary = partials_attributes
|
43
43
|
ids = []
|
44
|
-
ary.each {|a| ids.push(a['id']) unless ids.include?(a['id']) }
|
44
|
+
ary.each { |a| ids.push(a['id']) unless ids.include?(a['id']) }
|
45
45
|
ids
|
46
46
|
end
|
47
47
|
|
@@ -49,10 +49,26 @@ module RenderTurboStream
|
|
49
49
|
def partials
|
50
50
|
ary = partials_attributes
|
51
51
|
paths = []
|
52
|
-
ary.each {|a| paths.push(a['partial']) unless paths.include?(a['partial']) }
|
52
|
+
ary.each { |a| paths.push(a['partial']) unless paths.include?(a['partial']) }
|
53
53
|
paths
|
54
54
|
end
|
55
55
|
|
56
|
+
# array of strings of paths by which partials that are exactly one time rendered, for example: ['articles/form'].
|
57
|
+
def partials_once
|
58
|
+
ary = partials_attributes
|
59
|
+
paths = []
|
60
|
+
paths_once = []
|
61
|
+
ary.each do |a|
|
62
|
+
if paths.include?(a['partial'])
|
63
|
+
paths_once.delete(a['partial'])
|
64
|
+
else
|
65
|
+
paths.push(a['partial'])
|
66
|
+
paths_once.push(a['partial'])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
paths_once
|
70
|
+
end
|
71
|
+
|
56
72
|
# returns an array of hashes with the attributes used to call partials and the response (html as string) from the partial.
|
57
73
|
def partials_attributes
|
58
74
|
e = Nokogiri::HTML(response.body).search('#rendered-partials').first
|