render_turbo_stream 0.1.28 → 0.1.30

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ddfe2fddf5d0990264594bd1bac97f8ad8846d344e63446a1b7d5ac263c0c9d
4
- data.tar.gz: 0e56a273cc7cd654e5be6957565c982be9b8ad1fa2a0fa1155f97c5e6815cae9
3
+ metadata.gz: fceaabe20c5a6533f02917d1cc9512a7941980780ad94e5968b2fe594f9c300e
4
+ data.tar.gz: 9d12b4e354a672f93e31544e6153b57b16e4ae9fd8c2fae8b316fc2c19c956d2
5
5
  SHA512:
6
- metadata.gz: d7b25b72283be57909d4085752c0457b2db91de7174df9e8e83f3daf1da784eaca70b509fa1fa5ed28c6cf9f8896916679265914c28db8a0fb00117479d0c858
7
- data.tar.gz: 7d8ed294add44a776cd5e5fdfefd51380ef7af5063543fa49cac33155df50a9448966cc1c5599731d665aa0fc9ac1d2bea9fbdfc7a35af44b612c3c18680bed9
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 where rendered
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 parsed by nokogiri, see how to handle: https://nokogiri.org/tutorials/searching_a_xml_html_document.html#basic-searching
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
- # partials_responses (plural) returns a array
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
- r2 = partials_responses(partial: 'layouts/flash')
123
- expect(r2.length).to eq(1)
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
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "0.1.28"
2
+ VERSION = "0.1.30"
3
3
  end
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: render_turbo_stream
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.28
4
+ version: 0.1.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian