Module: ActionCable::Channel::TestCase::Behavior::ClassMethods

Defined in:
lib/action_cable/testing/channel/test_case.rb

Instance Method Summary collapse

Instance Method Details

#channel_classObject



183
184
185
186
187
188
189
# File 'lib/action_cable/testing/channel/test_case.rb', line 183

def channel_class
  if channel = self._channel_class
    channel
  else
    tests determine_default_channel(name)
  end
end

#determine_default_channel(name) ⇒ Object



191
192
193
194
195
196
197
# File 'lib/action_cable/testing/channel/test_case.rb', line 191

def determine_default_channel(name)
  channel = determine_constant_from_test_name(name) do |constant|
    Class === constant && constant < ActionCable::Channel::Base
  end
  raise NonInferrableChannelError.new(name) if channel.nil?
  channel
end

#tests(channel) ⇒ Object



172
173
174
175
176
177
178
179
180
181
# File 'lib/action_cable/testing/channel/test_case.rb', line 172

def tests(channel)
  case channel
  when String, Symbol
    self._channel_class = channel.to_s.camelize.constantize
  when Module
    self._channel_class = channel
  else
    raise NonInferrableChannelError.new(channel)
  end
end