Class: Appetizer::Test
- Inherits:
-
MiniTest::Unit::TestCase
- Object
- MiniTest::Unit::TestCase
- Appetizer::Test
- Defined in:
- lib/appetizer/test.rb
Class Method Summary collapse
- .setup(&block) ⇒ Object
- .setups ⇒ Object
- .teardown(&block) ⇒ Object
- .teardowns ⇒ Object
- .test(name, &block) ⇒ Object
Instance Method Summary collapse
Class Method Details
.setup(&block) ⇒ Object
15 16 17 |
# File 'lib/appetizer/test.rb', line 15 def self.setup &block setups << block end |
.setups ⇒ Object
19 20 21 22 23 24 |
# File 'lib/appetizer/test.rb', line 19 def self.setups @setups ||= (ancestors - [self]). map { |a| a.respond_to?(:setups) && a.setups }. select { |s| s }. compact.flatten.reverse end |
.teardown(&block) ⇒ Object
26 27 28 |
# File 'lib/appetizer/test.rb', line 26 def self.teardown &block teardowns.unshift block end |
.teardowns ⇒ Object
30 31 32 33 34 35 |
# File 'lib/appetizer/test.rb', line 30 def self.teardowns @teardowns ||= (ancestors - [self]). map { |a| a.respond_to?(:teardowns) && a.teardowns }. select { |t| t}. compact.flatten end |
.test(name, &block) ⇒ Object
37 38 39 |
# File 'lib/appetizer/test.rb', line 37 def self.test name, &block define_method "test #{name}", &block end |
Instance Method Details
#setup ⇒ Object
7 8 9 |
# File 'lib/appetizer/test.rb', line 7 def setup self.class.setups.each { |s| instance_eval(&s) } end |
#teardown ⇒ Object
11 12 13 |
# File 'lib/appetizer/test.rb', line 11 def teardown self.class.teardowns.each { |t| instance_eval(&t) } end |