Method: Funit::TestSuite#expand

Defined in:
lib/funit/testsuite.rb

#expandObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/funit/testsuite.rb', line 75

def expand
  $stderr.print "expanding test suite: #{@suite_name}..."
  funit_contents = @suite_content.split("\n")
  @funit_total_lines = funit_contents.length

  while (line = funit_contents.shift) && line !~ KEYWORDS
    puts line
  end

  funit_contents.unshift line

  puts " contains\n\n"

  while (line = funit_contents.shift)
    case line
    when COMMENT_LINE
      puts line
    when /^setup/i
      add_to_setup funit_contents
    when /^teardown/i
      add_to_teardown funit_contents
    when /^Xtest\s+(\w+)/i
      ignore_test($1,funit_contents)
    when /^test\s+(\w+)/i
      a_test($1,funit_contents)
    when /^test/i
      syntax_error "no name given for test", @suite_name
    when /^end\s+(setup|teardown|test)/i
      syntax_error "no matching #$1 for an #$&", @suite_name
    when Assertions::ASSERTION_PATTERN
      syntax_error "#$1 assertion not in a test block", @suite_name
    else
      puts line
    end
  end
  $stderr.puts "done."
end