render_turbo_stream 0.1.27 → 0.1.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 71ca68293cace6bf25ae1983f0c710669d00b624173185da8d22377094a5ec09
4
- data.tar.gz: 83f6948953c0bae73584aacb28e23785e8bf1308ca8c0f326488dbe1b70c6e4e
3
+ metadata.gz: 9fd83f028af180b34e023bf8e1b3fb253542404e51b34052c20234e2a39f0d49
4
+ data.tar.gz: 3718708775a5a332d5947c9a2c9a1beb4e0ae409cd1e70b6e67287a1f76d50c3
5
5
  SHA512:
6
- metadata.gz: 37f7dfac016b98ca2cb9b66f92b34bd534de52e285d1de7a44cd4b3ec8efeef5c0203178ffeef28ee77dd3e66029a76cb2714b7b1b0a398e15f6c774ec1df259
7
- data.tar.gz: 3a4059c7f942fedc218b716822b8cf9ef854cae5c6ee4e6e40e68a464938568984d290e85d9a915be83993640cb4c5d9cb8237ed7ef869659aedfc11fc6efca4
6
+ metadata.gz: 0fe15f3a6697b46ac3bf94cbb8a8c56c9899e1cacb5e092147963e6b8fbca138f5db867a5f023018c3e8d65396d181eb1b737a0347f4e39556c484ae2bf55a62
7
+ data.tar.gz: cab2f86053718391d43d098bfe6a45322f1e9b1eda5bf252f387e983835df771050cea36d737512cfa7dd2a69b8581ca99067f131732d1cd2be6f7ab4a30d3d0
data/README.md CHANGED
@@ -54,7 +54,7 @@ The corresponding partials for flashes could look [like this](https://gitlab.com
54
54
  end
55
55
  ```
56
56
 
57
- This will set a status, generate a flash message and perform `stream_partials', which could result in something like this:
57
+ This will set a status, generate a flash message and perform `stream_partials`, which could result in something like this:
58
58
 
59
59
  ```ruby
60
60
  stream_partials(
@@ -72,7 +72,7 @@ stream_partials(
72
72
  )
73
73
  ```
74
74
 
75
- The `stream_partial' method is nothing more than a singular of `stream_partials'.
75
+ The `stream_partial` method is nothing else than a singular of `stream_partials`.
76
76
 
77
77
  ```ruby
78
78
  stream_partial(
@@ -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
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
  ```
@@ -131,7 +137,7 @@ The test for a redirection might look something like this:
131
137
  it 'update success' do
132
138
  a = FactoryBot.create(:article)
133
139
  patch article_path(a, params: valid_params)
134
- expect(turbo_redirected_to).to eq(articles_path)
140
+ expect(turbo_redirect_to).to eq(articles_path)
135
141
  end
136
142
  ```
137
143
 
@@ -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
@@ -51,7 +60,7 @@ module RenderTurboStream
51
60
  end
52
61
 
53
62
  # Returns the path to which turbo_stream.redirect_to would be applied.
54
- def turbo_redirected_to
63
+ def turbo_redirect_to
55
64
  expect(response.status).to eq(302)
56
65
  r = JSON.parse(response.body)
57
66
  r['redirected_to']
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "0.1.27"
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.27
4
+ version: 0.1.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - christian