Class: RSpec::Rails::Matchers::ActionCable::HaveBroadcastedTo Private
- Inherits:
-
Matchers::BuiltIn::BaseMatcher
- Object
- Matchers::BuiltIn::BaseMatcher
- RSpec::Rails::Matchers::ActionCable::HaveBroadcastedTo
- Defined in:
- lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
rubocop: disable Metrics/ClassLength
Instance Method Summary collapse
- #at_least(count) ⇒ Object private
- #at_most(count) ⇒ Object private
- #exactly(count) ⇒ Object private
- #failure_message ⇒ Object private
- #failure_message_when_negated ⇒ Object private
- #from_channel(channel) ⇒ Object private
-
#initialize(target, channel:) ⇒ HaveBroadcastedTo
constructor
private
A new instance of HaveBroadcastedTo.
- #matches?(proc) ⇒ Boolean private
- #message_expectation_modifier ⇒ Object private
- #once ⇒ Object private
- #supports_block_expectations? ⇒ Boolean private
- #thrice ⇒ Object private
- #times ⇒ Object private
- #twice ⇒ Object private
- #with(data = nil, &block) ⇒ Object private
Constructor Details
#initialize(target, channel:) ⇒ HaveBroadcastedTo
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of HaveBroadcastedTo.
13 14 15 16 17 18 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 13 def initialize(target, channel:) @target = target @channel = channel @block = Proc.new {} set_expected_number(:exactly, 1) end |
Instance Method Details
#at_least(count) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
32 33 34 35 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 32 def at_least(count) set_expected_number(:at_least, count) self end |
#at_most(count) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 37 def at_most(count) set_expected_number(:at_most, count) self end |
#exactly(count) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
27 28 29 30 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 27 def exactly(count) set_expected_number(:exactly, count) self end |
#failure_message ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
58 59 60 61 62 63 64 65 66 67 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 58 def "expected to broadcast #{}".tap do |msg| if @unmatching_msgs.any? msg << "\nBroadcasted messages to #{stream}:" @unmatching_msgs.each do |data| msg << "\n #{data}" end end end end |
#failure_message_when_negated ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
69 70 71 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 69 def "expected not to broadcast #{}" end |
#from_channel(channel) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
95 96 97 98 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 95 def from_channel(channel) @channel = channel self end |
#matches?(proc) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
85 86 87 88 89 90 91 92 93 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 85 def matches?(proc) raise ArgumentError, "have_broadcasted_to and broadcast_to only support block expectations" unless Proc === proc = pubsub_adapter.broadcasts(stream).size proc.call = pubsub_adapter.broadcasts(stream).drop() check() end |
#message_expectation_modifier ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
73 74 75 76 77 78 79 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 73 def case @expectation_type when :exactly then "exactly" when :at_most then "at most" when :at_least then "at least" end end |
#once ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
46 47 48 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 46 def once exactly(:once) end |
#supports_block_expectations? ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
81 82 83 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 81 def supports_block_expectations? true end |
#thrice ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
54 55 56 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 54 def thrice exactly(:thrice) end |
#times ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
42 43 44 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 42 def times self end |
#twice ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
50 51 52 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 50 def twice exactly(:twice) end |
#with(data = nil, &block) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
20 21 22 23 24 25 |
# File 'lib/rspec/rails/matchers/action_cable/have_broadcasted_to.rb', line 20 def with(data = nil, &block) @data = data @data = @data.with_indifferent_access if @data.is_a?(Hash) @block = block if block_given? self end |