Class: Purobu::DSL

Inherits:
Object
  • Object
show all
Defined in:
lib/purobu/dsl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ DSL

Returns a new instance of DSL.



5
6
7
8
# File 'lib/purobu/dsl.rb', line 5

def initialize(opts = {})
  @runner = Runner.new
  @files  = opts[:files] || Dir['tests/**/test*.rb']
end

Instance Attribute Details

#filesObject (readonly)

Returns the value of attribute files.



3
4
5
# File 'lib/purobu/dsl.rb', line 3

def files
  @files
end

#runnerObject (readonly)

Returns the value of attribute runner.



3
4
5
# File 'lib/purobu/dsl.rb', line 3

def runner
  @runner
end

Instance Method Details

#load_testsObject



23
24
25
# File 'lib/purobu/dsl.rb', line 23

def load_tests
  files.each { |f| instance_eval(File.read(f)) }
end

#runObject



18
19
20
21
# File 'lib/purobu/dsl.rb', line 18

def run
  load_tests
  runner.run
end

#test(name = nil, &block) ⇒ Object



10
11
12
# File 'lib/purobu/dsl.rb', line 10

def test(name = nil, &block)
  runner.tests.push( Test.new(name).tap { |t| t.instance_eval(&block) } )
end

#testsObject



14
15
16
# File 'lib/purobu/dsl.rb', line 14

def tests
  runner.tests
end