cucumber 0.1.13 → 0.1.14

Sign up to get free protection for your applications and to get access to all the features.
Files changed (81) hide show
  1. data/History.txt +17 -0
  2. data/Manifest.txt +3 -2
  3. data/README.txt +3 -2
  4. data/config/hoe.rb +1 -0
  5. data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +1 -1
  6. data/examples/cs/features/step_definitons/calculator_steps.rb +1 -1
  7. data/examples/i18n/Rakefile +18 -2
  8. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +2 -1
  9. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +2 -1
  10. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +2 -1
  11. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +2 -1
  12. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +2 -1
  13. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +2 -1
  14. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +2 -1
  15. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +2 -1
  16. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +2 -1
  17. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +2 -1
  18. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +2 -1
  19. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +2 -1
  20. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +2 -1
  21. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +2 -1
  22. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +2 -1
  23. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +2 -1
  24. data/examples/java/features/step_definitons/hello_steps.rb +1 -1
  25. data/examples/java/features/step_definitons/tree_steps.rb +1 -1
  26. data/examples/selenium/features/step_definitons/stories_steps.rb +1 -1
  27. data/examples/tickets/features/scenario_outline.feature +26 -0
  28. data/examples/tickets/features/step_definitons/scenario_outline_steps.rb +8 -0
  29. data/examples/tickets/features/step_definitons/tickets_steps.rb +1 -1
  30. data/examples/watir/README.textile +16 -0
  31. data/examples/watir/features/step_definitons/search_steps.rb +27 -0
  32. data/examples/watir/features/support/env.rb +32 -0
  33. data/gem_tasks/deployment.rake +0 -23
  34. data/gem_tasks/gemspec.rake +4 -0
  35. data/gem_tasks/rspec.rake +2 -2
  36. data/gem_tasks/treetop.rake +1 -1
  37. data/lib/autotest/cucumber_mixin.rb +1 -5
  38. data/lib/cucumber.rb +0 -21
  39. data/lib/cucumber/cli.rb +2 -1
  40. data/lib/cucumber/core_ext/string.rb +1 -1
  41. data/lib/cucumber/formatters/ansicolor.rb +8 -3
  42. data/lib/cucumber/formatters/pretty_formatter.rb +17 -8
  43. data/lib/cucumber/formatters/unicode.rb +5 -5
  44. data/lib/cucumber/platform.rb +28 -6
  45. data/lib/cucumber/rails/rspec.rb +1 -1
  46. data/lib/cucumber/rails/world.rb +1 -1
  47. data/lib/cucumber/rake/task.rb +3 -3
  48. data/lib/cucumber/treetop_parser/feature.treetop.erb +1 -0
  49. data/lib/cucumber/treetop_parser/feature_ar.rb +1 -0
  50. data/lib/cucumber/treetop_parser/feature_cy.rb +1 -0
  51. data/lib/cucumber/treetop_parser/feature_da.rb +1 -0
  52. data/lib/cucumber/treetop_parser/feature_de.rb +1 -0
  53. data/lib/cucumber/treetop_parser/feature_en-lol.rb +1 -0
  54. data/lib/cucumber/treetop_parser/feature_en-tx.rb +1 -0
  55. data/lib/cucumber/treetop_parser/feature_en.rb +1 -0
  56. data/lib/cucumber/treetop_parser/feature_es.rb +1 -0
  57. data/lib/cucumber/treetop_parser/feature_et.rb +1 -0
  58. data/lib/cucumber/treetop_parser/feature_fr.rb +1 -0
  59. data/lib/cucumber/treetop_parser/feature_id.rb +1 -0
  60. data/lib/cucumber/treetop_parser/feature_it.rb +1 -0
  61. data/lib/cucumber/treetop_parser/feature_ja.rb +1 -0
  62. data/lib/cucumber/treetop_parser/feature_lt.rb +1 -0
  63. data/lib/cucumber/treetop_parser/feature_nl.rb +1 -0
  64. data/lib/cucumber/treetop_parser/feature_no.rb +1 -0
  65. data/lib/cucumber/treetop_parser/feature_parser.rb +3 -1
  66. data/lib/cucumber/treetop_parser/feature_pl.rb +1 -0
  67. data/lib/cucumber/treetop_parser/feature_pt.rb +1 -0
  68. data/lib/cucumber/treetop_parser/feature_ro.rb +1 -0
  69. data/lib/cucumber/treetop_parser/feature_ro2.rb +1 -0
  70. data/lib/cucumber/treetop_parser/feature_ru.rb +1 -0
  71. data/lib/cucumber/treetop_parser/feature_se.rb +1 -0
  72. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1 -0
  73. data/lib/cucumber/version.rb +3 -2
  74. data/spec/cucumber/formatters/pretty_formatter_spec.rb +46 -2
  75. data/spec/cucumber/model/table_spec.rb +19 -5
  76. data/spec/cucumber/rails/stubs/mini_rails.rb +4 -3
  77. data/spec/cucumber/tree/step_outline_spec.rb +2 -2
  78. data/spec/spec_helper.rb +1 -1
  79. metadata +5 -4
  80. data/examples/java/src/cucumber/demo/Hello.java +0 -16
  81. data/examples/watir/features/step_definitons/stories_steps.rb +0 -51
