123456789_123456789_123456789_123456789_123456789_

Module: RSpec::Rails::ChannelExampleGroup

Relationships & Source Files
Namespace Children
Modules:
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
Instance Chain:
self, ActionCable::Channel::TestCase::Behavior, ActionCable::Connection::TestCase::Behavior, RailsExampleGroup, ActiveSupport::ExecutionContext::TestHelper, ActiveSupport::CurrentAttributes::TestHelper, TaggedLoggingAdapter, FixtureSupport::Fixtures, FixtureSupport, ActiveRecord::TestFixtures, MinitestAssertionAdapter, MinitestLifecycleAdapter, SetupAndTeardownAdapter
Defined in: rspec-rails/lib/rspec/rails/example/channel_example_group.rb,
rspec-rails/lib/rspec/rails/example/channel_example_group.rb

Overview

Container module for channel spec functionality. It is only available if ActionCable has been loaded before it.

Class Method Summary

MinitestAssertionAdapter::ClassMethods - Extended

assertion_method_names

Returns the names of assertion methods that we want to expose to examples without exposing non-assertion methods in Test::Unit or Minitest.

define_assertion_delegators

SetupAndTeardownAdapter::ClassMethods - Extended

setup

Wraps ‘setup` calls from within Rails’ testing framework in ‘before` hooks.

teardown

Wraps ‘teardown` calls from within Rails’ testing framework in ‘after` hooks.

Instance Attribute Summary

FixtureSupport - Included

#run_in_transaction?

Monkey patched to avoid collisions with ‘let(:name)’ in ::RSpec::Rails 6.1 and after and let(:method_name) before ::RSpec::Rails 6.1.

Instance Method Summary

TaggedLoggingAdapter - Included

#tagged_logger

Vendored from activesupport/lib/active_support/testing/tagged_logging.rb This implements the tagged_logger method where it is expected, but doesn’t call ‘name` or set it up like ::RSpec::Rails does.

MinitestAssertionAdapter - Included

MinitestLifecycleAdapter - Included

SetupAndTeardownAdapter - Included

Instance Method Details

#have_rejected_connection

Checks that the connection attempt has been rejected.

Examples:

expect { connect }.to have_rejected_connection
[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/example/channel_example_group.rb', line 58

def have_rejected_connection
  raise_error(::ActionCable::Connection::Authorization::UnauthorizedError)
end

#have_stream_for(object)

Checks that the channel has been subscribed to a stream for the given model

Examples:

expect(subscription).to have_stream_for(user)
[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/example/channel_example_group.rb', line 86

def have_stream_for(object)
  check_subscribed!
  RSpec::Rails::Matchers::ActionCable::HaveStream.new(broadcasting_for(object))
end

#have_stream_from(stream)

Checks that the channel has been subscribed to the given stream

Examples:

expect(subscription).to have_stream_from("chat_1")
[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/example/channel_example_group.rb', line 76

def have_stream_from(stream)
  check_subscribed!

  RSpec::Rails::Matchers::ActionCable::HaveStream.new(stream)
end

#have_streams

Checks that the subscription is subscribed to at least one stream.

Examples:

expect(subscription).to have_streams
[ GitHub ]

  
# File 'rspec-rails/lib/rspec/rails/example/channel_example_group.rb', line 66

def have_streams
  check_subscribed!

  RSpec::Rails::Matchers::ActionCable::HaveStream.new
end