cucumber 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. data/.gitattributes +1 -0
  2. data/.gitignore +17 -0
  3. data/History.txt +27 -0
  4. data/{License.txt → LICENSE} +0 -0
  5. data/Manifest.txt +0 -487
  6. data/README.rdoc +26 -0
  7. data/Rakefile +54 -7
  8. data/VERSION.yml +4 -0
  9. data/bin/cucumber +1 -1
  10. data/cucumber.gemspec +743 -0
  11. data/cucumber.yml +3 -1
  12. data/examples/cs/.gitignore +1 -0
  13. data/examples/i18n/Rakefile +1 -1
  14. data/examples/i18n/de/.gitignore +1 -0
  15. data/examples/i18n/en/.gitignore +1 -0
  16. data/examples/i18n/fi/.gitignore +1 -0
  17. data/examples/i18n/hu/.gitignore +1 -0
  18. data/examples/i18n/id/.gitignore +1 -0
  19. data/examples/i18n/ja/.gitignore +1 -0
  20. data/examples/i18n/ko/.gitignore +1 -0
  21. data/examples/i18n/lt/.gitignore +1 -0
  22. data/examples/i18n/pl/.gitignore +1 -0
  23. data/examples/i18n/sk/.gitignore +1 -0
  24. data/examples/i18n/sr-latn/Rakefile +6 -0
  25. data/examples/i18n/sr-latn/features/sabiranje.feature +18 -0
  26. data/examples/i18n/sr-latn/features/step_definitons/calculator_steps.rb +24 -0
  27. data/examples/i18n/sr-latn/lib/calculator.rb +12 -0
  28. data/examples/i18n/sr/Rakefile +6 -0
  29. data/examples/i18n/sr/features/sabiranje.feature +18 -0
  30. data/examples/i18n/sr/features/step_definitons/calculator_steps.rb +24 -0
  31. data/examples/i18n/sr/lib/calculator.rb +12 -0
  32. data/examples/i18n/tr/.gitignore +1 -0
  33. data/examples/i18n/tr/features/{bo/314/210lme.feature → bolme.feature} +0 -0
  34. data/examples/i18n/tr/features/step_definitons/{hesap_makinesi_ad/304/261mlar/304/261.rb → hesap_makinesi_adimlari.rb} +0 -0
  35. data/examples/i18n/zh-TW/.gitignore +1 -0
  36. data/examples/java/.gitignore +1 -0
  37. data/examples/java/src/.gitignore +1 -0
  38. data/examples/java/src/cucumber/demo/.gitignore +1 -0
  39. data/examples/python/lib/.gitignore +1 -0
  40. data/examples/ruby2python/lib/.gitignore +1 -0
  41. data/examples/self_test/.gitignore +1 -0
  42. data/features/background.feature +0 -3
  43. data/features/bug_464.feature +16 -0
  44. data/features/cucumber_cli.feature +4 -6
  45. data/features/cucumber_cli_diff_disabled.feature +0 -2
  46. data/features/cucumber_cli_outlines.feature +0 -4
  47. data/features/drb_server_integration.feature +1 -0
  48. data/features/exception_in_after_block.feature +0 -2
  49. data/features/exception_in_after_step_block.feature +0 -2
  50. data/features/exception_in_before_block.feature +0 -2
  51. data/features/junit_formatter.feature +0 -1
  52. data/features/language_help.feature +40 -38
  53. data/features/listener_debugger_formatter.feature +41 -0
  54. data/features/post_configuration_hook.feature +1 -1
  55. data/features/report_called_undefined_steps.feature +0 -1
  56. data/features/step_definitions/simplest_steps.rb +0 -3
  57. data/features/support/env.rb +5 -1
  58. data/features/transform.feature +1 -1
  59. data/features/usage_and_stepdefs_formatter.feature +1 -3
  60. data/features/work_in_progress.feature +0 -2
  61. data/gem_tasks/features.rake +6 -1
  62. data/gem_tasks/rspec.rake +5 -35
  63. data/gem_tasks/sdoc.rake +10 -5
  64. data/lib/autotest/cucumber_mixin.rb +6 -0
  65. data/lib/cucumber.rb +0 -1
  66. data/lib/cucumber/ast/step_invocation.rb +3 -0
  67. data/lib/cucumber/cli/configuration.rb +7 -2
  68. data/lib/cucumber/cli/options.rb +8 -7
  69. data/lib/cucumber/core_ext/proc.rb +1 -0
  70. data/lib/cucumber/formatter/ansicolor.rb +0 -9
  71. data/lib/cucumber/formatter/console.rb +14 -12
  72. data/lib/cucumber/formatter/debug.rb +33 -0
  73. data/lib/cucumber/formatter/pretty.rb +2 -2
  74. data/lib/cucumber/formatter/rerun.rb +9 -6
  75. data/lib/cucumber/language_support/language_methods.rb +2 -2
  76. data/lib/cucumber/languages.yml +37 -1
  77. data/lib/cucumber/platform.rb +3 -1
  78. data/lib/cucumber/py_support/py_language.py +1 -1
  79. data/lib/cucumber/py_support/py_language.rb +2 -2
  80. data/lib/cucumber/rb_support/rb_language.rb +6 -7
  81. data/lib/cucumber/rb_support/rb_step_definition.rb +0 -1
  82. data/lib/cucumber/rb_support/rb_world.rb +1 -2
  83. data/lib/cucumber/step_match.rb +10 -7
  84. data/lib/cucumber/step_mother.rb +6 -3
  85. data/rails_generators/cucumber/cucumber_generator.rb +49 -6
  86. data/spec/cucumber/cli/options_spec.rb +1 -1
  87. data/spec/cucumber/formatter/console_spec.rb +20 -0
  88. data/spec/cucumber/step_match_spec.rb +10 -5
  89. metadata +258 -43
  90. data/README.txt +0 -4
  91. data/config/hoe.rb +0 -84
  92. data/config/requirements.rb +0 -15
  93. data/gem_tasks/deployment.rake +0 -11
  94. data/gem_tasks/gemspec.rake +0 -10
  95. data/lib/cucumber/language_support/step_definition_methods.rb +0 -23
  96. data/lib/cucumber/version.rb +0 -10