@@ -122,10 +122,6 @@ module Autotest::CucumberMixin
122
122
  else
123
123
  scenario_args = scenarios_to_run.map { |s| "-s '#{s}'" }.join(' ')
124
124
  end
125
- return "#{$CUCUMBER_RUBY} #{cucumber} #{args} #{scenario_args}"
126
- end
127
-
128
- def cucumber
129
- File.file?("script/cucumber") ? "script/cucumber" : "cucumber"
125
+ return "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} #{args} #{scenario_args}"
130
126
  end
131
127
  end
@@ -17,24 +17,3 @@ require 'cucumber/cli'
17
17
  require 'cucumber/broadcaster'
18
18
  require 'cucumber/world'
19
19
  require 'cucumber/core_ext/exception'
20
-
21
- module Cucumber
22
- LANGUAGE_FILE = File.expand_path(File.dirname(__FILE__) + '/cucumber/languages.yml')
23
-
24
- class << self
25
- attr_reader :language
26
-
27
- def load_language(lang)
28
- @language = config[lang]
29
- end
30
-
31
- def languages
32
- config.keys.sort
33
- end
34
-
35
- def config
36
- require 'yaml'
37
- @config ||= YAML.load_file(LANGUAGE_FILE)
38
- end
39
- end
40
- end
@@ -1,5 +1,6 @@
1
1
  require 'optparse'
2
2
  require 'cucumber'
3
+ require 'ostruct'
3
4
 
4
5
  module Cucumber
5
6
  class YmlLoadError < StandardError; end
@@ -344,7 +345,7 @@ Defined profiles in cucumber.yml:
344
345
  def enable_diffing
345
346
  if defined?(::Spec)
346
347
  require 'spec/expectations/differs/default'
347
- options = ::Spec::Runner::Options.new(nil, nil)
348
+ options = OpenStruct.new(:diff_format => :unified, :context_lines => 3)
348
349
  ::Spec::Expectations.differ = ::Spec::Expectations::Differs::Default.new(options)
349
350
  end
350
351
  end
@@ -20,7 +20,7 @@ class String
20
20
  s
21
21
  end
22
22
 
23
- if ($CUCUMBER_JRUBY && $CUCUMBER_RAILS)
23
+ if (Cucumber::JRUBY && Cucumber::RAILS) || Cucumber::RUBY_1_9
24
24
  # Workaround for http://tinyurl.com/55uu3u
25
25
  alias jlength length
26
26
  else
@@ -5,7 +5,7 @@ gem 'term-ansicolor'
5
5
  $LOAD_PATH.each{|path| $LOAD_PATH.unshift($LOAD_PATH.delete(path)) if path =~ /term-ansicolor/}
6
6
  require 'term/ansicolor'
7
7
 
