render_turbo_stream 0.1.28 → 0.1.30
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
- data/lib/render_turbo_stream.rb +2 -2
- 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: fceaabe20c5a6533f02917d1cc9512a7941980780ad94e5968b2fe594f9c300e
|
4
|
+
data.tar.gz: 9d12b4e354a672f93e31544e6153b57b16e4ae9fd8c2fae8b316fc2c19c956d2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f96b57506c02e8c106f2fac7c920750bd951b635d787c2170408d6aea397e1f3184926878d2306e701aade88a50630a0df7839358e8aa81509e7db43cca66285
|
7
|
+
data.tar.gz: 9ddb505c068cbee6863abc72f2094448f8b68dc6df01201ef87a3dc3e645ca0898fb773da7bdb738facf60d985eeff5fc47eb49cacc696fc63f2e7d9c021ba89
|
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
|
data/lib/render_turbo_stream.rb
CHANGED
@@ -90,8 +90,8 @@ module RenderTurboStream
|
|
90
90
|
flash_notices = []
|
91
91
|
end
|
92
92
|
|
93
|
-
flash_notices += add_flash_notices
|
94
|
-
flash_alerts += add_flash_alerts
|
93
|
+
flash_notices += add_flash_notices.to_a
|
94
|
+
flash_alerts += add_flash_alerts.to_a
|
95
95
|
_flash_id = Rails.configuration.x.render_turbo_stream.flash_id
|
96
96
|
flash_id = (_flash_id ? _flash_id : "ERROR, MISSING CONFIG => config.x.render_turbo_stream.flash_id")
|
97
97
|
flash_partial = Rails.configuration.x.render_turbo_stream.flash_partial
|