Class: Mini::Spec

Inherits:
Test::TestCase show all
Defined in:
lib/mini/spec.rb

Instance Attribute Summary

Attributes inherited from Test::TestCase

#name

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Test::TestCase

inherited, reset, #run, #setup, #teardown, test_methods, test_order, test_suites

Methods included from Assertions

#_assertions, #_assertions=, #assert, #assert_block, #assert_empty, #assert_equal, #assert_in_delta, #assert_in_epsilon, #assert_includes, #assert_instance_of, #assert_kind_of, #assert_match, #assert_nil, #assert_operator, #assert_raises, #assert_respond_to, #assert_same, #assert_throws, #capture_io, #exception_details, #fail, #message, #mu_pp, #pass, #refute, #refute_empty, #refute_equal, #refute_in_delta, #refute_in_epsilon, #refute_includes, #refute_instance_of, #refute_kind_of, #refute_match, #refute_nil, #refute_operator, #refute_respond_to, #refute_same

Constructor Details

#initialize(name) ⇒ Spec

Returns a new instance of Spec.



64
65
66
67
# File 'lib/mini/spec.rb', line 64

def initialize name
  super
  @@current_spec = self
end

Class Method Details

.after(type = :each, &block) ⇒ Object



74
75
76
77
# File 'lib/mini/spec.rb', line 74

def self.after(type = :each, &block)
  raise "unsupported after type: #{type}" unless type == :each
  define_method :teardown, &block
end

.before(type = :each, &block) ⇒ Object



69
70
71
72
# File 'lib/mini/spec.rb', line 69

def self.before(type = :each, &block)
  raise "unsupported before type: #{type}" unless type == :each
  define_method :setup, &block
end

.currentObject



60
61
62
# File 'lib/mini/spec.rb', line 60

def self.current
  @@current_spec
end

.it(desc, &block) ⇒ Object



79
80
81
# File 'lib/mini/spec.rb', line 79

def self.it desc, &block
  define_method "test_#{desc.gsub(/\W+/, '_').downcase}", &block
end