Module: Sapphire::DSL::Coverage

Included in:
Sapphire
Defined in:
lib/sapphire/DSL/Coverage/Covers.rb,
lib/sapphire/DSL/Coverage/Feature.rb,
lib/sapphire/DSL/Coverage/Behavior.rb,
lib/sapphire/DSL/Coverage/Describe.rb,
lib/sapphire/DSL/Coverage/Requirement.rb

Defined Under Namespace

Classes: Behavior, Feature, Requirement

Instance Method Summary collapse

Instance Method Details

#Behavior(token, hash) ⇒ Object



4
5
6
# File 'lib/sapphire/DSL/Coverage/Behavior.rb', line 4

def Behavior(token, hash)
  $features.last().AddBehavior(Behavior.new(token, hash))
end

#Covers(hash) ⇒ Object

def Covers(item)

Runner.instance.last_test_plan.Cover(item)

end



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/sapphire/DSL/Coverage/Covers.rb', line 8

def Covers(hash)
  token = hash.keys.first
  target = hash[hash.keys.first]

  if(token == :feature)
    $current_feature = target
  elsif(token == :requirement)
    $current_rule = target
  elsif(token == :behavior)
    feature = $features.select { |f| f.token == $current_feature }[0]
    requirement = feature.requirements.select { |r| r.token == $current_rule }[0]
    test = requirement.behaviors.select { |t| t.token == target }[0]
    test.is_covered = true
  end
end

#Describe(text) ⇒ Object



4
5
6
# File 'lib/sapphire/DSL/Coverage/Describe.rb', line 4

def Describe(text)
  $features.last().Describe(text)
end

#Feature(token, &block) ⇒ Object



4
5
6
7
8
# File 'lib/sapphire/DSL/Coverage/Feature.rb', line 4

def Feature(token, &block)
  $features ||= []
  $features << Feature.new(token)
  block.call
end

#Requirement(token, hash, &block) ⇒ Object



4
5
6
7
# File 'lib/sapphire/DSL/Coverage/Requirement.rb', line 4

def Requirement(token, hash, &block)
  $features.last.AddRequirement(Requirement.new(token, hash))
  block.call
end