Module: Testa
- Defined in:
- lib/testa.rb,
lib/testa/version.rb
Defined Under Namespace
Modules: Matcher Classes: Context, Failure, Reporter, Result, Test
Constant Summary collapse
- VERSION =
"0.0.1"
Class Method Summary collapse
-
.config ⇒ Object
Configuration.
- .run ⇒ Object
- .run! ⇒ Object
- .tests ⇒ Object
Instance Method Summary collapse
-
#test(description = nil, options = {}, &block) ⇒ Object
Create a test.
Class Method Details
.config ⇒ Object
Configuration
:matchers - {Array of Module} module(s) containing assertion helpers
:reporter - {Object} whose class inherits ReporterBase
:filters - {Array of Callable} filter out some tests
22 23 24 25 26 |
# File 'lib/testa.rb', line 22 def config @config ||= {:matchers => [Matcher], :reporter => Reporter.new, :filters => []} end |
.run ⇒ Object
28 29 30 31 32 33 34 |
# File 'lib/testa.rb', line 28 def run Testa::Context.send(:include, *config[:matchers]) reporter = config[:reporter] runnable.each { |t| reporter.after_each(t.call) } reporter.after_all(results) results.none? { |r| [:error, :failed].include? r.status } end |
.run! ⇒ Object
36 37 38 |
# File 'lib/testa.rb', line 36 def run! exit(run ? 0 : 1) end |
.tests ⇒ Object
40 41 42 |
# File 'lib/testa.rb', line 40 def tests @tests ||= [] end |
Instance Method Details
#test(description = nil, options = {}, &block) ⇒ Object
Create a test
description - {String} test's description string. Default is nil
options - {Hash} meta data
block - {Block} test code
10 11 12 13 |
# File 'lib/testa.rb', line 10 def test description=nil, ={}, &block location = caller(0)[1].split(":").tap(&:pop).join ":" Testa.tests << Test.new(location, description, , &block) end |