8
- if $CUCUMBER_WINDOWS_MRI
8
+ if Cucumber::WINDOWS_MRI
9
9
  begin
10
10
  require 'Win32/Console/ANSI'
11
11
  rescue LoadError
@@ -14,23 +14,26 @@ if $CUCUMBER_WINDOWS_MRI
14
14
  end
15
15
  end
16
16
 
17
- Term::ANSIColor.coloring = false if !STDOUT.tty? || ($CUCUMBER_WINDOWS && !$CUCUMBER_WINDOWS_MRI)
17
+ Term::ANSIColor.coloring = false if !STDOUT.tty? || (Cucumber::WINDOWS && !Cucumber::WINDOWS_MRI)
18
18
 
19
19
  module Cucumber
20
20
  module Formatters
21
21
  # Defines aliases for coloured output. You can tweak the colours by defining
22
- # a <tt>$CUCUMBER_COLORS</tt> variable in your shell, very much like you can
22
+ # a <tt>CUCUMBER_COLORS</tt> variable in your shell, very much like you can
23
23
  # tweak the familiar POSIX command <tt>ls</tt> with
24
24
  # <a href="http://mipsisrisc.com/rambling/2008/06/27/lscolorsls_colors-now-with-linux-support/">$LSCOLORS/$LS_COLORS</a>
25
25
  #
26
26
  # The colours that you can change are:
27
27
  #
28
+ # * <tt>missing</tt> - defaults to <tt>yellow</tt>
28
29
  # * <tt>pending</tt> - defaults to <tt>yellow</tt>
29
30
  # * <tt>pending_param</tt> - defaults to <tt>yellow,bold</tt>
30
31
  # * <tt>failed</tt> - defaults to <tt>red</tt>
31
32
  # * <tt>failed_param</tt> - defaults to <tt>red,bold</tt>
32
33
  # * <tt>passed</tt> - defaults to <tt>green</tt>
33
34
  # * <tt>passed_param</tt> - defaults to <tt>green,bold</tt>
35
+ # * <tt>outline</tt> - defaults to <tt>cyan</tt>
36
+ # * <tt>outline_param</tt> - defaults to <tt>cyan,bold</tt>
34
37
  # * <tt>skipped</tt> - defaults to <tt>cyan</tt>
35
38
  # * <tt>skipped_param</tt> - defaults to <tt>cyan,bold</tt>
36
39
  # * <tt>comment</tt> - defaults to <tt>grey</tt>
@@ -66,9 +69,11 @@ module Cucumber
66
69
  h[$1] + ',bold'
67
70
  end
