action-cable-testing 0.5.0 → 0.6.0

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: e9193234672a859c68a8e8d2a68dab7a7ed89b8038f77f3ffd91cd9fc77f4fb8
4
- data.tar.gz: e314c6633804c930a8963f9c8b0540214b4e070f9d0c77c29199efc164c1f55f
3
+ metadata.gz: 4685e6b9a972c44862aaa6fe59c4454c93d4557cbad57bd1a2eefdf9e9f6e572
4
+ data.tar.gz: e3ca2c5959b3f55032da62efabd94ff7829e724957acb2cf67b94b98fd4c9771
5
5
  SHA512:
6
- metadata.gz: cbe3764f6edf4b3d894b59440c1591a50c6677270102f408314c4fb329e124ae88f903d0ba202125bc59fed96df22e5971734a568a5b84f3a87d59df19d2ecba
7
- data.tar.gz: bd252a3a5c11a65606c0da763e53b1a80a88a038e21f231ec902ae2f210d997589414e5b53f77e30ab655cb644a93184e12b3e211a3082160e6ddc6f57c461a5
6
+ metadata.gz: 0764c04d9aad6eb8eaa6a890c9e442053db169f1ec0676b00f45dc8e7345268c2688adad1db6afba1496f43d7e1e8e362cf366d66c75939dab402414734673d6
7
+ data.tar.gz: f2fe591556834380e989906a906bf2ba1a298098aa02675e4aa99a9b353902dd7cb775ca37a8fd60a44947c51d71bc6b1344358538d29b55700234e010c343d5
@@ -1,6 +1,10 @@
1
1
  # Change log
2
2
 
3
- ## master
3
+ ## 0.6.0 (2019-08-19)
4
+
5
+ - **Ruby 2.4+** is required.
6
+
7
+ - Fix Rails 6 compatibility. ([@palkan][])
4
8
 
5
9
  ## 0.5.0 (2019-02-24)
6
10
 
data/README.md CHANGED
@@ -4,13 +4,12 @@
4
4
 
5
5
  This gem provides missing testing utils for [Action Cable][].
6
6
 
