aslakhellesoy-cucumber 0.3.93.1 → 0.3.94

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,10 +1,4 @@
1
- require 'erb'
2
- begin
3
- require 'builder'
4
- rescue LoadError
5
- gem 'builder'
6
- require 'builder'
7
- end
1
+ require 'cucumber/formatter/ordered_xml_markup'
8
2
  require 'cucumber/formatter/duration'
9
3
 
10
4
  module Cucumber
@@ -20,7 +14,7 @@ module Cucumber
20
14
  end
21
15
 
22
16
  def create_builder(io)
23
- Builder::XmlMarkup.new(:target => io, :indent => 0)
17
+ OrderedXmlMarkup.new(:target => io, :indent => 0)
24
18
  end
25
19
 
26
20
  def visit_features(features)
@@ -1,9 +1,4 @@
1
- begin
2
- require 'builder'
3
- rescue LoadError
4
- gem 'builder'
5
- require 'builder'
6
- end
1
+ require 'cucumber/formatter/ordered_xml_markup'
7
2
 
8
3
  module Cucumber
9
4
  module Formatter
@@ -18,16 +13,18 @@ module Cucumber
18
13
 
19
14
  def visit_feature(feature)
20
15
  @failures = @errors = @tests = 0
21
- @builder = Builder::XmlMarkup.new( :indent => 2 )
16
+ @builder = OrderedXmlMarkup.new( :indent => 2 )
17
+ @time = 0
22
18
  super
23
19
 
24
- @testsuite = Builder::XmlMarkup.new( :indent => 2 )
20
+ @testsuite = OrderedXmlMarkup.new( :indent => 2 )
25
21
  @testsuite.instruct!
26
22
  @testsuite.testsuite(
27
23
  :failures => @failures,
28
24
  :errors => @errors,
29
25
  :tests => @tests,
30
- :name => @feature_name ) do
26
+ :time => "%.6f" % @time,
27
+ :name => @feature_name ) do
31
28
  @testsuite << @builder.target!
32
29
  end
33
30
 
@@ -36,40 +33,84 @@ module Cucumber
36
33
  File.open(feature_filename, 'w') { |file| file.write(@testsuite.target!) }
37
34
  end
38
35
 
36
+ def visit_background(name)
37
+ @in_background = true
38
+ super
39
+ @in_background = false
40
+ end
41
+
39
42
  def visit_feature_name(name)
40
43
  lines = name.split(/\r?\n/)
41
44
  @feature_name = lines[0].sub(/Feature\:/, '').strip
42
45
  end
43
46
 
44
47
  def visit_scenario_name(keyword, name, file_colon_line, source_indent)
45
- @scenario = name
48
+ scenario_name = name.strip
49
+ scenario_name = "Unnamed scenario" if name == ""
50
+ @scenario = scenario_name
51
+ @outline = keyword.include?('Scenario Outline')
52
+ @output = "Scenario#{ " outline" if @outline}: #{@scenario}\n\n"
46
53
  end
47
54
 
48
55
  def visit_steps(steps)
49
- @steps_failed = false
56
+ return if @in_background
57
+ start = Time.now
50
58
  super
51
- @failures += 1 if @steps_failed
52
- @tests += 1
59
+ duration = Time.now - start
60
+ unless @outline
61
+ if steps.failed?
62
+ steps.each { |step| @output += "#{step.keyword} #{step.name}\n" }
63
+ @output += "\nMessage:\n"
64
+ end
65
+ build_testcase(duration, steps.status, steps.exception)
66
+ end
67
+ end
68
+
69
+ def visit_outline_table(outline_table)
70
+ @header_row = true
71
+ super(outline_table)
53
72
  end
54
73
 
55
- def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
56
- step_name = keyword + " " + step_match.format_args(lambda{|param| "*#{param}*"})
57
- @builder.testcase(:classname => "#{@feature_name}.#{@scenario}", :name => step_name) do
58
- if status != :passed
59
- @builder.failure(:message => step_name) do
60
- @builder.text!(format_exception(exception)) if exception
74
+ def visit_table_row(table_row)
75
+ if @outline
76
+ start = Time.now
77
+ super(table_row)
78
+ duration = Time.now - start
79
+ unless @header_row
80
+ name_suffix = " (outline example : #{table_row.name})"
81
+ if table_row.failed?
82
+ @output += "Example row: #{table_row.name}\n"
83
+ @output += "\nMessage:\n"
61
84
  end
