Class: Specifier::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/specifier/context.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(scope, &block) ⇒ Context

Returns a new instance of Context.



7
8
9
10
11
# File 'lib/specifier/context.rb', line 7

def initialize(scope, &block)
  @_scope = scope
  @_block = block
  @_examples = Set.new
end

Instance Attribute Details

#parentObject

Returns the value of attribute parent.



5
6
7
# File 'lib/specifier/context.rb', line 5

def parent
  @parent
end

Instance Method Details

#describe(scope, &block) ⇒ Object



13
14
15
16
17
# File 'lib/specifier/context.rb', line 13

def describe(scope, &block)
  context = Context.new(scope, &block)
  context.parent = self
  context.run
end

#it(descriptor, &block) ⇒ Object



19
20
21
# File 'lib/specifier/context.rb', line 19

def it(descriptor, &block)
  @_examples << Example.new(descriptor, &block)
end

#runObject



23
24
25
26
27
28
# File 'lib/specifier/context.rb', line 23

def run
  instance_eval(&@_block)
  @_examples.each do |example|
    Specifier.formatter.record(example, example.run)
  end
end