cucumber 0.3.103 → 0.3.104
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +27 -2
- data/Manifest.txt +10 -4
- data/examples/ramaze/README.textile +7 -0
- data/examples/ramaze/Rakefile +6 -0
- data/examples/ramaze/app.rb +21 -0
- data/examples/ramaze/features/add.feature +11 -0
- data/examples/ramaze/features/step_definitions/add_steps.rb +15 -0
- data/examples/ramaze/features/support/env.rb +32 -0
- data/examples/ramaze/layout/default.html.erb +8 -0
- data/examples/ramaze/view/index.html.erb +5 -0
- data/examples/sinatra/features/support/env.rb +1 -1
- data/features/cucumber_cli.feature +5 -5
- data/features/usage_and_stepdefs_formatter.feature +169 -0
- data/lib/cucumber/ast/step_invocation.rb +7 -0
- data/lib/cucumber/ast/tags.rb +6 -1
- data/lib/cucumber/ast/tree_walker.rb +5 -11
- data/lib/cucumber/cli/options.rb +20 -11
- data/lib/cucumber/formatter/html.rb +0 -2
- data/lib/cucumber/formatter/stepdefs.rb +14 -0
- data/lib/cucumber/formatter/usage.rb +106 -50
- data/lib/cucumber/language_support/language_methods.rb +6 -9
- data/lib/cucumber/rb_support/rb_language.rb +16 -3
- data/lib/cucumber/rb_support/rb_step_definition.rb +7 -1
- data/lib/cucumber/step_match.rb +4 -0
- data/lib/cucumber/step_mother.rb +8 -37
- data/lib/cucumber/version.rb +1 -1
- data/spec/cucumber/ast/background_spec.rb +0 -6
- data/spec/cucumber/ast/tree_walker_spec.rb +0 -7
- data/spec/cucumber/cli/options_spec.rb +12 -0
- data/spec/cucumber/formatter/html_spec.rb +0 -1
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +0 -9
- data/spec/cucumber/step_mother_spec.rb +13 -34
- metadata +12 -6
- data/features/steps_formatter.feature +0 -26
- data/features/usage.feature +0 -126
- data/lib/cucumber/formatter/profile.rb +0 -78
- data/lib/cucumber/formatters/unicode.rb +0 -7
@@ -1,78 +0,0 @@
|
|
1
|
-
require 'cucumber/formatter/progress'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
module Formatter
|
5
|
-
# The formatter used for <tt>--format profile</tt>
|
6
|
-
class Profile < Progress
|
7
|
-
NUMBER_OF_STEP_DEFINITONS_TO_SHOW = 10
|
8
|
-
NUMBER_OF_STEP_INVOCATIONS_TO_SHOW = 5
|
9
|
-
|
10
|
-
def initialize(step_mother, io, options)
|
11
|
-
super
|
12
|
-
@step_definition_durations = Hash.new { |h,step_definition| h[step_definition] = [] }
|
13
|
-
end
|
14
|
-
|
15
|
-
def step(step)
|
16
|
-
@step_duration = Time.now
|
17
|
-
@step = step
|
18
|
-
super
|
19
|
-
end
|
20
|
-
|
21
|
-
def step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
|
22
|
-
duration = Time.now - @step_duration
|
23
|
-
super
|
24
|
-
|
25
|
-
if step_match.step_definition
|
26
|
-
description = format_step(keyword, step_match, status, nil)
|
27
|
-
@step_definition_durations[step_match.step_definition] << [duration, description, @step.file_colon_line]
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
def print_summary(features)
|
32
|
-
super
|
33
|
-
@io.puts "\n\nTop #{NUMBER_OF_STEP_DEFINITONS_TO_SHOW} average slowest steps with #{NUMBER_OF_STEP_INVOCATIONS_TO_SHOW} slowest matches:\n"
|
34
|
-
|
35
|
-
mean_durations = map_to_mean_durations(@step_definition_durations)
|
36
|
-
mean_durations = mean_durations.sort_by do |duration_description_location, step_definition, mean_duration|
|
37
|
-
mean_duration
|
38
|
-
end.reverse
|
39
|
-
|
40
|
-
mean_durations[0...NUMBER_OF_STEP_DEFINITONS_TO_SHOW].each do |duration_description_location, step_definition, mean_duration|
|
41
|
-
print_step_definition(step_definition, mean_duration)
|
42
|
-
duration_description_location = duration_description_location.sort_by do |duration, description, location|
|
43
|
-
duration
|
44
|
-
end.reverse
|
45
|
-
print_step_definitions(duration_description_location, step_definition)
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def map_to_mean_durations(step_definition_durations)
|
52
|
-
mean_durations = []
|
53
|
-
step_definition_durations.each do |step_definition, duration_description_location|
|
54
|
-
total_duration = duration_description_location.inject(0) { |sum, step_details| step_details[0] + sum }
|
55
|
-
mean_duration = total_duration / duration_description_location.length
|
56
|
-
|
57
|
-
mean_durations << [duration_description_location, step_definition, mean_duration]
|
58
|
-
end
|
59
|
-
mean_durations
|
60
|
-
end
|
61
|
-
|
62
|
-
def print_step_definition(step_definition, mean_duration)
|
63
|
-
duration = sprintf("%.7f", mean_duration)
|
64
|
-
@io.puts format_string("#{duration} #{step_definition.backtrace_line}", :failed)
|
65
|
-
end
|
66
|
-
|
67
|
-
def print_step_definitions(duration_description_location, step_definition)
|
68
|
-
max_length = duration_description_location[0...NUMBER_OF_STEP_INVOCATIONS_TO_SHOW].map{|_, d, _| d.jlength}.max
|
69
|
-
duration_description_location[0...NUMBER_OF_STEP_INVOCATIONS_TO_SHOW].each do |duration, description, location|
|
70
|
-
@io.print format_string(" #{sprintf("%.7f", duration)}", :pending)
|
71
|
-
@io.print " #{description}"
|
72
|
-
@io.print format_string(" # #{location}".indent(max_length - description.jlength), :comment)
|
73
|
-
@io.puts
|
74
|
-
end
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|