# # Oh look! A Minitest::Spec::DSL module! Eat your heart out DHH. # module Minitest::Spec::DSL # # Register a new type of spec that matches the spec's description. This method # can take either a Regexp and a spec class or a spec class and a block that # takes the description and returns true if it matches. # # Eg: # # register_spec_type(/Controller$/, Minitest::Spec::Rails) # # or: # # register_spec_type(Minitest::Spec::RailsModel) do |desc| # desc.superclass == ActiveRecord::Base # end # def register_spec_type: (*untyped args) ?{ () -> untyped } -> untyped # # Figure out the spec class to use based on a spec's description. Eg: # # spec_type("BlahController") # => Minitest::Spec::Rails # def spec_type: (untyped desc, *untyped additional) -> untyped def describe_stack: () -> untyped def children: () -> untyped def nuke_test_methods!: () -> untyped # # Define a 'before' action. Inherits the way normal methods should. # # NOTE: `type` is ignored and is only there to make porting easier. # # Equivalent to Minitest::Test#setup. # def before: (?untyped? _type) ?{ () -> untyped } -> untyped # # Define an 'after' action. Inherits the way normal methods should. # # NOTE: `type` is ignored and is only there to make porting easier. # # Equivalent to Minitest::Test#teardown. # def after: (?untyped? _type) ?{ () -> untyped } -> untyped # # Define an expectation with name `desc`. Name gets morphed to a proper test # method name. For some freakish reason, people who write specs don't like class # inheritance, so this goes way out of its way to make sure that expectations # aren't inherited. # # This is also aliased to #specify and doesn't require a `desc` arg. # # Hint: If you *do* want inheritance, use minitest/test. You can mix and match # between assertions and expectations as much as you want. # def it: (?::String desc) ?{ () -> untyped } -> untyped # # Essentially, define an accessor for `name` with `block`. # # Why use let instead of def? I honestly don't know. # def let: (untyped name) ?{ () -> untyped } -> untyped # # Another lazy man's accessor generator. Made even more lazy by setting the name # for you to `subject`. # def subject: () ?{ () -> untyped } -> untyped def create: (untyped name, untyped desc) -> untyped def name: () -> untyped def to_s: () -> untyped # # alias specify it def self.extended: (untyped obj) -> untyped attr_reader desc: untyped # # Contains pairs of matchers and Spec classes to be used to calculate the # superclass of a top-level describe. This allows for automatically customizable # spec types. # # See: register_spec_type and spec_type # TYPES: Array[Array[Regexp | singleton(Minitest::BenchSpec)] | Array[Regexp | singleton(Minitest::Spec)]] end