class RSpec::Rails::Matchers::ActionCable::HaveStream
@api private Provides the implementation for `have_stream`, `have_stream_for`, and `have_stream_from`. Not intended to be instantiated directly.
Public Instance Methods
does_not_match?(subscription)
click to toggle source
@api private @return [Boolean]
# File lib/rspec/rails/matchers/action_cable/have_streams.rb, line 33 def does_not_match?(subscription) !match(subscription) end
failure_message()
click to toggle source
@api private @return [String]
# File lib/rspec/rails/matchers/action_cable/have_streams.rb, line 13 def failure_message "expected to have #{base_message}" end
failure_message_when_negated()
click to toggle source
@api private @return [String]
# File lib/rspec/rails/matchers/action_cable/have_streams.rb, line 19 def failure_message_when_negated "expected not to have #{base_message}" end
matches?(subscription)
click to toggle source
@api private @return [Boolean]
# File lib/rspec/rails/matchers/action_cable/have_streams.rb, line 25 def matches?(subscription) raise(ArgumentError, "have_streams is used for negated expectations only") if no_expected? match(subscription) end
Private Instance Methods
base_message()
click to toggle source
# File lib/rspec/rails/matchers/action_cable/have_streams.rb, line 49 def base_message no_expected? ? "any stream started" : "stream #{expected_formatted} started, but have #{actual_formatted}" end
match(subscription)
click to toggle source
# File lib/rspec/rails/matchers/action_cable/have_streams.rb, line 39 def match(subscription) case subscription when ::ActionCable::Channel::Base @actual = subscription.streams no_expected? ? actual.any? : actual.any? { |i| expected === i } else raise ArgumentError, "have_stream, have_stream_from and have_stream_from support expectations on subscription only" end end
no_expected?()
click to toggle source
# File lib/rspec/rails/matchers/action_cable/have_streams.rb, line 53 def no_expected? !defined?(@expected) end