cucumber 0.3.103 → 0.3.104

Sign up to get free protection for your applications and to get access to all the features.
Files changed (37) hide show
  1. data/History.txt +27 -2
  2. data/Manifest.txt +10 -4
  3. data/examples/ramaze/README.textile +7 -0
  4. data/examples/ramaze/Rakefile +6 -0
  5. data/examples/ramaze/app.rb +21 -0
  6. data/examples/ramaze/features/add.feature +11 -0
  7. data/examples/ramaze/features/step_definitions/add_steps.rb +15 -0
  8. data/examples/ramaze/features/support/env.rb +32 -0
  9. data/examples/ramaze/layout/default.html.erb +8 -0
  10. data/examples/ramaze/view/index.html.erb +5 -0
  11. data/examples/sinatra/features/support/env.rb +1 -1
  12. data/features/cucumber_cli.feature +5 -5
  13. data/features/usage_and_stepdefs_formatter.feature +169 -0
  14. data/lib/cucumber/ast/step_invocation.rb +7 -0
  15. data/lib/cucumber/ast/tags.rb +6 -1
  16. data/lib/cucumber/ast/tree_walker.rb +5 -11
  17. data/lib/cucumber/cli/options.rb +20 -11
  18. data/lib/cucumber/formatter/html.rb +0 -2
  19. data/lib/cucumber/formatter/stepdefs.rb +14 -0
  20. data/lib/cucumber/formatter/usage.rb +106 -50
  21. data/lib/cucumber/language_support/language_methods.rb +6 -9
  22. data/lib/cucumber/rb_support/rb_language.rb +16 -3
  23. data/lib/cucumber/rb_support/rb_step_definition.rb +7 -1
  24. data/lib/cucumber/step_match.rb +4 -0
  25. data/lib/cucumber/step_mother.rb +8 -37
  26. data/lib/cucumber/version.rb +1 -1
  27. data/spec/cucumber/ast/background_spec.rb +0 -6
  28. data/spec/cucumber/ast/tree_walker_spec.rb +0 -7
  29. data/spec/cucumber/cli/options_spec.rb +12 -0
  30. data/spec/cucumber/formatter/html_spec.rb +0 -1
  31. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +0 -9
  32. data/spec/cucumber/step_mother_spec.rb +13 -34
  33. metadata +12 -6
  34. data/features/steps_formatter.feature +0 -26
  35. data/features/usage.feature +0 -126
  36. data/lib/cucumber/formatter/profile.rb +0 -78
  37. 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
@@ -1,7 +0,0 @@
1
- STDERR.puts <<-EOF
2
- WARNING: The cucumber/formatters/unicode file is deprecated.
3
- It will be removed in version 0.4.0
4
- Please use cucumber/formatter/unicode instead
5
- EOF
6
- # This is for backwards compatibility
7
- require 'cucumber/formatter/unicode'