68
71
  end.merge({
72
+ 'missing' => 'yellow',
69
73
  'pending' => 'yellow',
70
74
  'failed' => 'red',
71
75
  'passed' => 'green',
76
+ 'outline' => 'cyan',
72
77
  'skipped' => 'cyan',
73
78
  'comment' => 'grey',
74
79
  'tag' => 'blue'
@@ -19,6 +19,8 @@ module Cucumber
19
19
  @last_executed_was_row = false
20
20
  @pending_messages = {}
21
21
  @forced_pending_step_count = 0
22
+
23
+ @total_scenario_count = 0
22
24
  end
23
25
 
24
26
  def feature_executing(feature)
@@ -81,6 +83,7 @@ module Cucumber
81
83
  @io.puts
82
84
  output_failing_step(@failed.last)
83
85
  end
86
+ @total_scenario_count += 1
84
87
  end
85
88
 
86
89
  def step_passed(step, regexp, args)
@@ -100,14 +103,13 @@ module Cucumber
100
103
  end
101
104
 
102
105
  def step_failed(step, regexp, args)
106
+ @scenario_failed = true
103
107
  if step.row?
104
108
  args = step.visible_args if step.outline?
105
109
  @failed << step
106
- @scenario_failed = true
107
110
  print_failed_args(args)
108
111
  else
109
112
  @failed << step
110
- @scenario_failed = true
111
113
  @io.print failed(" #{step.keyword} #{step.format(regexp){|param| failed_param(param) << failed}}")
112
114
  if @options[:source]
113
115
  @io.print padding_spaces(step)
@@ -176,13 +178,16 @@ module Cucumber
176
178
 
177
179
  print_pending_messages if @pending_messages.any?
178
180
 
179
- @io.puts pending("#{@pending_scenarios.length} scenarios pending") if @pending_scenarios.any?
181
+ @io.puts dump_count(@total_scenario_count, "scenario")
182
+
183
+ @io.puts pending(dump_count(@pending_scenarios.length, "scenario", "pending")) if @pending_scenarios.any?
184
+
185
+ @io.puts passed(dump_count(@passed.length, "step", "passed")) if @passed.any?
186
+ @io.puts passed(dump_count(@failed.length, "step", "failed")) if @failed.any?
187
+ @io.puts passed(dump_count(@skipped.length, "step", "skipped")) if @skipped.any?
180
188
 
181
- @io.puts passed("#{@passed.length} steps passed") if @passed.any?
182
- @io.puts failed("#{@failed.length} steps failed") if @failed.any?
183
- @io.puts skipped("#{@skipped.length} steps skipped") if @skipped.any?
184
189
  if @pending_steps.any?
185
- @io.print pending("#{@pending_steps.length} steps pending")
190
+ @io.print pending(dump_count(@pending_steps.length, "step", "pending"))
186
191
  @io.print pending(" (#{number_of_unimplemented_steps} with no step definition)") if number_of_unimplemented_steps > 0
187
192
  @io.puts
188
193
  end
@@ -191,6 +196,10 @@ module Cucumber
191
196
 
192
197
  print_snippets if @options[:snippets]
193
198
  end
199
+
200
+ def dump_count(count, what, state=nil)
201
+ return [count, "#{what}#{count == 1 ? '' : 's'}", state].compact.join(" ")
202
+ end
194
203
 
195
204
  def print_pending_messages
196
205
  @io.puts "Pending Notes:"
@@ -199,7 +208,7 @@ module Cucumber
199
208
  end
200
209
  @io.puts
201
210
  end
202
-
211
+
203
212
  def print_snippets
204
213
  snippets = @pending_steps
205
214
  snippets.delete_if {|snippet| snippet.row? || @step_mother.has_step_definition?(snippet.name)}
@@ -2,25 +2,25 @@
2
2
  require 'cucumber/platform'
3
3
  require 'cucumber/formatters/ansicolor'
4
4
 
5
- $KCODE='u'
5
+ $KCODE='u' unless Cucumber::RUBY_1_9
6
6
 
7
- if $CUCUMBER_WINDOWS_MRI && `chcp` =~ /Active code page: (\d+)/
7
+ if Cucumber::WINDOWS_MRI && `chcp` =~ /Active code page: (\d+)/
8
8
  codepage = $1.to_i
9
9
  codepages = (1251..1252)
10
10
 
11
11
  if codepages.include?(codepage)
12
- $CUCUMBER_CODEPAGE = "cp#{codepage}"
12
+ Cucumber::CODEPAGE = "cp#{codepage}"
13
13
 
14
14
  require 'iconv'
15
15
  module Kernel
16
16
  alias cucumber_print print
17
17
  def print(*a)
18
- cucumber_print *Iconv.iconv($CUCUMBER_CODEPAGE, "UTF-8", *a)
18
+ cucumber_print *Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a)
19
19
  end
20
20
 
21
21
  alias cucumber_puts puts
22
22
  def puts(*a)
23
- cucumber_puts *Iconv.iconv($CUCUMBER_CODEPAGE, "UTF-8", *a)
23
+ cucumber_puts *Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a)
24
24
  end
25
25
  end
26
26
  end
@@ -2,9 +2,31 @@
2
2
  # in various places.
3
3
  require 'rbconfig'
4
4
 
