module Minitest::Spec::DSL

Extend Minitest Spec DSL with custom methodss

Public Instance Methods

channel(id = nil, &block) click to toggle source

Generates Channel class dynamically and add memoized helper to access its name

# File lib/anyt/ext/minitest.rb, line 93
def channel(id = nil, &block)
  class_name = @name.gsub(/\s+/, "_")
  class_name += "_#{id}" if id
  class_name += "_channel"

  cls = Class.new(ApplicationCable::Channel, &block)

  Anyt::TestChannels.const_set(class_name.classify, cls)

  helper_name = id ? "#{id}_channel" : "channel"

  let(helper_name) { cls.name }
end
connect_handler(tag, &block) click to toggle source

Add new connect handler

# File lib/anyt/ext/minitest.rb, line 108
def connect_handler(tag, &block)
  Anyt::ConnectHandlers.add(tag, &block)
end
scenario(desc, &block) click to toggle source

Simplified version of `it` which doesn't care about unique method names

# File lib/anyt/ext/minitest.rb, line 83
def scenario(desc, &block)
  block ||= proc { skip "(no tests defined)" }

  define_method "test_ #{desc}", &block

  desc
end