render_turbo_stream 0.1.28 → 0.1.29
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +15 -9
- data/lib/render_turbo_stream/test_helpers.rb +9 -0
- 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: 9fd83f028af180b34e023bf8e1b3fb253542404e51b34052c20234e2a39f0d49
|
4
|
+
data.tar.gz: 3718708775a5a332d5947c9a2c9a1beb4e0ae409cd1e70b6e67287a1f76d50c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fe15f3a6697b46ac3bf94cbb8a8c56c9899e1cacb5e092147963e6b8fbca138f5db867a5f023018c3e8d65396d181eb1b737a0347f4e39556c484ae2bf55a62
|
7
|
+
data.tar.gz: cab2f86053718391d43d098bfe6a45322f1e9b1eda5bf252f387e983835df771050cea36d737512cfa7dd2a69b8581ca99067f131732d1cd2be6f7ab4a30d3d0
|
data/README.md
CHANGED
@@ -105,22 +105,28 @@ RSpec.describe "Articles", type: :request do
|
|
105
105
|
# to which html-ids turbo-stream would point
|
106
106
|
expect(partials_ids).to include('flash-box', 'form')
|
107
107
|
|
108
|
-
# which partials
|
108
|
+
# which partials were rendered
|
109
109
|
expect(partials_paths).to include('layouts/flash', 'articles/form')
|
110
110
|
|
111
|
-
# partial_response (singular) returns false unless partial responded exactly one time, otherwise the content
|
111
|
+
# partial_response (singular) returns false unless partial responded exactly one time, otherwise the content in nokogiri format: https://nokogiri.org/tutorials/searching_a_xml_html_document.html#basic-searching
|
112
112
|
r = partial_response(id: 'flash-box')
|
113
113
|
expect(r.css('div.text-content').first.inner_html).to include('Article could not be created')
|
114
114
|
|
115
|
-
#
|
116
|
-
r2 = partials_responses(id: 'flash-box')
|
117
|
-
expect(r2.length).to eq(1)
|
118
|
-
|
119
|
-
# same, based on path by which partial is rendered to
|
115
|
+
# same, but based on path by which partial is rendered to
|
120
116
|
r = partial_response(partial: 'layouts/flash')
|
121
117
|
expect(r.css('div.text-content').first.inner_html).to include('Article could not be created')
|
122
|
-
|
123
|
-
|
118
|
+
|
119
|
+
# COUNTS
|
120
|
+
|
121
|
+
# Check the number of ids responded to
|
122
|
+
expect(partials_ids_count).to eq(2)
|
123
|
+
|
124
|
+
# Check how many times a specific ID has been responded to.
|
125
|
+
expect(partials_responses(id: 'flash-box').length).to eq(1)
|
126
|
+
|
127
|
+
# Same with partials
|
128
|
+
expect(partials_count).to eq(2)
|
129
|
+
expect(partials_responses(partial: 'layouts/flash').length).to eq(1)
|
124
130
|
end
|
125
131
|
end
|
126
132
|
```
|
@@ -13,6 +13,7 @@ module RenderTurboStream
|
|
13
13
|
end
|
14
14
|
|
15
15
|
# like partial_response, but returns an array with length of how many times partial was rendered
|
16
|
+
#
|
16
17
|
|
17
18
|
def partials_responses(id: nil, partial: nil)
|
18
19
|
ary = partials_attributes
|
@@ -28,6 +29,14 @@ module RenderTurboStream
|
|
28
29
|
res.map{|r| Nokogiri::HTML(r['html_response']) }
|
29
30
|
end
|
30
31
|
|
32
|
+
def partials_ids_count
|
33
|
+
partials_ids.length
|
34
|
+
end
|
35
|
+
|
36
|
+
def partials_count
|
37
|
+
partials_paths.length
|
38
|
+
end
|
39
|
+
|
31
40
|
# array of strings of ids of rendered partials that turbo_stream pointed to
|
32
41
|
def partials_ids
|
33
42
|
ary = partials_attributes
|