cucumber 2.0.0 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/CONTRIBUTING.md +7 -9
  3. data/History.md +295 -265
  4. data/README.md +9 -7
  5. data/cucumber.gemspec +2 -2
  6. data/features/docs/cli/dry_run.feature +0 -3
  7. data/features/docs/cli/finding_steps.feature +28 -0
  8. data/features/docs/cli/run_specific_scenarios.feature +3 -1
  9. data/features/docs/cli/specifying_multiple_formatters.feature +22 -1
  10. data/features/docs/defining_steps/nested_steps.feature +0 -1
  11. data/features/docs/defining_steps/printing_messages.feature +4 -4
  12. data/features/docs/defining_steps/skip_scenario.feature +0 -2
  13. data/features/docs/exception_in_around_hook.feature +1 -3
  14. data/features/docs/formatters/html_formatter.feature +1 -0
  15. data/features/docs/formatters/json_formatter.feature +73 -62
  16. data/features/docs/formatters/junit_formatter.feature +130 -38
  17. data/features/docs/formatters/rerun_formatter.feature +60 -8
  18. data/features/docs/formatters/usage_formatter.feature +3 -7
  19. data/features/docs/getting_started.feature +1 -1
  20. data/features/docs/gherkin/background.feature +0 -11
  21. data/features/docs/gherkin/language_help.feature +5 -0
  22. data/features/docs/gherkin/outlines.feature +1 -3
  23. data/features/docs/gherkin/using_descriptions.feature +0 -1
  24. data/features/docs/raketask.feature +1 -1
  25. data/features/docs/writing_support_code/after_hooks.feature +22 -0
  26. data/features/lib/step_definitions/aruba_steps.rb +4 -0
  27. data/features/lib/step_definitions/junit_steps.rb +1 -1
  28. data/features/lib/support/normalise_output.rb +21 -4
  29. data/lib/cucumber/cli/configuration.rb +16 -13
  30. data/lib/cucumber/cli/main.rb +35 -10
  31. data/lib/cucumber/cli/options.rb +33 -9
  32. data/lib/cucumber/cli/rerun_file.rb +29 -0
  33. data/lib/cucumber/filters/prepare_world.rb +2 -3
  34. data/lib/cucumber/formatter/backtrace_filter.rb +40 -0
  35. data/lib/cucumber/formatter/console.rb +2 -3
  36. data/lib/cucumber/formatter/cucumber.css +1 -0
  37. data/lib/cucumber/formatter/duration_extractor.rb +28 -0
  38. data/lib/cucumber/formatter/hook_query_visitor.rb +40 -0
  39. data/lib/cucumber/formatter/html.rb +16 -1
  40. data/lib/cucumber/formatter/json.rb +287 -8
  41. data/lib/cucumber/formatter/junit.rb +92 -143
  42. data/lib/cucumber/formatter/legacy_api/adapter.rb +18 -54
  43. data/lib/cucumber/formatter/legacy_api/ast.rb +13 -0
  44. data/lib/cucumber/formatter/legacy_api/runtime_facade.rb +4 -0
  45. data/lib/cucumber/formatter/pretty.rb +2 -1
  46. data/lib/cucumber/formatter/progress.rb +20 -53
  47. data/lib/cucumber/formatter/rerun.rb +2 -1
  48. data/lib/cucumber/formatter/usage.rb +16 -22
  49. data/lib/cucumber/hooks.rb +18 -9
  50. data/lib/cucumber/multiline_argument/data_table.rb +40 -28
  51. data/lib/cucumber/platform.rb +1 -1
  52. data/lib/cucumber/rb_support/rb_hook.rb +4 -0
  53. data/lib/cucumber/running_test_case.rb +13 -4
  54. data/lib/cucumber/runtime/after_hooks.rb +7 -6
  55. data/lib/cucumber/runtime/before_hooks.rb +8 -4
  56. data/lib/cucumber/runtime/step_hooks.rb +5 -4
  57. data/lib/cucumber/runtime/support_code.rb +6 -15
  58. data/lib/cucumber/step_match.rb +1 -1
  59. data/spec/cucumber/cli/configuration_spec.rb +32 -5
  60. data/spec/cucumber/cli/main_spec.rb +3 -3
  61. data/spec/cucumber/cli/options_spec.rb +60 -1
  62. data/spec/cucumber/cli/rerun_spec.rb +89 -0
  63. data/spec/cucumber/formatter/html_spec.rb +84 -5
  64. data/spec/cucumber/formatter/json_spec.rb +757 -0
  65. data/spec/cucumber/formatter/junit_spec.rb +5 -5
  66. data/spec/cucumber/formatter/legacy_api/adapter_spec.rb +69 -8
  67. data/spec/cucumber/formatter/pretty_spec.rb +96 -0
  68. data/spec/cucumber/formatter/progress_spec.rb +85 -1
  69. data/spec/cucumber/formatter/rerun_spec.rb +3 -3
  70. data/spec/cucumber/multiline_argument/data_table_spec.rb +89 -0
  71. data/spec/cucumber/running_test_case_spec.rb +57 -1
  72. metadata +70 -60
  73. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +0 -204
  74. data/lib/cucumber/formatter/gpretty.rb +0 -24
