diff --git a/lib/pretty_face.rb b/lib/pretty_face.rb
index bdc5b11..590da1d 100644
--- a/lib/pretty_face.rb
+++ b/lib/pretty_face.rb
@@ -2,5 +2,26 @@
require "pretty_face/formatter/html"
module PrettyFace
- # Your code goes here...
+
+ @msg_storage= Array.new
+
+ def self.set_header(data)
+ data_2= Hash.new
+ data.each { |k, v| (data_2.length >= data.length) ? break : data_2[:"#{k}"]= data.delete(k) }
+ @header_row_1= data
+ @header_row_2= data_2
+ end
+
+ def self.get_header(row)
+ (row == 1) ? @header_row_1 : @header_row_2
+ end
+
+ def self.log_scenario_msg(data)
+ @msg_storage.push(data)
+ end
+
+ def self.fetch_scenario_msg
+ @msg_storage.shift
+ end
+
end
diff --git a/lib/pretty_face/formatter/html.rb b/lib/pretty_face/formatter/html.rb
index 1a301fb..9560401 100644
--- a/lib/pretty_face/formatter/html.rb
+++ b/lib/pretty_face/formatter/html.rb
@@ -2,9 +2,10 @@
require 'fileutils'
require 'cucumber/formatter/io'
require 'cucumber/formatter/duration'
-require 'cucumber/core/ast/scenario'
-require 'cucumber/multiline_argument/data_table'
-
+require 'cucumber/formatter/console'
+require 'cucumber/ast/scenario'
+require 'cucumber/ast/table'
+require 'cucumber/ast/outline_table'
require File.join(File.dirname(__FILE__), 'view_helper')
require File.join(File.dirname(__FILE__), 'report')
@@ -18,6 +19,7 @@ module Formatter
class Html
include Cucumber::Formatter::Io
include Cucumber::Formatter::Duration
+ include Cucumber::Formatter::Console
include ViewHelper
attr_reader :report, :logo
@@ -33,7 +35,8 @@ def initialize(step_mother, path_or_io, options)
@options[:expand] = false unless @options.nil?
@report = Report.new
@img_id = 0
- @logo = 'face.png'
+ @logo = 'logo.png'
+ @delayed_messages = []
end
def set_path_and_file(path_or_io)
@@ -42,11 +45,11 @@ def set_path_and_file(path_or_io)
FileUtils.mkdir_p dir unless File.directory? dir
@io = ensure_io(path_or_io, 'html')
end
-
+
def embed(src, mime_type, label)
case(mime_type)
- when /^image\/(png|gif|jpg|jpeg)/
- embed_image(src, label)
+ when /^image\/(png|gif|jpg|jpeg)/
+ embed_image(src, label)
end
end
@@ -87,19 +90,18 @@ def after_background(background)
end
def before_feature_element(feature_element)
-# unless scenario_outline? feature_element
+ unless scenario_outline? feature_element
@report.add_scenario ReportScenario.new(feature_element)
-# end
+ end
end
def after_feature_element(feature_element)
-# unless scenario_outline?(feature_element)
+ unless scenario_outline?(feature_element)
process_scenario(feature_element)
-# end
+ end
end
def before_table_row(example_row)
- @before_example_row = example_row
@report.add_scenario ReportScenario.new(example_row) unless info_row?(example_row)
end
@@ -108,7 +110,7 @@ def after_table_row(example_row)
@report.current_scenario.populate(example_row)
build_scenario_outline_steps(example_row)
end
- populate_cells(example_row) if example_row.instance_of? Cucumber::Core::Ast::DataTable
+ populate_cells(example_row) if example_row.instance_of? Cucumber::Ast::Table::Cells
end
def before_step(step)
@@ -201,10 +203,10 @@ def copy_file(source, destination)
end
def copy_images
- copy_directory 'images', %w(failed passed pending undefined skipped table_failed table_passed table_pending table_undefined table_skipped), "png"
+ copy_directory 'images', %w(debug screenshot failed passed pending undefined skipped table_failed table_passed table_pending table_undefined table_skipped), "png"
logo = logo_file
copy_file logo, "#{File.join(File.dirname(@path), 'images')}" if logo
- copy_directory 'images', ['face'], 'png' unless logo
+ copy_directory 'images', ['logo'], 'png' unless logo
end
def copy_stylesheets
@@ -222,7 +224,7 @@ def logo_file
end
def customization_directory
- dir = File.join(File.expand_path('features'), 'support', 'pretty_face')
+ dir = File.join(File.expand_path('features'), 'support', 'ugly_face')
return dir if File.exists? dir
end
@@ -235,7 +237,7 @@ def process_step(step, status=nil)
report_step = ReportStep.new(step)
report_step.duration = duration
report_step.status = status unless status.nil?
- if step.background
+ if step.background?
@report.current_feature.background << report_step if @report.processing_background_steps?
else
@report.add_step report_step
@@ -244,12 +246,12 @@ def process_step(step, status=nil)
end
def scenario_outline?(feature_element)
- feature_element.is_a? Cucumber::Core::Ast::ScenarioOutline
+ feature_element.is_a? Cucumber::Ast::ScenarioOutline
end
def info_row?(example_row)
return example_row.scenario_outline.nil? if example_row.respond_to? :scenario_outline
- return true if example_row.instance_of? Cucumber::Formatter::LegacyApi::Ast::DataTableRow
+ return true if example_row.instance_of? Cucumber::Ast::Table::Cells
false
end
@@ -259,13 +261,9 @@ def step_belongs_to_outline?(step)
end
def build_scenario_outline_steps(example_row)
- si = example_row.cells
+ si = example_row.instance_variable_get :@step_invocations
si.each do |row|
- duration = Time.now - @step_timer
- report_step = ReportStep.new(@before_example_row, example_row)
- report_step.duration = duration
- @report.add_step report_step
-# process_step(row, row.status)
+ process_step(row, row.status)
end
end
diff --git a/lib/pretty_face/formatter/report.rb b/lib/pretty_face/formatter/report.rb
index fa72f66..8b1dfef 100644
--- a/lib/pretty_face/formatter/report.rb
+++ b/lib/pretty_face/formatter/report.rb
@@ -130,15 +130,13 @@ def step_summary_for(status)
end
def scenario_average_duration
- has_duration = scenarios.reject { |scenario| scenario.duration.nil? }
- durations = has_duration.collect { |scenario| scenario.duration }
+ durations = scenarios.collect { |scenario| scenario.duration }
formatted_duration(durations.reduce(:+).to_f / durations.size)
end
def step_average_duration
steps = scenarios.collect { |scenario| scenario.steps }
- has_duration = steps.flatten.reject { |step| step.duration.nil? }
- durations = has_duration.collect { |step| step.duration }
+ durations = steps.flatten.collect { |step| step.duration }
formatted_duration(durations.reduce(:+).to_f / durations.size)
end
@@ -173,17 +171,17 @@ def initialize(scenario)
@image_id = []
@start = Time.now
end
-
+
def populate(scenario)
@duration = Time.now - @start
- @status = scenario.status
- if scenario.instance_of? Cucumber::Formatter::LegacyApi::Ast::Scenario
+ if scenario.instance_of? Cucumber::Ast::Scenario
@name = scenario.name
- @file_colon_line = scenario.line
- elsif scenario.instance_of? Cucumber::Formatter::LegacyApi::Ast::ExampleTableRow
- @name = scenario.name
- @file_colon_line = scenario.line
+ @file_colon_line = scenario.file_colon_line
+ elsif scenario.instance_of? Cucumber::Ast::OutlineTable::ExampleRow
+ @name = scenario.scenario_outline.name
+ @file_colon_line = scenario.backtrace_line
end
+ @status = scenario.status
end
def has_image?
@@ -194,22 +192,19 @@ def has_image?
class ReportStep
attr_accessor :name, :keyword, :file_colon_line, :status, :duration, :table, :multiline_arg, :error
- def initialize(step, ast_step=nil)
- if ast_step
- @name = ast_step.name
- @keyword = ast_step.keyword
- @status = ast_step.status
- @error = ast_step.exception
- else
- @name = step.name
- unless step.instance_of? Cucumber::Formatter::LegacyApi::Ast::Background
+ def initialize(step)
+ @name = step.name
+ @file_colon_line = step.file_colon_line
+ unless step.instance_of? Cucumber::Ast::Background
+ if step.respond_to? :actual_keyword
+ @keyword = step.actual_keyword
+ else
@keyword = step.keyword
- @status = step.status
- @multiline_arg = step.multiline_arg unless step.multiline_arg.instance_of? Cucumber::Core::Ast::EmptyMultilineArgument
- @error = step.exception
end
+ @status = step.status
+ @multiline_arg = step.multiline_arg
+ @error = step.exception
end
- @file_colon_line = step.file_colon_line
end
def failed_with_error?
@@ -254,7 +249,7 @@ def snippet(error)
end
def snippet_for(error_line)
- file, line = file_name_and_line(error_line)
+ file, line = file_name_and_line(error_line)
if file
[lines_around(file, line), line, file]
else
diff --git a/lib/pretty_face/formatter/view_helper.rb b/lib/pretty_face/formatter/view_helper.rb
index 4fb7992..83d602e 100644
--- a/lib/pretty_face/formatter/view_helper.rb
+++ b/lib/pretty_face/formatter/view_helper.rb
@@ -1,6 +1,6 @@
-require 'cucumber/core/ast/scenario_outline'
+require 'cucumber/ast/scenario_outline'
-module PrettyFace
+module UglyFace
module Formatter
module ViewHelper
@@ -23,15 +23,13 @@ def total_duration
def step_average_duration(features)
scenarios = features.collect { |feature| feature.scenarios }
steps = scenarios.flatten.collect { |scenario| scenario.steps }
- has_duration = steps.flatten.reject { |step| step.duration.nil? }
- durations = has_duration.collect { |step| step.duration }
+ durations = steps.flatten.collect { |step| step.duration }
format_duration get_average_from_float_array durations
end
def scenario_average_duration(features)
scenarios = features.collect { |feature| feature.scenarios }
- has_duration = scenarios.flatten.reject { |scenario| scenario.duration.nil? }
- durations = has_duration.collect { |scenario| scenario.duration }
+ durations = scenarios.flatten.collect { |scenario| scenario.duration }
format_duration get_average_from_float_array durations
end
diff --git a/lib/pretty_face/templates/_step.erb b/lib/pretty_face/templates/_step.erb
index 0351076..e320ea1 100644
--- a/lib/pretty_face/templates/_step.erb
+++ b/lib/pretty_face/templates/_step.erb
@@ -1,46 +1,39 @@
<%= "#{step.keyword} #{step.name}" %>
<% if step.has_table? %>
-
-
-
- <% step.table.first.each do |column| %>
- | <%= column %> |
+
+
+ <% step.table.each do |row| %>
+
+ <% row.each_with_index do |column, index| %>
+ <% if index == 0 %>
+ | <%= column %> |
+ <% else %>
+ <%= column %> |
+ <% end %>
+ <% end %>
+
<% end %>
-
- <% step.table.delete_at 0 %>
- <% step.table.each do |row| %>
-
- <% row.each do |column| %>
- | <%= column %> |
- <% end %>
-
- <% end %>
-
+
<% end %>
<% if step.has_multiline_arg? %>
-
-
-
- <%= step.multiline_arg %> |
-
-
+
+
+
+ <%= step.multiline_arg %> |
+
+
<% end %>
<% if step.failed_with_error? %>
-
-
-
- <%= "#{step.error.message} (#{step.error.class})" %>
- |
-
-
- |
- <%= raw(step.extra_failure_content(step.error.backtrace)) %>
- |
-
-
-
- <%= step.error.backtrace.join("\n") %>
- |
-
-
-<% end %>
+
+
+
+ <%= "#{step.error.message} (#{step.error.class})" %>
+ |
+
+
+ |
+ <%= raw(step.extra_failure_content(step.error.backtrace)) %>
+ |
+
+
+<% end %>
\ No newline at end of file
diff --git a/lib/pretty_face/templates/feature.erb b/lib/pretty_face/templates/feature.erb
index 2c01b04..e3adc1b 100644
--- a/lib/pretty_face/templates/feature.erb
+++ b/lib/pretty_face/templates/feature.erb
@@ -1,134 +1,139 @@
-
-
-
- Feature Results
-
+
+
+
+ Feature Results
+
-
-
-
+
-
-
-
-
+
+
+
+
-
-
-
- | Summary |
- Executed |
- <%= raw(feature.table_image_for('passed', feature.file)) %> Passed |
- <%= raw(feature.table_image_for('failed', feature.file)) %> Failed |
- <%= raw(feature.table_image_for('skipped', feature.file)) %> Skipped |
- <%= raw(feature.table_image_for('undefined', feature.file)) %> Undefined |
- <%= raw(feature.table_image_for('pending', feature.file)) %> Pending |
- Average Duration |
-
+
+
+
+ | Summary |
+ Executed |
+ <%= raw(feature.table_image_for('passed', feature.file)) %> Passed |
+ <%= raw(feature.table_image_for('failed', feature.file)) %> Failed |
+ <%= raw(feature.table_image_for('skipped', feature.file)) %> Skipped |
+ <%= raw(feature.table_image_for('undefined', feature.file)) %> Undefined |
+ <%= raw(feature.table_image_for('pending', feature.file)) %> Pending |
+ Average Duration |
+
-
-
+
+
-
-
+
+
-
-
- <% if feature.has_background? %>
-
-
Background: <%= feature.background_title.name %>
- <% end %>
-
- <% feature.background_steps.each do |step| %>
-
- | <%= raw(feature.image_tag_for(step.status, feature.file)) %> |
-
- <%= render "step", step: step %>
- |
-
- <% end %>
-
-
-
Scenarios:
-
- <% feature.scenarios.each do |scenario| %>
-
-
- | <%= scenario.name %> |
-
- <% scenario.steps.each do |step| %>
-
- | <%= raw(feature.image_tag_for(step.status, feature.file)) %> |
- ">
-
- <%= render "step", step: step %>
- |
-
- <% end %>
-
-
-
+
+
+ <% if feature.has_background? %>
+
+
Background: <%= feature.background_title.name %>
+ <% end %>
+
+ <% feature.background_steps.each do |step| %>
+
+ | <%= raw(feature.image_tag_for(step.status, feature.file)) %> |
+
+ <%= render "step", step: step %>
+ |
+
+ <% end %>
+
+
+
Scenarios:
+ <% feature.scenarios.each do |scenario| %>
+
+
+ | <%= scenario.name %> (<%= scenario.duration.round(1) %>s) |
+
+ <% scenario.steps.each do |step| %>
+
+ | <%= raw(feature.image_tag_for(step.status, feature.file)) %> |
+ ">
+ <%= render "step", step: step %>
+ |
+ <%= step.duration.round(1) %>s |
+
+ <% end %>
<% if scenario.has_image? %>
- <% scenario.image.length.times do |i| %>
- <%= "#{scenario.image_label[i]}" %>
-
- <% end %>
+
+ | <%= raw(feature.image_tag_for('screenshot', feature.file)) %> |
+
+ <% scenario.image.length.times do |i| %>
+ | <%= "#{scenario.image_label[i]}" %> |
+
+ <% end %>
+ |
+ |
+
<% end %>
-
- <% end %>
-
-
-
-
-
-
-
-
-
+
+ | <%= raw(feature.image_tag_for('debug', feature.file)) %> |
+ <%= raw(PrettyFace::fetch_scenario_msg) %> |
+ |
+
+
+
+ <% end %>
+
+
+
+
+