cucumber 1.1.9 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. data/.travis.yml +9 -0
  2. data/History.md +20 -3
  3. data/README.md +1 -2
  4. data/cucumber.gemspec +10 -13
  5. data/cucumber.yml +2 -2
  6. data/features/.cucumber/stepdefs.json +13 -391
  7. data/features/backtraces.feature +36 -0
  8. data/features/{issue_117.feature → drb_server_integration.feature} +3 -3
  9. data/features/formatter_step_file_colon_line.feature +46 -0
  10. data/features/{issue_57.feature → rerun_formatter.feature} +2 -2
  11. data/features/run_specific_scenarios.feature +47 -0
  12. data/gem_tasks/cucumber.rake +15 -8
  13. data/legacy_features/cucumber_cli.feature +0 -7
  14. data/legacy_features/junit_formatter.feature +60 -10
  15. data/legacy_features/language_help.feature +1 -0
  16. data/lib/cucumber.rb +2 -1
  17. data/lib/cucumber/ast/step.rb +1 -1
  18. data/lib/cucumber/ast/step_invocation.rb +2 -15
  19. data/lib/cucumber/ast/table.rb +16 -6
  20. data/lib/cucumber/ast/tree_walker.rb +5 -5
  21. data/lib/cucumber/cli/options.rb +5 -8
  22. data/lib/cucumber/formatter/ansicolor.rb +7 -12
  23. data/lib/cucumber/formatter/cucumber.css +7 -1
  24. data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +1 -1
  25. data/lib/cucumber/formatter/html.rb +5 -5
  26. data/lib/cucumber/formatter/interceptor.rb +62 -0
  27. data/lib/cucumber/formatter/junit.rb +30 -14
  28. data/lib/cucumber/formatter/pretty.rb +3 -3
  29. data/lib/cucumber/formatter/progress.rb +1 -1
  30. data/lib/cucumber/formatter/rerun.rb +1 -1
  31. data/lib/cucumber/formatter/usage.rb +1 -1
  32. data/lib/cucumber/js_support/js_snippets.rb +1 -1
  33. data/lib/cucumber/platform.rb +1 -1
  34. data/lib/cucumber/rb_support/rb_dsl.rb +15 -8
  35. data/lib/cucumber/rb_support/rb_language.rb +3 -3
  36. data/lib/cucumber/rb_support/rb_step_definition.rb +17 -5
  37. data/lib/cucumber/term/ansicolor.rb +118 -0
  38. data/spec/cucumber/ast/table_spec.rb +9 -0
  39. data/spec/cucumber/cli/configuration_spec.rb +12 -6
  40. data/spec/cucumber/cli/options_spec.rb +9 -3
  41. data/spec/cucumber/constantize_spec.rb +5 -1
  42. data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
  43. data/spec/cucumber/formatter/interceptor_spec.rb +111 -0
  44. data/spec/cucumber/formatter/junit_spec.rb +36 -20
  45. data/spec/cucumber/formatter/progress_spec.rb +2 -2
  46. data/spec/cucumber/rb_support/rb_language_spec.rb +5 -5
  47. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +17 -1
  48. data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +6 -2
  49. data/spec/cucumber/step_match_spec.rb +8 -4
  50. data/spec/spec_helper.rb +15 -1
  51. metadata +215 -82
  52. data/.gitmodules +0 -3
  53. data/lib/cucumber/formatter/pdf.rb +0 -244