62
- @steps_failed = true
85
+ build_testcase(duration, table_row.status, table_row.exception, name_suffix)
63
86
  end
87
+ else
88
+ super(table_row)
64
89
  end
90
+ @header_row = false
65
91
  end
66
92
 
67
93
  private
68
94
 
69
- def format_exception(exception)
70
- (["#{exception.message} (#{exception.class})"] + exception.backtrace).join("\n")
71
- end
72
- end
95
+ def build_testcase(duration, status, exception = nil, suffix = "")
96
+ @time += duration
97
+ classname = "#{@feature_name}.#{@scenario}"
98
+ name = "#{@scenario}#{suffix}"
99
+ @builder.testcase(:classname => classname, :name => name, :time => "%.6f" % duration) do
100
+ if status != :passed
101
+ @builder.failure(:message => "#{status.to_s} #{name}", :type => status.to_s) do
102
+ @builder.text! @output
103
+ @builder.text!(format_exception(exception)) if exception
104
+ end
105
+ @failures += 1
106
+ end
107
+ end
108
+ @tests += 1
109
+ end
73
110
 
111
+ def format_exception(exception)
112
+ (["#{exception.message} (#{exception.class})"] + exception.backtrace).join("\n")
113
+ end
114
+ end
74
115
  end
75
116
  end
@@ -48,14 +48,14 @@ module Cucumber
48
48
  end
49
49
 
50
50
  def visit_comment_line(comment_line)
51
- @io.puts(comment_line.indent(@indent))
51
+ @io.puts(comment_line.indent(@indent))
52
52
  @io.flush
53
53
  end
54
54
 
55
55
  def visit_tags(tags)
56
56
  tags.accept(self)
57
57
  if @indent == 1
58
- @io.puts
58
+ @io.puts
59
59
  @io.flush
60
60
  end
61
61
  end
@@ -74,6 +74,7 @@ module Cucumber
74
74
  end
75
75
 
76
76
  def visit_feature_element(feature_element)
77
+ record_tag_occurrences(feature_element, @options)
77
78
  @indent = 2
78
79
  @scenario_indent = 2
79
80
  super
@@ -160,7 +161,7 @@ module Cucumber
160
161
  super
161
162
  @io.puts
162
163
  if table_row.exception && !@exceptions.index(table_row.exception)
163
- print_exception(table_row.exception, :failed, @indent)
164
+ print_exception(table_row.exception, :failed, @indent)
164
165
  end
165
166
  end
166
167
 
@@ -187,7 +188,10 @@ module Cucumber
187
188
  end
188
189
 
189
190
  private
190
-
191
+ def cell_prefix(status)
192
+ @prefixes[status]
193
+ end
194
+
191
195
  def cell_prefix(status)
192
196
  @prefixes[status]
193
197
  end
@@ -196,6 +200,7 @@ module Cucumber
196
200
  print_stats(features)
197
201
  print_snippets(@options)
198
202
  print_passing_wip(@options)
203
+ print_tag_limit_warnings(@options)
199
204
  end
200
205
 
201
206
  end
@@ -18,6 +18,11 @@ module Cucumber
18
18
  print_summary(features)
19
19
  end
20
20
 
21
+ def visit_feature_element(feature_element)
22
+ record_tag_occurrences(feature_element, @options)
23
+ super
24
+ end
25
+
21
26
  def visit_step_result(keyword, step_match, multiline_arg, status, exception, source_indent, background)
22
27
  progress(status)
23
28
  @status = status
@@ -36,6 +41,7 @@ module Cucumber
36
41
  print_stats(features)
37
42
  print_snippets(@options)
38
43
  print_passing_wip(@options)
44
+ print_tag_limit_warnings(@options)
39
45
  end
40
46
 