@@ -0,0 +1,41 @@
1
+ Feature: Listener Debugger
2
+ In order to easily visualise the listener API
3
+ As a developer
4
+ I want a formatter that prints the calls to the listener as a feature is run
5
+
6
+ Background:
7
+ Given a standard Cucumber project directory structure
8
+
9
+ Scenario: title
10
+ Given a file named "features/sample.feature" with:
11
+ """
12
+ Feature: Sample
13
+
14
+ Scenario: Sample
15
+ Given Sample
16
+
17
+ """
18
+ When I run cucumber -f debug features/sample.feature
19
+ Then it should pass with
20
+ """
21
+ before_features
22
+ before_feature
23
+ before_tags
24
+ after_tags
25
+ feature_name
26
+ before_feature_element
27
+ before_tags
28
+ after_tags
29
+ scenario_name
30
+ before_steps
31
+ before_step
32
+ before_step_result
33
+ step_name
34
+ after_step_result
35
+ after_step
36
+ after_steps
37
+ after_feature_element
38
+ after_feature
39
+ after_features
40
+
41
+ """
@@ -26,7 +26,7 @@ Feature: Post Configuration Hook [#423]
26
26
  And a file named "features/support/env.rb" with:
27
27
  """
28
28
  AfterConfiguration do |config|
29
- config.out_stream << "AfterConfiguration hook read feature directories: #{config.feature_dirs}"
29
+ config.out_stream << "AfterConfiguration hook read feature directories: #{config.feature_dirs.join(', ')}"
30
30
  end
31
31
  """
32
32
  When I run cucumber features
@@ -2,7 +2,6 @@ Feature: Cucumber command line
2
2
  In order to find out what step definitions need to be implemented
3
3
  Developers should always see what step definition is missing
4
4
 
5
- @mri186
6
5
  Scenario: Get info at arbitrary levels of nesting
7
6
  When I run cucumber features/call_undefined_step_from_step_def.feature
8
7
  Then it should pass with
@@ -1,6 +1,3 @@
1
- require 'rubygems'
2
- require 'ruby-debug'
3
-
4
1
  Given /^this step works$/ do
5
2
  end
6
3
 
@@ -39,13 +39,17 @@ class CucumberWorld
39
39
 
40
40
  # The last standard out, with the duration line taken out (unpredictable)
41
41
  def last_stdout
42
- strip_duration(@last_stdout)
42
+ strip_1_9_paths(strip_duration(@last_stdout))
43
43
  end
44
44
 
45
45
  def strip_duration(s)
46
46
  s.gsub(/^\d+m\d+\.\d+s\n/m, "")
47
47
  end
48
48
 
49
+ def strip_1_9_paths(s)
50
+ s.gsub(/#{Dir.pwd}\/examples\/self_test\/tmp/m, ".").gsub(/#{Dir.pwd}\/examples\/self_test/m, ".")
51
+ end
52
+
49
53
  def replace_duration(s, replacement)
50
54
  s.gsub(/\d+m\d+\.\d+s/m, replacement)
51
55
  end
@@ -38,7 +38,7 @@ Feature: transform
38
38
  end
39
39
 
40
40
  Transform /^'(\d+)' to a Float$/ do |integer_string|
41
- Float.induced_from Transform("'#{integer_string}' to an Integer")
41
+ Transform("'#{integer_string}' to an Integer").to_f
42
42
  end
43
43
 
44
44
  Transform(/^('\w+') to Nil$/) {|str| nil }
@@ -3,7 +3,6 @@ Feature: Cucumber command line
3
3
  steps and step definitions, Cucumber must provide a way to
4
4
  display how they are related.
5
5
 
6
- @mri186
7
6
  Scenario: List usage of step definitions
8
7
  When I run cucumber features --format usage --dry-run
9
8
  Then STDERR should be empty
@@ -137,8 +136,7 @@ Feature: Cucumber command line
137
136
 
138
137
  """
139
138
 
140
- @mri186
141
- Scenario: --format steps
139
+ Scenario: --format steps
142
140
  When I run cucumber features --format stepdefs --dry-run
143
141
  Then STDERR should be empty
144
142
  And it should pass with
@@ -49,7 +49,6 @@ Feature: Cucumber --work-in-progress switch
49
49
  end
50
50
  """
51
51
 
52
- @mri186
53
52
  Scenario: Pass with Failing Scenarios
54
53
  When I run cucumber -q -w -t @failing features/wip.feature
55
54
  Then STDERR should be empty
@@ -91,7 +90,6 @@ Feature: Cucumber --work-in-progress switch
91
90
 
92
91
  """
93
92
 
94
- @mri186
95
93
  Scenario: Pass with Undefined Scenarios
96
94
  When I run cucumber -q -w -t @pending features/wip.feature
97
95
  Then it should pass with
@@ -1,8 +1,13 @@
1
1
  $:.unshift(File.dirname(__FILE__) + '/../lib')
2
2
  require 'cucumber/rake/task'
3
+ require 'cucumber/platform'
3
4
 
4
5
  Cucumber::Rake::Task.new do |t|
5
- t.cucumber_opts = %w{--format progress}
6
+ if(Cucumber::JRUBY)
7
+ t.profile = 'jruby'
8
+ elsif(Cucumber::WINDOWS_MRI)
9
+ t.profile = 'windows_mri'
10
+ end
6
11
  t.rcov = ENV['RCOV']
7
12
  end
8
13
 
@@ -1,40 +1,8 @@
1
- def unable_to_load
2
- STDERR.puts <<-EOS
3
- To use rspec for testing you must install rspec gem:
4
- gem install rspec
5
-
6
- EOS
7
- nil
8
- end
9
-
10
- def require_spec
1
+ begin
11
2
  require 'spec/expectations'
12
- rescue LoadError
13
- require_spec_with_rubygems
14
- end
3
+ require 'spec/rake/spectask'
15
4
 
16
- def require_spec_with_rubygems
17
- require 'rubygems'
18
- require 'spec/expectations'
19
- rescue LoadError
20
- unable_to_load
21
- end
22
-
23
- if require_spec
24
- begin
25
- require 'spec/rake/spectask'
26
- rescue LoadError
27
- unable_to_load
28
- end
29
-
30
- def undefine_task(*names)
31
- app = Rake.application
32
- tasks = app.instance_variable_get('@tasks')
33
- names.flatten.each { |name| tasks.delete(name) }
34
- end
35
- undefine_task('spec') # Hoe 1.2.12 is broken - it defines a spec task that we can't tweak.
36
-
37
- desc "Run the Cucumber specs"
5
+ desc "Run RSpec"
38
6
  Spec::Rake::SpecTask.new do |t|
39
7
  t.spec_opts = ['--options', "spec/spec.opts"]
40
8
  t.spec_files = FileList['spec/**/*_spec.rb']
@@ -42,4 +10,6 @@ if require_spec
42
10
  t.rcov_opts = %w{--exclude osx\/objc,gems\/,spec\/}
43
11
  t.verbose = true
44
12
  end
13
+ rescue LoadError
14
+ task :spec
45
15
  end
@@ -1,7 +1,12 @@
1
- require 'sdoc' # and use your RDoc task the same way you used it before
1
+ begin
2
+ require 'rake/rdoctask'
3
+ require 'sdoc' # and use your RDoc task the same way you used it before
2
4
 
3
- Rake::RDocTask.new(:sdoc) do |rdoc|
4
- rdoc.rdoc_dir = 'doc/sdoc'
5
- rdoc.options += %w{--fmt shtml -N --webcvs=http://github.com/aslakhellesoy/cucumber/blob/v0.3.96/%s --title "Cucumber API" --threads 4 --main README --exclude cucumber/parser lib}
6
- rdoc.template = 'direct' # lighter template used on railsapi.com
5
+ Rake::RDocTask.new(:sdoc) do |rdoc|
6
+ rdoc.rdoc_dir = 'doc/sdoc'
7
+ rdoc.title = "Cucumber"
8
+ rdoc.options += %w{--fmt shtml -N --webcvs=http://github.com/aslakhellesoy/cucumber/blob/v0.3.96/%s --title "Cucumber API" --threads 4 --main README --exclude cucumber/parser lib}
9
+ rdoc.template = 'direct' # lighter template used on railsapi.com
10
+ end
11
+ rescue LoadError => ignore
7
12
  end
@@ -118,6 +118,12 @@ module Autotest::CucumberMixin
118
118
  # No --color option as some IDEs (Netbeans) don't output them very well (1 failed step)
119
119
  args += %w{--format rerun --out} << dirty_features_filename
120
120
  args << (features_to_run == :all ? "features" : features_to_run)
121
+
122
+ # Unless I do this, all the steps turn up undefined during the rerun...
123
+ unless features_to_run == :all
124
+ args << 'features/step_definitions' << 'features/support'
125
+ end
126
+
121
127
  args = args.join(' ')
122
128
 
123
129
  return "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} #{args}"
@@ -4,7 +4,6 @@ $:.unshift(File.dirname(__FILE__)) unless
4
4
  require 'yaml'
5
5
  require 'cucumber/platform'
6
6
  require 'cucumber/parser'
7
- require 'cucumber/version'
8
7
  require 'cucumber/step_mother'
9
8
  require 'cucumber/cli/main'
10
9
  require 'cucumber/broadcaster'
@@ -105,6 +105,9 @@ module Cucumber
105
105
 
106
106
  def filter_backtrace(e)
107
107
  return e if Cucumber.use_full_backtrace
108
+ pwd = /#{Dir.pwd}\//m
109
+ (e.backtrace || []).each{|line| line.gsub!(pwd, "./")}
110
+
108
111
  filtered = (e.backtrace || []).reject do |line|
109
112
  BACKTRACE_FILTER_PATTERNS.detect { |p| line =~ p }
110
113
  end
@@ -135,8 +135,13 @@ module Cucumber
135
135
  unless File.directory?(out)
136
136
  out = File.open(out, Cucumber.file_mode('w'))
137
137
  at_exit do
138
- out.flush
139
- out.close
138
+
139
+ # Since Spork "never" actually exits, I want to flush and close earlier...
140
+ unless out.closed?
141
+ out.flush
142
+ out.close
143
+ end
144
+
140
145
  end
141
146
  end
142
147
  end
@@ -18,9 +18,10 @@ module Cucumber
18
18
  "#{' ' * 51}is not shown, and step definitions are sorted by\n" +
19
19
  "#{' ' * 51}filename instead."],
20
20
  'stepdefs' => ['Cucumber::Formatter::Stepdefs', "Prints All step definitions with their locations. Same as\n" +
21
- "the usage formatter, except that steps are not printed."],
21
+ "#{' ' * 51}the usage formatter, except that steps are not printed."],
22
22
  'junit' => ['Cucumber::Formatter::Junit', 'Generates a report similar to Ant+JUnit.'],
23
- 'tag_cloud' => ['Cucumber::Formatter::TagCloud', 'Prints a tag cloud of tag usage.']
23
+ 'tag_cloud' => ['Cucumber::Formatter::TagCloud', 'Prints a tag cloud of tag usage.'],
24
+ 'debug' => ['Cucumber::Formatter::Debug', 'For developing formatters - prints the calls made to the listeners.']
24
25
  }
25
26
  max = BUILTIN_FORMATS.keys.map{|s| s.length}.max
26
27
  FORMAT_HELP = (BUILTIN_FORMATS.keys.sort.map do |key|
@@ -232,12 +233,12 @@ module Cucumber
232
233
  @options[:drb_port] = port
233
234
  end
234
235
  opts.on_tail("--version", "Show version.") do
235
- @out_stream.puts VERSION::STRING
236
- Kernel.exit
236
+ @out_stream.puts Cucumber::VERSION
237
+ Kernel.exit(0)
237
238
  end
238
239
  opts.on_tail("-h", "--help", "You're looking at it.") do
239
240
  @out_stream.puts opts.help
240
- Kernel.exit
241
+ Kernel.exit(0)
241
242
  end
242
243
  end.parse!
243
244
 
@@ -359,12 +360,12 @@ module Cucumber
359
360
  raise("No language with key #{lang}")
360
361
  end
361
362
  LanguageHelpFormatter.list_keywords(@out_stream, lang)
362
- Kernel.exit
363
+ Kernel.exit(0)
363
364
  end
364
365
 
365
366
  def list_languages_and_exit
366
367
  LanguageHelpFormatter.list_languages(@out_stream)
367
- Kernel.exit
368
+ Kernel.exit(0)
368
369
  end
369
370
 
370
371
  def print_profile_information
@@ -13,6 +13,7 @@ class Proc #:nodoc:
13
13
  if Proc.new{}.to_s =~ PROC_PATTERN
14
14
  def file_colon_line
15
15
  path, line = *to_s.match(PROC_PATTERN)[1..2]
16
+ line = line.to_i - 1 if Cucumber::RUBY_1_9
16
17
  path = File.expand_path(path)
17
18
  pwd = Dir.pwd
18
19
  path = path[pwd.length+1..-1]
@@ -1,4 +1,3 @@
1
- gem 'term-ansicolor'
2
1
  require 'term/ansicolor'
3
2
 
4
3
  if Cucumber::WINDOWS_MRI
@@ -9,14 +8,6 @@ if Cucumber::WINDOWS_MRI
9
8
  STDERR.puts %{*** WARNING: You must "gem install win32console" (1.2.0 or higher) to get coloured output on MRI/Windows}
10
9
  Term::ANSIColor.coloring = false
11
10
  end
12
- elsif Cucumber::WINDOWS && Cucumber::JRUBY
13
- begin
14
- gem 'aslakhellesoy-ansicolor', '>= 1.0'
15
- require 'ansicolor'
16
- rescue LoadError
17
- STDERR.puts %{*** WARNING: You must "gem install aslakhellesoy-ansicolor --source http://gems.github.com" (1.0 or higher) to get coloured output on JRuby/Windows}
18
- Term::ANSIColor.coloring = false
19
- end
20
11
  end
21
12
 
22
13
  Term::ANSIColor.coloring = false if !STDOUT.tty? and not ENV.has_key?("AUTOTEST")
@@ -126,26 +126,28 @@ module Cucumber
126
126
  end
127
127
 
128
128
  def print_tag_limit_warnings(options)
129
- first_tag = true
130
- options[:tag_names].each do |tag_name, limit|
131
- unless Ast::Tags.exclude_tag?(tag_name)
132
- tag_frequnecy = @tag_occurences[tag_name].size
133
- if limit && tag_frequnecy > limit
134
- @io.puts if first_tag
135
- first_tag = false
136
- @io.puts format_string("#{tag_name} occurred #{tag_frequnecy} times, but the limit was set to #{limit}", :failed)
137
- @tag_occurences[tag_name].each {|location| @io.puts format_string(" #{location}", :failed)}
138
- @io.flush
129
+ if @tag_occurrences
130
+ first_tag = true
131
+ options[:tag_names].each do |tag_name, limit|
132
+ unless Ast::Tags.exclude_tag?(tag_name)
133
+ tag_frequency = @tag_occurrences[tag_name].size
134
+ if limit && tag_frequency > limit
135
+ @io.puts if first_tag
136
+ first_tag = false
137
+ @io.puts format_string("#{tag_name} occurred #{tag_frequency} times, but the limit was set to #{limit}", :failed)
138
+ @tag_occurrences[tag_name].each {|location| @io.puts format_string(" #{location}", :failed)}
139
+ @io.flush
140
+ end
139
141
  end
140
142
  end
141
143
  end
142
144
  end
143
145
 
144
146
  def record_tag_occurrences(feature_element, options)
145
- @tag_occurences ||= Hash.new{|k,v| k[v] = []}
147
+ @tag_occurrences ||= Hash.new{|k,v| k[v] = []}
146
148
  options[:tag_names].each do |tag_name, limit|
147
149
  if !Ast::Tags.exclude_tag?(tag_name) && feature_element.tag_count(tag_name) > 0
148
- @tag_occurences[tag_name] << feature_element.file_colon_line
150
+ @tag_occurrences[tag_name] << feature_element.file_colon_line
149
151
  end
150
152
  end
151
153
  end
@@ -0,0 +1,33 @@
1
+ require 'cucumber/formatter/progress'
2
+ require 'cucumber/step_definition_light'
3
+
4
+ module Cucumber
5
+ module Formatter
6
+ class Debug
7
+ def initialize(step_mother, io, options)
8
+ @io = io
9
+ @indent = 0
10
+ end
11
+
12
+ def respond_to?(*args)
13
+ true
14
+ end
15
+
16
+ def method_missing(name, *args)
17
+ @indent -= 2 if name.to_s =~ /^after/
18
+ print(name)
19
+ @indent += 2 if name.to_s =~ /^before/
20
+ end
21
+
22
+ private
23
+
24
+ def print(text)
25
+ @io.puts "#{indent}#{text}"
26
+ end
27
+
28
+ def indent
29
+ (' ' * @indent)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -148,8 +148,8 @@ module Cucumber
148
148
  def step_name(keyword, step_match, status, source_indent, background)
149
149
  return if @hide_this_step
150
150
  source_indent = nil unless @options[:source]
151
- formatted_step_name = format_step(keyword, step_match, status, source_indent)
152
- @io.puts(formatted_step_name.indent(@scenario_indent + 2))
151
+ name_to_report = format_step(keyword, step_match, status, source_indent)
152
+ @io.puts(name_to_report.indent(@scenario_indent + 2))
153
153
  end
154
154
 
155
155
  def py_string(string)
@@ -18,19 +18,22 @@ module Cucumber
18
18
  @file_colon_lines = Hash.new{|h,k| h[k] = []}
19
19
  end
20
20
 
21
- def features(features)
22
- super
21
+ # features() is never executed at all... ?
22
+ def after_features(features)
23
23
  files = @file_names.uniq.map do |file|
24
24
  lines = @file_colon_lines[file]
25
25
  "#{file}:#{lines.join(':')}"
26
26
  end
27
27
  @io.puts files.join(' ')
28
+
29
+ # Flusing output to rerun tempfile here...
30
+ @io.flush
31
+ @io.close
28
32
  end
29
33
 
30
- def feature_element(feature_element)
31
- @rerun = false
32
- super
33
- if @rerun
34
+ # feature_element() is never executed at all, either... ?
35
+ def after_feature_element(feature_element)
36
+ if feature_element.failed?
34
37
  file, line = *feature_element.file_colon_line.split(':')
35
38
  @file_colon_lines[file] << line
36
39
  @file_names << file