@@ -1,204 +0,0 @@
1
- require 'cucumber/formatter/io'
2
- require 'gherkin/formatter/argument'
3
-
4
- module Cucumber
5
- module Formatter
6
- # Adapts Cucumber formatter events to Gherkin formatter events
7
- # This class will disappear when Cucumber is based on Gherkin's model.
8
- class GherkinFormatterAdapter
9
- def initialize(gherkin_formatter, print_empty_match, options)
10
- @gf = gherkin_formatter
11
- @print_empty_match = print_empty_match
12
- @options = options
13
- @delayed_messages = []
14
- @delayed_embeddings = []
15
- end
16
-
17
- def before_feature(feature)
18
- @gf.uri(feature.file)
19
- @gf.feature(feature.gherkin_statement)
20
- end
21
-
22
- def before_background(background)
23
- @outline = false
24
- @gf.background(background.gherkin_statement)
25
- end
26
-
27
- def before_feature_element(feature_element)
28
- case(feature_element)
29
- when Core::Ast::Scenario
30
- @outline = false
31
- @gf.scenario(feature_element.gherkin_statement)
32
- when Core::Ast::ScenarioOutline
33
- @outline = true
34
- if @options[:expand]
35
- @in_instantiated_scenario = false
36
- @current_scenario_hash = to_hash(feature_element.gherkin_statement)
37
- else
38
- @gf.scenario_outline(feature_element.gherkin_statement)
39
- end
40
- else
41
- raise "Bad type: #{feature_element.class}"
42
- end
43
- end
44
-
45
- def before_test_case(test_case)
46
- @delay_output = true
47
- end
48
-
49
- def scenario_name(keyword, name, file_colon_line, source_indent)
50
- if @outline and @options[:expand]
51
- return if not @in_instantiated_scenario
52
- if @new_example_table
53
- @example_row = 1
54
- @new_example_table = false
55
- else
56
- @example_row += 1
57
- end
58
- example_row_hash = @current_example_rows[@example_row].to_hash
59
- scenario = Gherkin::Formatter::Model::Scenario.new(
60
- @current_scenario_hash['comments'],
61
- @current_scenario_hash['tags'],
62
- @current_scenario_hash['keyword'],
63
- @current_scenario_hash['name'],
64
- @current_scenario_hash['description'],
65
- example_row_hash['line'],
66
- example_row_hash['id'])
67
- @gf.scenario(scenario)
68
- end
69
- end
70
-
71
- def before_step(step)
72
- unless @outline and @options[:expand]
73
- @gf.step(step.gherkin_statement)
74
- pass_delayed_output
75
- @delay_output = false
76
- else
77
- if @in_instantiated_scenario
78
- @current_step_hash = to_hash(step.gherkin_statement)
79
- @delay_output = true
80
- end
81
- end
82
- if @print_empty_match
83
- if(@outline)
84
- match = Gherkin::Formatter::Model::Match.new(step.gherkin_statement.outline_args, nil)
85
- else
86
- match = Gherkin::Formatter::Model::Match.new([], nil)
87
- end
88
- @gf.match(match)
89
- end
90
- end
91
-
92
- def before_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background, file_colon_line)
93
- arguments = step_match.step_arguments.map{|a| Gherkin::Formatter::Argument.new(a.offset, a.val)}
94
- location = step_match.file_colon_line
95
- match = Gherkin::Formatter::Model::Match.new(arguments, location)
96
- if @print_empty_match
97
- # Trick the formatter to believe that's what was printed previously so we get arg highlights on #result
98
- @gf.instance_variable_set('@match', match)
99
- else
100
- unless @outline and @options[:expand]
101
- @gf.match(match)
102
- end
103
- end
104
-
105
- error_message = exception ? "#{exception.message} (#{exception.class})\n#{exception.backtrace.join("\n")}" : nil
106
- unless @outline
107
- @gf.result(Gherkin::Formatter::Model::Result.new(status, nil, error_message))
108
- else
109
- if @options[:expand] and @in_instantiated_scenario
110
- @current_match = match
111
- @current_result = Gherkin::Formatter::Model::Result.new(status, nil, error_message)
112
- end
113
- end
114
- end
115
-
116
- def step_name(keyword, step_match, status, source_indent, background, file_colon_line)
117
- if @outline and @options[:expand] and @in_instantiated_scenario
118
- @gf.step(Gherkin::Formatter::Model::Step.new(
119
- @current_step_hash['comments'],
120
- @current_step_hash['keyword'],
121
- step_match.format_args(),
122
- file_colon_line.split(':')[1].to_i,
123
- @current_step_hash['rows'],
124
- @current_step_hash['doc_string']))
125
- pass_delayed_output
126
- @delay_output = false
127
- @gf.match(@current_match)
128
- @gf.result(@current_result)
129
- end
130
- end
131
-
132
- def before_examples(examples)
133
- unless @options[:expand]
134
- @gf.examples(examples.gherkin_statement)
135
- else
136
- @in_instantiated_scenario = true
137
- @new_example_table = true
138
- @current_example_rows = to_hash(examples.gherkin_statement)['rows']
139
- end
140
- end
141
-
142
- #used for capturing duration
143
- def after_step(step)
144
- unless @outline and @options[:expand] and not @in_instantiated_scenario
145
- step.duration.tap { |duration| @gf.append_duration(duration.nanoseconds / 10 ** 9.0) }
146
- end
147
- end
148
-
149
- def after_feature(feature)
150
- @gf.eof
151
- end
152
-
153
- def after_features(features)
154
- @gf.done
155
- end
156
-
157
- def embed(file, mime_type, label)
158
- if File.file?(file)
159
- data = File.open(file, 'rb') { |f| f.read }
160
- else
161
- if mime_type =~ /;base64$/
162
- mime_type = mime_type[0..-8]
163
- data = Base64.decode64(file)
164
- else
165
- data = file
166
- end
167
- end
168
- if defined?(JRUBY_VERSION)
169
- data = data.to_java_bytes
170
- end
171
- unless @delay_output
172
- @gf.embedding(mime_type, data)
173
- else
174
- @delayed_embeddings.push [mime_type, data]
175
- end
176
- end
177
-
178
- def puts(message)
179
- unless @delay_output
180
- @gf.write(message)
181
- else
182
- @delayed_messages.push message
183
- end
184
- end
185
-
186
- private
187
-
188
- def to_hash(gherkin_statement)
189
- if defined?(JRUBY_VERSION)
190
- gherkin_statement.toMap()
191
- else
192
- gherkin_statement.to_hash
193
- end
194
- end
195
-
196
- def pass_delayed_output
197
- @delayed_messages.each { |message| @gf.write(message) }
198
- @delayed_embeddings.each { |embed_data| @gf.embedding(embed_data[0], embed_data[1]) }
199
- @delayed_messages = []
200
- @delayed_embeddings = []
201
- end
202
- end
203
- end
204
- end
@@ -1,24 +0,0 @@
1
- require 'cucumber/formatter/gherkin_formatter_adapter'
2
- require 'cucumber/formatter/io'
3
- require 'gherkin/formatter/argument'
4
- require 'gherkin/formatter/pretty_formatter'
5
-
6
- module Cucumber
7
- module Formatter
8
- # The formatter used for <tt>--format gpretty</tt>
9
- class Gpretty < GherkinFormatterAdapter
10
- include Io
11
-
12
- def initialize(runtime, io, options)
13
- @io = ensure_io(io, "json")
14
- super(Gherkin::Formatter::PrettyFormatter.new(@io, false), true)
15
- end
16
-
17
- def after_feature(feature)
18
- super
19
- @io.puts
20
- end
21
- end
22
- end
23
- end
24
-