41
47
  CHARS = {
@@ -51,7 +57,7 @@ module Cucumber
51
57
  @io.print(format_string(char, status))
52
58
  @io.flush
53
59
  end
54
-
60
+
55
61
  def table_header_cell?(status)
56
62
  status == :skipped_param
57
63
  end
@@ -8,8 +8,8 @@ module Cucumber
8
8
  #
9
9
  # Cucumber::Rake::Task.new
10
10
  #
11
- # This will create a task named 'features' described as 'Run Features with
12
- # Cucumber'. It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
11
+ # This will create a task named 'cucumber' described as 'Run Cucumber features'.
12
+ # It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
13
13
  #
14
14
  # To further configure the task, you can pass a block:
15
15
  #
@@ -148,7 +148,7 @@ module Cucumber
148
148
  end
149
149
 
150
150
  # Define Cucumber Rake task
151
- def initialize(task_name = "features", desc = "Run Features with Cucumber")
151
+ def initialize(task_name = "cucumber", desc = "Run Cucumber features")
152
152
  @task_name, @desc = task_name, desc
153
153
  @fork = true
154
154
  @libs = ['lib']
@@ -127,7 +127,9 @@ module Cucumber
127
127
  end
128
128
 
129
129
  # Registers a new StepDefinition. This method is aliased
130
- # to <tt>Given</tt>, <tt>When</tt> and <tt>Then</tt>.
130
+ # to <tt>Given</tt>, <tt>When</tt> and <tt>Then</tt>, and
131
+ # also to the i18n translations whenever a feature of a
132
+ # new language is loaded.
131
133
  #
132
134
  # See Cucumber#alias_steps for details on how to
133
135
  # create your own aliases.
@@ -2,8 +2,8 @@ module Cucumber #:nodoc:
2
2
  class VERSION #:nodoc:
3
3
  MAJOR = 0
4
4
  MINOR = 3
5
- TINY = 93
6
- PATCH = 1 # Set to nil for official release
5
+ TINY = 94
6
+ PATCH = nil # Set to nil for official release
7
7
 
8
8
  STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
9
9
  end
@@ -4,15 +4,27 @@ unless ARGV.any? {|a| a =~ /^gems/}
4
4
 
5
5
  begin
6
6
  require 'cucumber/rake/task'
7
+ namespace :cucumber do
8
+ Cucumber::Rake::Task.new({:ok => 'db:test:prepare'}, 'Run features that should pass') do |t|
9
+ t.fork = true # You may get faster startup if you set this to false
10
+ t.cucumber_opts = "--tags ~@wip --strict --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}<%= spork? ? ' --drb' : '' %>"
11
+ end
7
12
 
8
- Cucumber::Rake::Task.new(:features) do |t|
9
- t.fork = true
10
- t.cucumber_opts = [<%= options[:spork] ? "'--drb', " : "" %>'--format', (ENV['CUCUMBER_FORMAT'] || 'pretty')]
13
+ Cucumber::Rake::Task.new({:wip => 'db:test:prepare'}, 'Run features that are being worked on') do |t|
14
+ t.fork = true # You may get faster startup if you set this to false
15
+ t.cucumber_opts = "--tags @wip:2 --wip --format #{ENV['CUCUMBER_FORMAT'] || 'pretty'}<%= spork? ? ' --drb' : '' %>"
16
+ end
17
+
18
+ desc 'Run all features'
19
+ task :all => [:ok, :wip]
20
+ end
21
+
22
+ task :features => 'cucumber:ok' do
23
+ STDERR.puts "*** The 'features' task is deprecated. See rake -T cucumber ***"
11
24
  end
12
- task :features => 'db:test:prepare'
13
25
  rescue LoadError
14
- desc 'Cucumber rake task not available'
15
- task :features do
26
+ desc 'cucumber rake task not available (cucumber not installed)'
27
+ task :cucumber do
16
28
  abort 'Cucumber rake task is not available. Be sure to install cucumber as a gem or plugin'
17
29
  end
18
30
  end
@@ -47,7 +47,7 @@ module Cucumber
47
47
  ]
48
48
  ]
49
49
  ]
50
-
50
+
51
51
  )
52
52
  end
53
53
 
@@ -59,7 +59,7 @@ module Cucumber
59
59
 
60
60
  it "should pretty print" do
