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.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 Style/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
-
#initialize(stream) ⇒ 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) ⇒ Object private
Constructor Details
#initialize(stream) ⇒ 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 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 13 def initialize(stream) @stream = stream @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.
31 32 33 34 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 31 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.
36 37 38 39 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 36 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.
26 27 28 29 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 26 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.
57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 57 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.
68 69 70 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 68 def "expected not to broadcast #{}" 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.
84 85 86 87 88 89 90 91 92 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 84 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.
72 73 74 75 76 77 78 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 72 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.
45 46 47 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 45 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.
80 81 82 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 80 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.
53 54 55 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 53 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.
41 42 43 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 41 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.
49 50 51 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 49 def twice exactly(:twice) end |
#with(data = nil) ⇒ 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.
19 20 21 22 23 24 |
# File 'lib/rspec/rails/matchers/action_cable.rb', line 19 def with(data = nil) @data = data @data = @data.with_indifferent_access if @data.is_a?(Hash) @block = Proc.new if block_given? self end |