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: 45e043a4b3096676a058b2558d29cfdd9e1580757f973464d727ef63e5cb54f8
4
- data.tar.gz: d905cc69bd7b28c3bbd32ed807acd9386862446292acc90c5506e6d3e6a36bcf
3
+ metadata.gz: e7bdbd86f6a632d14466afe180d2a6f75dbf7fa852cc49719deb13bfa740ac74
4
+ data.tar.gz: 0bfb9d97fa310d9e1694d1797666424ad74258cbafe1ce53d04007402f79f81b
5
5
  SHA512:
6
- metadata.gz: 8ff9c676ed207c0b59eb1f3949b69c73f482100c2d775ebba417acebba2fbfe0ff25e0d10906b752101b391e9d47f5c2147e60feef0c87b7a291b81fdf86a1f5
7
- data.tar.gz: 145930ea3e14e690b8c27cce58338daf236f562b7fbb9119532656669180c6d63f3fad5a4f386e34a1c19cc0e9b1419a621d45c9d5f5e8816f7d1b8865e662b7
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
- # ----- MORE OPTIONS -----
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 TestHelpers
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
@@ -1,3 +1,3 @@
1
1
  module RenderTurboStream
2
- VERSION = "0.1.31"
2
+ VERSION = "0.1.33"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  require "render_turbo_stream/version"
2
2
  require "render_turbo_stream/railtie"
3
3
  require 'render_turbo_stream/engine'
4
- require 'render_turbo_stream/test_helpers'
4
+ require 'render_turbo_stream/request_test_helpers'
5
5
 
6
6
  module RenderTurboStream
7
7
 
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.31
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/test_helpers.rb
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