turbo-rails 2.0.6 → 2.0.13

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.
@@ -0,0 +1,128 @@
1
+ module Turbo::SystemTestHelper
2
+ # Delay until every `<turbo-cable-stream-source>` element present in the page
3
+ # is ready to receive broadcasts
4
+ #
5
+ # test "renders broadcasted Messages" do
6
+ # message = Message.new content: "Hello, from Action Cable"
7
+ #
8
+ # visit "/"
9
+ # click_link "All Messages"
10
+ # message.save! # execute server-side code to broadcast a Message
11
+ #
12
+ # assert_text message.content
13
+ # end
14
+ #
15
+ # By default, calls to `#visit` will wait for all `<turbo-cable-stream-source>`
16
+ # elements to connect. You can control this by modifying the
17
+ # `config.turbo.test_connect_after_actions`. For example, to wait after calls to
18
+ # `#click_link`, add the following to `config/environments/test.rb`:
19
+ #
20
+ # # config/environments/test.rb
21
+ # config.turbo.test_connect_after_actions << :click_link
22
+ #
23
+ # To disable automatic connecting, set the configuration to `[]`:
24
+ #
25
+ # # config/environments/test.rb
26
+ # config.turbo.test_connect_after_actions = []
27
+ #
28
+ def connect_turbo_cable_stream_sources(**options, &block)
29
+ all(:turbo_cable_stream_source, **options, connected: false, wait: 0).each do |element|
30
+ element.assert_matches_selector(:turbo_cable_stream_source, **options, connected: true, &block)
31
+ end
32
+ end
33
+
34
+ # Asserts that a `<turbo-cable-stream-source>` element is present in the
35
+ # document
36
+ #
37
+ # ==== Arguments
38
+ #
39
+ # * <tt>locator</tt> optional locator to determine the element's
40
+ # `[signed-stream-name]` attribute. Can be of any type that is a valid
41
+ # argument to <tt>Turbo::Streams::StreamName#signed_stream_name</tt>.
42
+ #
43
+ # ==== Options
44
+ #
45
+ # * <tt>:connected</tt> matches the `[connected]` attribute
46
+ # * <tt>:channel</tt> matches the `[channel]` attribute. Can be a Class,
47
+ # String, Symbol, or Regexp
48
+ # * <tt>:signed_stream_name</tt> matches the element's `[signed-stream-name]`
49
+ # attribute. Can be of any type that is a valid
50
+ # argument to <tt>Turbo::Streams::StreamName#signed_stream_name</tt>.
51
+ #
52
+ # In addition to the filters listed above, accepts any valid Capybara global
53
+ # filter option.
54
+ def assert_turbo_cable_stream_source(...)
55
+ assert_selector(:turbo_cable_stream_source, ...)
56
+ end
57
+
58
+ # Asserts that a `<turbo-cable-stream-source>` element is absent from the
59
+ # document
60
+ #
61
+ # ==== Arguments
62
+ #
63
+ # * <tt>locator</tt> optional locator to determine the element's
64
+ # `[signed-stream-name]` attribute. Can be of any type that is a valid
65
+ # argument to <tt>Turbo::Streams::StreamName#signed_stream_name</tt>.
66
+ #
67
+ # ==== Options
68
+ #
69
+ # * <tt>:connected</tt> matches the `[connected]` attribute
70
+ # * <tt>:channel</tt> matches the `[channel]` attribute. Can be a Class,
71
+ # String, Symbol, or Regexp
72
+ # * <tt>:signed_stream_name</tt> matches the element's `[signed-stream-name]`
73
+ # attribute. Can be of any type that is a valid
74
+ # argument to <tt>Turbo::Streams::StreamName#signed_stream_name</tt>.
75
+ #
76
+ # In addition to the filters listed above, accepts any valid Capybara global
77
+ # filter option.
78
+ def assert_no_turbo_cable_stream_source(...)
79
+ assert_no_selector(:turbo_cable_stream_source, ...)
80
+ end
81
+
82
+ Capybara.add_selector :turbo_cable_stream_source do
83
+ xpath do |locator|
84
+ xpath = XPath.descendant.where(XPath.local_name == "turbo-cable-stream-source")
85
+ xpath.where(SignedStreamNameConditions.new(locator).reduce(:|))
86
+ end
87
+
88
+ expression_filter :connected do |xpath, value|
89
+ builder(xpath).add_attribute_conditions(connected: value)
90
+ end
91
+
92
+ expression_filter :channel do |xpath, value|
93
+ builder(xpath).add_attribute_conditions(channel: value.try(:name) || value)
94
+ end
95
+
96
+ expression_filter :signed_stream_name do |xpath, value|
97
+ case value
98
+ when TrueClass, FalseClass, NilClass, Regexp
99
+ builder(xpath).add_attribute_conditions("signed-stream-name": value)
100
+ else
101
+ xpath.where(SignedStreamNameConditions.new(value).reduce(:|))
102
+ end
103
+ end
104
+ end
105
+
106
+ class SignedStreamNameConditions # :nodoc:
107
+ include Turbo::Streams::StreamName, Enumerable
108
+
109
+ def initialize(value)
110
+ @value = value
111
+ end
112
+
113
+ def attribute
114
+ XPath.attr(:"signed-stream-name")
115
+ end
116
+
117
+ def each
118
+ if @value.is_a?(String)
119
+ yield attribute == @value
120
+ yield attribute == signed_stream_name(@value)
121
+ elsif @value.is_a?(Array) || @value.respond_to?(:to_key)
122
+ yield attribute == signed_stream_name(@value)
123
+ elsif @value.present?
124
+ yield attribute == @value
125
+ end
126
+ end
127
+ end
128
+ end
data/lib/turbo/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Turbo
2
- VERSION = "2.0.6"
2
+ VERSION = "2.0.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: turbo-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.6
4
+ version: 2.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sam Stephenson
@@ -10,50 +10,36 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2024-07-19 00:00:00.000000000 Z
13
+ date: 2025-03-03 00:00:00.000000000 Z
14
14
  dependencies:
