Class: Probatio::Group

Inherits:
Section show all
Includes:
Helpers
Defined in:
lib/probatio.rb,
lib/probatio/helpers.rb

Constant Summary

Constants inherited from Section

Section::ATTRS, Section::METHS

Instance Attribute Summary

Attributes inherited from Node

#block, #children, #opts, #parent, #path

Instance Method Summary collapse

Methods included from Helpers

#beep, #jruby?, #time, #windows?

Methods inherited from Section

#add_block, #add_file, #add_section, #after, #afters, #all_tests, #around, #arounds, #before, #befores, #context, #initialize, #method_missing, #path=, #run, #setup, #skip?, #teardown

Methods included from Waiters

#monow, #wait_until

Methods inherited from Node

#array_name, #depth, #filename, #full_name, #groups, #head, #initialize, #last_line, #line, #location, #map, #name, #path_and_line, #pending?, #root, #skip?, #test?, #to_s, #trail, #type

Constructor Details

This class inherits a constructor from Probatio::Section

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Probatio::Section

Instance Method Details

#group(*names, &block) ⇒ Object



581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
# File 'lib/probatio.rb', line 581

def group(*names, &block)

  opts = names.last.is_a?(Hash) ? names.pop : {}

  names = names
    .collect { |s| s.to_s.split(/\s*(?:\||;|<|>)\s*/) }
    .flatten(1)

  last_name = names.last

  names.inject(self) do |g, name|

    gg = g.groups.find { |e| e.name == name }

    if gg
      gg.path = @path
    else
      gg = Probatio::Group.new(g, @path, name, opts, block)
      g.children << gg
    end

    gg.add_block(block) if name == last_name

    gg
  end
end

#section(name, opts = {}, &block) ⇒ Object



608
609
610
611
612
# File 'lib/probatio.rb', line 608

def section(name, opts={}, &block)

  @children << Probatio::Section.new(self, @path, name.to_s, opts, block) \
    unless opts[:pending]
end

#test(name, opts = {}, &block) ⇒ Object



614
615
616
617
618
619
# File 'lib/probatio.rb', line 614

def test(name, opts={}, &block)

  opts[:pending] = true if block.nil?

  @children << Probatio::Test.new(self, @path, name.to_s, opts, block)
end