7
- **NOTE:** this gem [has](https://github.com/rails/rails/pull/33659) [been](https://github.com/rails/rails/pull/33969) [merged](https://github.com/rails/rails/pull/34845) into Rails 6.0.
7
+ **NOTE:** this gem [has](https://github.com/rails/rails/pull/33659) [been](https://github.com/rails/rails/pull/33969) [merged](https://github.com/rails/rails/pull/34845) into Rails 6.0 and [into RSpec 4](https://github.com/rspec/rspec-rails/pull/2113).
8
8
 
9
9
  If you're using Minitest – you don't need this gem anymore.
10
10
 
11
11
  If you're using RSpec < 4, you still can use this gem to write Action Cable specs even for Rails 6.
12
12
 
13
-
14
13
  ## Installation
15
14
 
16
15
  Add this line to your application's Gemfile:
@@ -274,10 +273,10 @@ Or when broacasting to an object:
274
273
  ```ruby
275
274
  RSpec.describe CommentsController do
276
275
  describe "POST #create" do
277
- let(:post) { create :post }
276
+ let(:the_post) { create :post }
278
277
 
279
- expect { post :create, comment: { text: 'Cool!', post_id: post.id } }.to
280
- have_broadcasted_to(post).from_channel(PostChannel).with(text: 'Cool!')
278
+ expect { post :create, comment: { text: 'Cool!', post_id: the_post.id } }.to
279
+ have_broadcasted_to(the_post).from_channel(PostChannel).with(text: 'Cool!')
281
280
  end
282
281
  end
283
282
  ```
@@ -337,6 +336,8 @@ end
337
336
 
338
337
  #### Shared contexts to switch between adapters
339
338
 
339
+ **NOTE:** this feature is gem-only and hasn't been migrated to RSpec 4. You can still use the gem for that by adding `require "rspec/rails/shared_contexts/action_cable"` to your `rspec_helper.rb`.
340
+
340
341
  Sometimes you may want to use _real_ Action Cable adapter instead of the test one (for example, in Capybara-like tests).
341
342
 
342
343
  We provide shared contexts to do that:
@@ -5,6 +5,9 @@ require "active_support/test_case"
5
5
  require "active_support/core_ext/hash/indifferent_access"
6
6
  require "json"
7
7
 
8
+ require "action_cable/testing/rails_six"
9
+ using ActionCable::Testing::Rails6
10
+
8
11
  module ActionCable
9
12
  module Channel
10
13
  class NonInferrableChannelError < ::StandardError
@@ -292,9 +295,7 @@ module ActionCable
292
295
  def broadcasting_for(stream_or_object)
293
296
  return stream_or_object if stream_or_object.is_a?(String)
294
297
 
295
- self.class.channel_class.broadcasting_for(
296
- [self.class.channel_class.channel_name, stream_or_object]
297
- )
298
+ self.class.channel_class.broadcasting_for(stream_or_object)
298
299
  end
299
300
  end
300
301
 
@@ -15,7 +15,7 @@ module ActionCable
15
15
  module Rails6
16
16
  begin
17
17
  # Has been added only after 6.0.0.beta1
18
- unless ActionCable::Channel.respond_to?(:serialize_broadcasting)
18
+ unless ActionCable::Channel::Base.respond_to?(:serialize_broadcasting)
19
19
  refine ActionCable::Channel::Broadcasting::ClassMethods do
20
20
  def broadcasting_for(model)
21
21
  super([channel_name, model])
@@ -2,25 +2,38 @@
2
2
 
3
3
  require "action-cable-testing"
4
4
  require "rspec/rails"
5
- require "rspec/rails/example/channel_example_group"
6
- require "rspec/rails/matchers/action_cable"
7
- require "rspec/rails/shared_contexts/action_cable"
8
5
 
9
- module RSpec # :nodoc:
10
- module Rails
11
- module FeatureCheck
12
- module_function
13
- def has_action_cable?
14
- defined?(::ActionCable)
15
- end
16
- end
6
+ if RSpec::Rails::FeatureCheck.respond_to?(:has_action_cable_testing?)
7
+ warn <<~MSG
8
+ You're using RSpec with Action Cable support.
9
+
10
+ You can remove `require "action_cable/testing/rspec"` from your RSpec setup.
11
+
12
+ NOTE: if you use Action Cable shared contexts ("action_cable:async", "action_cable:inline", etc.)
13
+ you still need to use the gem and add `require "rspec/rails/shared_contexts/action_cable"`.
14
+ MSG
15
+ else
16
+ require "rspec/rails/example/channel_example_group"
17
+ require "rspec/rails/matchers/action_cable"
18
+
19
+ module RSpec # :nodoc:
20
+ module Rails
21
+ module FeatureCheck
22
+ module_function
23
+ def has_action_cable_testing?
24
+ defined?(::ActionCable)
25
+ end
26
+ end
17
27
 
18
- self::DIRECTORY_MAPPINGS[:channel] = %w[spec channels]
28
+ self::DIRECTORY_MAPPINGS[:channel] = %w[spec channels]
29
+ end
19
30
  end
20
- end
21
31
 
22
- RSpec.configure do |config|
23
- if defined?(ActionCable)
24
- config.include RSpec::Rails::ChannelExampleGroup, type: :channel
32
+ RSpec.configure do |config|
33
+ if defined?(ActionCable)
34
+ config.include RSpec::Rails::ChannelExampleGroup, type: :channel
35
+ end
25
36
  end
26
37
  end
38
+
39
+ require "rspec/rails/shared_contexts/action_cable"
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "action_cable/testing/rails_six"
4
+ using ActionCable::Testing::Rails6
5
+
3
6
  module ActionCable
4
7
  # Provides helper methods for testing Action Cable broadcasting
5
8
  module TestHelper
@@ -144,7 +147,7 @@ module ActionCable
144
147
  channel ||= @subscription
145
148
  return target unless channel && channel.respond_to?(:channel_name)
146
149
 
147
- channel.broadcasting_for([channel.channel_name, target])
150
+ channel.broadcasting_for(target)
148
151
  end
149
152
 
150
153
  def warn_deprecated_channel!
@@ -2,6 +2,6 @@
2
2
 
3
3
  module ActionCable
4
4
  module Testing
5
- VERSION = "0.5.0"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
@@ -1,5 +1,8 @@
1
1
  # rubocop: disable Style/FrozenStringLiteralComment
2
2
 
3
+ require "action_cable/testing/rails_six"
4
+ using ActionCable::Testing::Rails6
5
+
3
6
  module RSpec
4
7
  module Rails
5
8
  module Matchers
@@ -101,7 +104,7 @@ module RSpec
101
104
  @target
102
105
  else
103
106
  check_channel_presence
104
- @channel.broadcasting_for([@channel.channel_name, @target])
107
+ @channel.broadcasting_for(@target)
105
108
  end
106
109
  end
107
110
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: action-cable-testing
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vladimir Dementyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-02-25 00:00:00.000000000 Z
11
+ date: 2019-08-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: actioncable
@@ -128,14 +128,14 @@ dependencies:
128
128
  requirements:
129
129
  - - "~>"
130
130
  - !ruby/object:Gem::Version
131
- version: '0.51'
131
+ version: 0.68.0
132
132
  type: :development
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
136
  - - "~>"
137
137
  - !ruby/object:Gem::Version
138
- version: '0.51'
138
+ version: 0.68.0
139
139
  description: Testing utils for Action Cable
140
140
  email:
141
141
  - dementiev.vm@gmail.com
@@ -178,15 +178,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
178
178
  requirements:
179
179
  - - ">="
180
180
  - !ruby/object:Gem::Version
181
- version: 2.3.0
181
+ version: 2.4.0
182
182
  required_rubygems_version: !ruby/object:Gem::Requirement
183
183
  requirements:
184
184
  - - ">="
185
185
  - !ruby/object:Gem::Version
186
186
  version: '0'
187
187
  requirements: []
188
- rubyforge_project:
189
- rubygems_version: 2.7.6
188
+ rubygems_version: 3.0.4
190
189
  signing_key:
191
190
  specification_version: 4
192
191
  summary: Testing utils for Action Cable