Class: Neospec::Suite

Inherits:
Object
  • Object
show all
Defined in:
lib/neospec/suite.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(runner: Neospec::Runner::Basic.new) ⇒ Suite

Returns a new instance of Suite.



5
6
7
8
9
10
11
12
# File 'lib/neospec/suite.rb', line 5

def initialize(runner: Neospec::Runner::Basic.new)
  @runner = runner
  @specs = []
  @setup = -> {}
  @teardown = -> {}
  @before = -> {}
  @after = -> {}
end

Instance Attribute Details

#runnerObject

Returns the value of attribute runner.



3
4
5
# File 'lib/neospec/suite.rb', line 3

def runner
  @runner
end

#specsObject

Returns the value of attribute specs.



3
4
5
# File 'lib/neospec/suite.rb', line 3

def specs
  @specs
end

Instance Method Details

#after(&block) ⇒ Object



49
50
51
52
53
54
55
# File 'lib/neospec/suite.rb', line 49

def after(&block)
  if block_given?
    @after = block
  else
    @after
  end
end

#before(&block) ⇒ Object



41
42
43
44
45
46
47
# File 'lib/neospec/suite.rb', line 41

def before(&block)
  if block_given?
    @before = block
  else
    @before
  end
end

#describe(description, &block) ⇒ Object



18
19
20
21
22
23
# File 'lib/neospec/suite.rb', line 18

def describe(description, &block)
  @specs << Neospec::Spec.new(
    description: description,
    block: block
  )
end

#resultsObject



14
15
16
# File 'lib/neospec/suite.rb', line 14

def results
  @specs.map(&:result)
end

#run(logger:) ⇒ Object



57
58
59
60
61
62
# File 'lib/neospec/suite.rb', line 57

def run(logger:)
  runner.run(
    logger: logger,
    suite: self
  )
end

#setup(&block) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/neospec/suite.rb', line 25

def setup(&block)
  if block_given?
    @setup = block
  else
    @setup
  end
end

#teardown(&block) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/neospec/suite.rb', line 33

def teardown(&block)
  if block_given?
    @teardown = block
  else
    @teardown
  end
end