@@ -1,3 +0,0 @@
1
- [submodule "features/cucumber-features"]
2
- path = features/cucumber-features
3
- url = https://github.com/cucumber/cucumber-features
@@ -1,244 +0,0 @@
1
- require 'cucumber/formatter/console'
2
- require 'cucumber/formatter/io'
3
- require 'fileutils'
4
-
5
- begin
6
- require 'rubygems'
7
- require 'prawn/core'
8
- require "prawn/layout"
9
- rescue LoadError => e
10
- e.message << "\nYou need the prawn gem. Please do 'gem install prawn'"
11
- raise e
12
- end
13
-
14
- module Cucumber
15
- module Formatter
16
-
17
- BLACK = '000000'
18
- GREY = '999999'
19
-
20
- class Pdf
21
- include FileUtils
22
- include Console
23
- include Io
24
- attr_writer :indent
25
-
26
- def initialize(step_mother, path_or_io, options)
27
- @step_mother = step_mother
28
- @file = ensure_file(path_or_io, "pdf")
29
-
30
- if(options[:dry_run])
31
- @status_colors = { :passed => BLACK, :skipped => BLACK, :undefined => BLACK, :failed => BLACK, :putsd => GREY}
32
- else
33
- @status_colors = { :passed => '055902', :skipped => GREY, :undefined => 'F27405', :failed => '730202', :putsd => GREY}
34
- end
35
-
36
- @pdf = Prawn::Document.new
37
- @scrap = Prawn::Document.new
38
- @doc = @scrap
39
- @options = options
40
- @exceptions = []
41
- @indent = 0
42
- @buffer = []
43
- load_cover_page_image
44
- @pdf.text "\n\n\nCucumber features", :align => :center, :size => 32
45
- @pdf.draw_text "Generated: #{Time.now.strftime("%Y-%m-%d %H:%M")}", :size => 10, :at => [0, 24]
46
- @pdf.draw_text "$ cucumber #{ARGV.join(" ")}", :size => 10, :at => [0,10]
47
- unless options[:dry_run]
48
- @pdf.bounding_box [450,100] , :width => 100 do
49
- @pdf.text 'Legend', :size => 10
50
- @status_colors.each do |k,v|
51
- @pdf.fill_color v
52
- @pdf.text k.to_s, :size => 10
53
- @pdf.fill_color BLACK
54
- end
55
- end
56
- end
57
- end
58
-
59
- def load_cover_page_image()
60
- if (!load_image("features/support/logo.png"))
61
- load_image("features/support/logo.jpg")
62
- end
63
- end
64
-
65
- def load_image(image_path)
66
- begin
67
- @pdf.image open(image_path, "rb"), :position => :center, :width => 500
68
- true
69
- rescue Errno::ENOENT
70
- false
71
- end
72
- end
73
-
74
- def puts(message)
75
- @pdf.fill_color(@status_colors[:putsd])
76
- @pdf.text message, :size => 10
77
- @pdf.fill_color BLACK
78
- end
79
-
80
-
81
- def after_features(features)
82
- @pdf.render_file(@file.path)
83
- puts "\ndone"
84
- end
85
-
86
- def feature_name(keyword, name)
87
- @pdf.start_new_page
88
- names = name.split("\n")
89
- @pdf.fill_color GREY
90
- @pdf.text(keyword, :align => :center)
91
- @pdf.fill_color BLACK
92
- names.each_with_index do |nameline, i|
93
- case i
94
- when 0
95
- @pdf.text(nameline.strip, :size => 30, :align => :center )
96
- @pdf.text("\n")
97
- else
98
- @pdf.text(nameline.strip, :size => 12)
99
- end
100
- end
101
- @pdf.move_down(30)
102
- end
103
-
104
- def after_feature_element(feature_element)
105
- flush
106
- end
107
-
108
- def after_feature(feature)
109
- flush
110
- end
111
-
112
- def feature_element_name(keyword, name)
113
- names = name.empty? ? [name] : name.split("\n")
114
- print "."
115
- STDOUT.flush
116
-
117
- keep_with do
118
- @doc.move_down(20)
119
- @doc.fill_color GREY
120
- @doc.text("#{keyword}", :size => 8)
121
- @doc.fill_color BLACK
122
- @doc.text("#{names[0]}", :size => 16)
123
- names[1..-1].each { |s| @doc.text(s, :size => 12) }
124
- @doc.text("\n")
125
- end
126
- end
127
-
128
- def step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
129
- @hide_this_step = false
130
- if exception
131
- if @exceptions.include?(exception)
132
- @hide_this_step = true
133
- return
134
- end
135
- @exceptions << exception
136
- end
137
- if status != :failed && @in_background ^ background
138
- @hide_this_step = true
139
- return
140
- end
141
- end
142
-
143
- def step_name(keyword, step_match, status, source_indent, background)
144
- return if @hide_this_step
145
- line = "#{keyword} #{step_match.format_args("%s")}"
146
- colorize(line, status)
147
- end
148
-
149
- def before_background(background)
150
- @in_background = true
151
- end
152
-
153
- def after_background(background)
154
- @in_background = nil
155
- end
156
-
157
- def before_multiline_arg(table)
158
- return if @hide_this_step
159
- if(table.kind_of? Cucumber::Ast::Table)
160
- keep_with do
161
- print_table(table, ['ffffff', 'f0f0f0'])
162
- end
163
- end
164
- end
165
-
166
- #using row_color hack to highlight each row correctly
167
- def before_outline_table(table)
168
- return if @hide_this_step
169
- row_colors = table.example_rows.map { |r| @status_colors[r.status] unless r.status == :skipped}
170
- keep_with do
171
- print_table(table, row_colors)
172
- end
173
- end
174
-
175
- def before_doc_string(string)
176
- return if @hide_this_step
177
- s = %{"""\n#{string}\n"""}.indent(10)
178
- s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}
179
- s.each do |line|
180
- keep_with { @doc.text(line, :size => 8) }
181
- end
182
- end
183
-
184
- def tag_name(tag_name)
185
- return if @hide_this_step
186
- tag = format_string(tag_name, :tag).indent(@indent)
187
- # TODO should we render tags at all? skipped for now. difficult to place due to page breaks
188
- end
189
-
190
- def background_name(keyword, name, file_colon_line, source_indent)
191
- feature_element_name(keyword, name)
192
- end
193
-
194
- def examples_name(keyword, name)
195
- feature_element_name(keyword, name)
196
- end
197
-
198
- def scenario_name(keyword, name, file_colon_line, source_indent)
199
- feature_element_name(keyword, name)
200
- end
201
-
202
- private
203
-
204
- def colorize(text, status)
205
- keep_with do
206
- @doc.fill_color(@status_colors[status] || BLACK)
207
- @doc.text(text)
208
- @doc.fill_color(BLACK)
209
- end
210
- end
211
-
212
- def keep_with(&block)
213
- @buffer << block
214
- end
215
-
216
- def render(doc)
217
- @doc = doc
218
- @buffer.each do |proc|
219
- proc.call
220
- end
221
- end
222
-
223
- # This method does a 'test' rendering on a blank page, to see the rendered height of the buffer
224
- # if that too high for the space left on the age in the real document, we do a page break.
225
- # This obviously doesn't work if a scenario is longer than a whole page (God forbid)
226
- def flush
227
- @scrap.start_new_page
228
- oldy = @scrap.y
229
- render @scrap
230
- height = (oldy - @scrap.y) + 36 # whops magic number
231
- if ((@pdf.y - height) < @pdf.bounds.bottom)
232
- @pdf.start_new_page
233
- end
234
- render @pdf
235
- @pdf.move_down(20)
236
- @buffer = []
237
- end
238
-
239
- def print_table(table, row_colors)
240
- @doc.table(table.rows, :headers => table.headers, :position => :center, :row_colors => row_colors)
241
- end
242
- end
243
- end
244
- end