15
- - !ruby/object:Gem::Dependency
16
- name: activejob
17
- requirement: !ruby/object:Gem::Requirement
18
- requirements:
19
- - - ">="
20
- - !ruby/object:Gem::Version
21
- version: 6.0.0
22
- type: :runtime
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- version: 6.0.0
29
15
  - !ruby/object:Gem::Dependency
30
16
  name: actionpack
31
17
  requirement: !ruby/object:Gem::Requirement
32
18
  requirements:
33
19
  - - ">="
34
20
  - !ruby/object:Gem::Version
35
- version: 6.0.0
21
+ version: 7.1.0
36
22
  type: :runtime
37
23
  prerelease: false
38
24
  version_requirements: !ruby/object:Gem::Requirement
39
25
  requirements:
40
26
  - - ">="
41
27
  - !ruby/object:Gem::Version
42
- version: 6.0.0
28
+ version: 7.1.0
43
29
  - !ruby/object:Gem::Dependency
44
30
  name: railties
45
31
  requirement: !ruby/object:Gem::Requirement
46
32
  requirements:
47
33
  - - ">="
48
34
  - !ruby/object:Gem::Version
49
- version: 6.0.0
35
+ version: 7.1.0
50
36
  type: :runtime
51
37
  prerelease: false
52
38
  version_requirements: !ruby/object:Gem::Requirement
53
39
  requirements:
54
40
  - - ">="
55
41
  - !ruby/object:Gem::Version
56
- version: 6.0.0
42
+ version: 7.1.0
57
43
  description:
58
44
  email: david@loudthinking.com
59
45
  executables: []
@@ -93,7 +79,6 @@ files:
93
79
  - app/models/turbo/thread_debouncer.rb
94
80
  - app/views/layouts/turbo_rails/frame.html.erb
95
81
  - config/routes.rb
96
- - lib/install/turbo_needs_redis.rb
97
82
  - lib/install/turbo_with_bun.rb
98
83
  - lib/install/turbo_with_importmap.rb
99
84
  - lib/install/turbo_with_node.rb
@@ -101,6 +86,7 @@ files:
101
86
  - lib/turbo-rails.rb
102
87
  - lib/turbo/broadcastable/test_helper.rb
103
88
  - lib/turbo/engine.rb
89
+ - lib/turbo/system_test_helper.rb
104
90
  - lib/turbo/test_assertions.rb
105
91
  - lib/turbo/test_assertions/integration_test_assertions.rb
106
92
  - lib/turbo/version.rb
@@ -117,14 +103,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
103
  requirements:
118
104
  - - ">="
119
105
  - !ruby/object:Gem::Version
120
- version: 2.6.0
106
+ version: '3.1'
121
107
  required_rubygems_version: !ruby/object:Gem::Requirement
122
108
  requirements:
123
109
  - - ">="
124
110
  - !ruby/object:Gem::Version
125
111
  version: '0'
126
112
  requirements: []
127
- rubygems_version: 3.5.11
113
+ rubygems_version: 3.5.22
128
114
  signing_key:
129
115
  specification_version: 4
130
116
  summary: The speed of a single-page web application without having to write any JavaScript.
@@ -1,20 +0,0 @@
1
- if (cable_config_path = Rails.root.join("config/cable.yml")).exist?
2
- say "Enable redis in bundle"
3
-
4
- gemfile_content = File.read(Rails.root.join("Gemfile"))
5
- pattern = /gem ['"]redis['"]/
6
-
7
- if gemfile_content.match?(pattern)
8
- uncomment_lines "Gemfile", pattern
9
- else
10
- append_file "Gemfile", "\n# Use Redis for Action Cable"
11
- gem 'redis', '~> 4.0'
12
- end
13
-
14
- run_bundle
15
-
16
- say "Switch development cable to use redis"
17
- gsub_file cable_config_path.to_s, /development:\n\s+adapter: async/, "development:\n adapter: redis\n url: redis://localhost:6379/1"
18
- else
19
- say 'ActionCable config file (config/cable.yml) is missing. Uncomment "gem \'redis\'" in your Gemfile and create config/cable.yml to use the Turbo Streams broadcast feature.'
20
- end