Class MiniTest::Spec
In: lib/minitest/spec.rb
lib/minitest/benchmark.rb
Parent: MiniTest::Unit::TestCase

MiniTest::Spec — The faster, better, less-magical spec framework!

For a list of expectations, see MiniTest::Expectations.

Methods

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

NAME_RE = if RUBY_VERSION >= "1.9"

Public Class 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.

This is used to define a new benchmark method. You usually don‘t use this directly and is intended for those needing to write new performance curve fits (eg: you need a specific polynomial fit).

See ::bench_performance_linear for an example of how to use this.

Create a benchmark that verifies that the performance is constant.

  describe "my class" do
    bench_performance_constant "zoom_algorithm!" do |n|
      @obj.zoom_algorithm!(n)
    end
  end

Create a benchmark that verifies that the performance is exponential.

  describe "my class" do
    bench_performance_exponential "algorithm" do |n|
      @obj.algorithm(n)
    end
  end

Create a benchmark that verifies that the performance is linear.

  describe "my class" do
    bench_performance_linear "fast_algorithm", 0.9999 do |n|
      @obj.fast_algorithm(n)
    end
  end

Specifies the ranges used for benchmarking for that class.

  bench_range do
    bench_exp(2, 16, 2)
  end

See Unit::TestCase.bench_range for more details.

Returns the children of this spec.

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

[Validate]