Module MiniTest::Spec::DSL
In: lib/minitest/spec.rb

Oh look! A MiniTest::Spec::DSL module! Eat your heart out DHH.

Methods

after   before   children   it   let   register_spec_type   spec_type   subject  

Constants

TYPES = [[//, MiniTest::Spec]]   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

Public Instance methods

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::Unit::TestCase#teardown.

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::Unit::TestCase#setup.

Returns the children of this spec.

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 inheritence, use minitest/unit. You can mix and match between assertions and expectations as much as you want.

Essentially, define an accessor for name with block.

Why use let instead of def? I honestly don‘t know.

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

Figure out the spec class to use based on a spec‘s description. Eg:

    spec_type("BlahController") # => MiniTest::Spec::Rails

Another lazy man‘s accessor generator. Made even more lazy by setting the name for you to subject.

[Validate]