5
- $CUCUMBER_JRUBY = defined?(JRUBY_VERSION)
6
- $CUCUMBER_IRONRUBY = Config::CONFIG['sitedir'] =~ /IronRuby/
7
- $CUCUMBER_WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
8
- $CUCUMBER_WINDOWS_MRI = $CUCUMBER_WINDOWS && !$CUCUMBER_JRUBY && !$CUCUMBER_IRONRUBY
9
- $CUCUMBER_RAILS = defined?(Rails)
10
- $CUCUMBER_RUBY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
5
+ module Cucumber
6
+ LANGUAGE_FILE = File.expand_path(File.dirname(__FILE__) + '/languages.yml')
7
+ BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
8
+ JRUBY = defined?(JRUBY_VERSION)
9
+ IRONRUBY = Config::CONFIG['sitedir'] =~ /IronRuby/
10
+ WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
11
+ WINDOWS_MRI = WINDOWS && !JRUBY && !IRONRUBY
12
+ RAILS = defined?(Rails)
13
+ RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
14
+ RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
15
+
16
+ class << self
17
+ attr_reader :language
18
+
19
+ def load_language(lang)
20
+ @language = config[lang]
21
+ end
22
+
23
+ def languages
24
+ config.keys.sort
25
+ end
26
+
27
+ def config
28
+ require 'yaml'
29
+ @config ||= YAML.load_file(LANGUAGE_FILE)
30
+ end
31
+ end
32
+ end
@@ -1,4 +1,4 @@
1
- require 'spec'
1
+ require 'spec/expectations'
2
2
  require 'spec/rails'
3
3
 
4
4
  # Hack to stop RSpec from dumping the summary
@@ -15,7 +15,7 @@ ActionController::Base.class_eval do
15
15
  perform_action_without_rescue
16
16
  end
17
17
  end
18
- Dispatcher.class_eval do
18
+ ActionController::Dispatcher.class_eval do
19
19
  def self.failsafe_response(output, status, exception = nil)
20
20
  raise exception
21
21
  end
@@ -1,3 +1,5 @@
1
+ require 'cucumber/platform'
2
+
1
3
  module Cucumber
2
4
  module Rake
3
5
  # Defines a task for running features.
@@ -5,7 +7,6 @@ module Cucumber
5
7
  LIB = File.expand_path(File.dirname(__FILE__) + '/../..')
6
8
 
7
9
  attr_accessor :libs
8
- attr_accessor :binary
9
10
  attr_accessor :step_list
10
11
  attr_accessor :step_pattern
11
12
  attr_accessor :feature_list
@@ -24,7 +25,6 @@ module Cucumber
24
25
 
25
26
  @feature_pattern = "features/**/*.feature" if feature_pattern.nil? && feature_list.nil?
26
27
  @step_pattern = "features/**/*.rb" if step_pattern.nil? && step_list.nil?
27
- @binary ||= File.expand_path(File.dirname(__FILE__) + '/../../../bin/cucumber')
28
28
  define_task
29
29
  end
30
30
 
@@ -37,7 +37,7 @@ module Cucumber
37
37
 
38
38
  def arguments_for_ruby_execution(task_args = nil)
39
39
  lib_args = ['"%s"' % ([LIB] + libs).join(File::PATH_SEPARATOR)]
40
- cucumber_bin = ['"%s"' % binary]
40
+ cucumber_bin = ['"%s"' % Cucumber::BINARY]
41
41
  cuc_opts = [(ENV['CUCUMBER_OPTS'] || cucumber_opts)]
42
42
 
43
43
  step_files(task_args).each do |step_file|
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -20,7 +20,9 @@ module Cucumber
20
20
  end
21
21
 
22
22
  def parse_feature(file)
23
- ast = parse(IO.read(file))
23
+ gherkin = IO.read(file)
24
+ gherkin = gherkin.force_encoding('utf-8') if Cucumber::RUBY_1_9
25
+ ast = parse(gherkin)
24
26
  if ast.nil?
25
27
  raise SyntaxError.new(file, self)
26
28
  else
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser
@@ -1,3 +1,4 @@
1
+ # encoding: utf-8
1
2
  module Cucumber
2
3
  # :stopdoc:
3
4
  module TreetopParser