61
61
  require 'cucumber/formatter/pretty'
62
- visitor = Formatter::Pretty.new(@step_mother, STDOUT, {:comment => true})
62
+ visitor = Formatter::Pretty.new(@step_mother, STDOUT, {:comment => true, :include_tags => {}, :exclude_tags => {}})
63
63
  visitor.visit_feature_element(@scenario_outline)
64
64
  end
65
65
  end
@@ -101,6 +101,11 @@ module Cucumber
101
101
  table2.hashes.first[:three].should == '4444'
102
102
  end
103
103
 
104
+ it "should allow renaming columns using regexp" do
105
+ table2 = @table.map_headers(/one|uno/ => :three)
106
+ table2.hashes.first[:three].should == '4444'
107
+ end
108
+
104
109
  it "should copy column mappings when mapping headers" do
105
110
  @table.map_column!('one') { |v| v.to_i }
106
111
  table2 = @table.map_headers('one' => 'three')
@@ -361,7 +361,8 @@ END_OF_MESSAGE
361
361
 
362
362
  it "should accept --no-color option" do
363
363
  Term::ANSIColor.should_receive(:coloring=).with(false)
364
- config.parse!(%w[--no-color])
364
+ config = Configuration.new(StringIO.new)
365
+ config.parse!(['--no-color'])
365
366
  end
366
367
 
367
368
  describe "--backtrace" do
@@ -87,10 +87,10 @@ module Cli
87
87
 
88
88
  context '-t TAGS --tags TAGS' do
89
89
  it "removes the @ prefix" do
90
- after_parsing('-t @foo,bar') { options[:include_tags].should == ['foo','bar'] }
90
+ after_parsing('-t @foo,bar') { options[:include_tags].should == {'foo' => nil, 'bar' => nil} }
91
91
  end
92
92
  it "designates tags prefixed with ~ as tags to be excluded" do
93
- after_parsing('--tags ~@foo,bar') { options[:exclude_tags].should == ['foo'] }
93
+ after_parsing('--tags ~@foo,bar') { options[:exclude_tags].should == {'foo' => nil} }
94
94
  end
95
95
  end
96
96
 
@@ -157,13 +157,13 @@ module Cli
157
157
  it "combines the include_tags of both" do
158
158
  given_cucumber_yml_defined_as('baz' => %w[-t bar])
159
159
  options.parse!(%w[--tags foo -p baz])
160
- options[:include_tags].should == %w[foo bar]
160
+ options[:include_tags].should == {'foo' => nil, 'bar' => nil}
161
161
  end
162
162
 
163
163
  it "combines the exclude_tags of both" do
164
164
  given_cucumber_yml_defined_as('baz' => %w[-t ~bar])
165
165
  options.parse!(%w[--tags ~foo -p baz])
166
- options[:exclude_tags].should == %w[foo bar]
166
+ options[:exclude_tags].should == {'foo' => nil, 'bar' => nil}
167
167
  end
168
168
 
169
169
  it "only takes the paths from the original options, and disgregards the profiles" do
@@ -269,8 +269,6 @@ module Cli
269
269
  options[:paths].should == ['my_feature.feature']
270
270
  end
271
271
  end
272
-
273
-
274
272
  end
275
273
 
276
274
  describe '#expanded_args_without_drb' do
@@ -295,6 +293,13 @@ module Cli
295
293
  options.expanded_args_without_drb.should == %w[features FOO=bar]
296
294
  end
297
295
 
296
+ it "ignores the paths from the profiles if one was specified on the command line" do
297
+ given_cucumber_yml_defined_as('foo' => 'features --drb')
298
+ options.parse!(%w[some_feature.feature -p foo])
299
+ options.expanded_args_without_drb.should == %w[some_feature.feature]
300
+ end
301
+
302
+
298
303
 
299
304
 
300
305
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aslakhellesoy-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.93.1
4
+ version: 0.3.94
5
5
  platform: ruby
6
6
  authors:
7
7
  - "Aslak Helles\xC3\xB8y"
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-08-03 00:00:00 -07:00
12
+ date: 2009-08-06 00:00:00 -07:00
13
13
  default_executable: cucumber
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency