render_turbo_stream 0.1.28 → 0.1.29

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: 9fd83f028af180b34e023bf8e1b3fb253542404e51b34052c20234e2a39f0d49
4
+ data.tar.gz: 3718708775a5a332d5947c9a2c9a1beb4e0ae409cd1e70b6e67287a1f76d50c3
5
5
  SHA512:
6
- metadata.gz: d7b25b72283be57909d4085752c0457b2db91de7174df9e8e83f3daf1da784eaca70b509fa1fa5ed28c6cf9f8896916679265914c28db8a0fb00117479d0c858
7
- data.tar.gz: 7d8ed294add44a776cd5e5fdfefd51380ef7af5063543fa49cac33155df50a9448966cc1c5599731d665aa0fc9ac1d2bea9fbdfc7a35af44b612c3c18680bed9
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 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.29"
3
3
  end
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.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian