render_turbo_stream 0.1.31 → 0.1.33
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e7bdbd86f6a632d14466afe180d2a6f75dbf7fa852cc49719deb13bfa740ac74
|
4
|
+
data.tar.gz: 0bfb9d97fa310d9e1694d1797666424ad74258cbafe1ce53d04007402f79f81b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c36293efee4cca99176fbd40806f5d1d945329f86ef9a068d98e8f23945764be5bafabe2ece128a2e4afb41a7c40075ec736030d61f2ac2bbea9eb3b57639972
|
7
|
+
data.tar.gz: 040f42b9a0eabacc7150872a885b0576c64642016b2a63160ae13278b9a28533f8aa74e97959c5982bcc42b85c7db0091f0e9613f91653aa781b295502ea3bcc
|
data/README.md
CHANGED
@@ -24,6 +24,14 @@ ApplicationController
|
|
24
24
|
include RenderTurboStream
|
25
25
|
```
|
26
26
|
|
27
|
+
spec/rails_helper.rb
|
28
|
+
|
29
|
+
```ruby
|
30
|
+
RSpec.configure do |config|
|
31
|
+
config.include RenderTurboStream::RequestTestHelpers, type: :request
|
32
|
+
end
|
33
|
+
```
|
34
|
+
|
27
35
|
Redirection
|
28
36
|
|
29
37
|
For redirection to work, you must follow the installation steps from [turbo_power](https://github.com/marcoroth/turbo_power).
|
@@ -103,6 +111,8 @@ RSpec.describe "Articles", type: :request do
|
|
103
111
|
|
104
112
|
post articles_path(params: invalid_params)
|
105
113
|
|
114
|
+
# --- BASIC TEST ---
|
115
|
+
|
106
116
|
# Which partials were rendered
|
107
117
|
expect(partials_count).to eq(2)
|
108
118
|
expect(partials).to include('layouts/flash', 'articles/form')
|
@@ -110,7 +120,7 @@ RSpec.describe "Articles", type: :request do
|
|
110
120
|
|
111
121
|
|
112
122
|
|
113
|
-
#
|
123
|
+
# --- MORE OPTIONS ---
|
114
124
|
|
115
125
|
# to which html-ids turbo-stream would point
|
116
126
|
expect(partials_ids).to include('flash-box', 'form')
|
@@ -1,5 +1,5 @@
|
|
1
1
|
module RenderTurboStream
|
2
|
-
module
|
2
|
+
module RequestTestHelpers
|
3
3
|
|
4
4
|
# returns false if partial is rendered cero or multiple times
|
5
5
|
# response can be searched by nokogiri https://nokogiri.org/tutorials/searching_a_xml_html_document.html#basic-searching
|
@@ -26,7 +26,7 @@ module RenderTurboStream
|
|
26
26
|
else
|
27
27
|
raise 'missing parameter'
|
28
28
|
end
|
29
|
-
res.map{|r| Nokogiri::HTML(r['html_response']) }
|
29
|
+
res.map { |r| Nokogiri::HTML(r['html_response']) }
|
30
30
|
end
|
31
31
|
|
32
32
|
def partials_ids_count
|
@@ -41,7 +41,7 @@ module RenderTurboStream
|
|
41
41
|
def partials_ids
|
42
42
|
ary = partials_attributes
|
43
43
|
ids = []
|
44
|
-
ary.each {|a| ids.push(a['id']) unless ids.include?(a['id']) }
|
44
|
+
ary.each { |a| ids.push(a['id']) unless ids.include?(a['id']) }
|
45
45
|
ids
|
46
46
|
end
|
47
47
|
|
@@ -49,10 +49,26 @@ module RenderTurboStream
|
|
49
49
|
def partials
|
50
50
|
ary = partials_attributes
|
51
51
|
paths = []
|
52
|
-
ary.each {|a| paths.push(a['partial']) unless paths.include?(a['partial']) }
|
52
|
+
ary.each { |a| paths.push(a['partial']) unless paths.include?(a['partial']) }
|
53
53
|
paths
|
54
54
|
end
|
55
55
|
|
56
|
+
# array of strings of paths by which partials that are exactly one time rendered, for example: ['articles/form'].
|
57
|
+
def partials_once
|
58
|
+
ary = partials_attributes
|
59
|
+
paths = []
|
60
|
+
paths_once = []
|
61
|
+
ary.each do |a|
|
62
|
+
if paths.include?(a['partial'])
|
63
|
+
paths_once.delete(a['partial'])
|
64
|
+
else
|
65
|
+
paths.push(a['partial'])
|
66
|
+
paths_once.push(a['partial'])
|
67
|
+
end
|
68
|
+
end
|
69
|
+
paths_once
|
70
|
+
end
|
71
|
+
|
56
72
|
# returns an array of hashes with the attributes used to call partials and the response (html as string) from the partial.
|
57
73
|
def partials_attributes
|
58
74
|
e = Nokogiri::HTML(response.body).search('#rendered-partials').first
|
data/lib/render_turbo_stream.rb
CHANGED
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.
|
4
|
+
version: 0.1.33
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- christian
|
@@ -43,7 +43,7 @@ files:
|
|
43
43
|
- lib/render_turbo_stream.rb
|
44
44
|
- lib/render_turbo_stream/engine.rb
|
45
45
|
- lib/render_turbo_stream/railtie.rb
|
46
|
-
- lib/render_turbo_stream/
|
46
|
+
- lib/render_turbo_stream/request_test_helpers.rb
|
47
47
|
- lib/render_turbo_stream/version.rb
|
48
48
|
- lib/tasks/render_turbo_stream_tasks.rake
|
49
49
|
homepage: https://gitlab.com/sedl/renderturbostream
|