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

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

For a list of expectations, see Object.

Methods

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
      @obj.zoom_algorithm!
    end
  end

Create a benchmark that verifies that the performance is exponential.

  describe "my class" do
    bench_performance_exponential "algorithm" do
      @obj.algorithm
    end
  end

Create a benchmark that verifies that the performance is linear.

  describe "my class" do
    bench_performance_linear "fast_algorithm", 0.9999 do
      @obj.fast_algorithm
    end
  end

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 inheritence, so this goes way out of its way to make sure that expectations aren‘t inherited.

Hint: If you do want inheritence, use minitest/unit. You can mix and match between assertions and expectations as much as you want.

[Validate]