class Suite def parse_output_file_and_open_in_browser(file) results = "" File.open(file) do |f| f.readlines.each do |l| results << l end end html = parse_results(results).html %x(touch '/tmp/out.html' && echo '#{html}' > /tmp/out.html && open '/tmp/out.html' ) end def parse_results_and_open_in_safari(results) html = parse_results(results).html open_in_safari(html) end def open_in_safari(html) %x(touch '/tmp/out.html' && echo '#{html}' > /tmp/out.html && open '/tmp/out.html' ) end def parse_results(results="") parse @passed = true features.each do |f| f.scenarios.each do |s| s.verify_status(results) @passed &&= s.passed? end end self end def passed? @passed end def html <<-END
#{features.map {|f| f.to_html }.join(" \n")}
END end def valid? unique_feature_test_case_names? end def unique_feature_test_case_names? feature_test_case_name = features.map {|f| f.test_case_name } feature_test_case_name == feature_test_case_name.uniq end def run parse raise "Invalid: Duplicated Titles" unless valid? File.open(test_cases_file, "w") { |f| f.puts self } end def parse parse_features parse_feature_scenarios end def parse_feature_scenarios features.each do |feature| feature.parse_scenarios end end def all_feature_files all_entries_in_feature_files_path = Dir.new(feature_files_path).entries feature_entries = all_entries_in_feature_files_path.select do |file| !!(file =~ /\.#{feature_file_suffix}$/) end feature_entries.map do |file| feature_files_path + "/" + file end end def all_feature_files_as_strings feature_files.map do |file| feature_string = "" File.open(file) do |f| f.readlines.each do |l| feature_string << l end end feature_string end end end