cucumber 0.1.9 → 0.1.10

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 (44) hide show
  1. data/History.txt +31 -1
  2. data/Manifest.txt +15 -0
  3. data/bin/cucumber +2 -1
  4. data/config/hoe.rb +2 -1
  5. data/examples/calculator_ruby_features/features/addition.rb +1 -1
  6. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -0
  7. data/examples/i18n/de/Rakefile +6 -0
  8. data/examples/i18n/de/features/addition.feature +17 -0
  9. data/examples/i18n/de/features/division.feature +10 -0
  10. data/examples/i18n/de/features/step_definitons/calculator_steps.rb +30 -0
  11. data/examples/i18n/de/lib/calculator.rb +14 -0
  12. data/examples/i18n/en/Rakefile +1 -0
  13. data/examples/i18n/lt/Rakefile +6 -0
  14. data/examples/i18n/lt/features/addition.feature +17 -0
  15. data/examples/i18n/lt/features/division.feature +10 -0
  16. data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +31 -0
  17. data/examples/i18n/lt/lib/calculator.rb +14 -0
  18. data/examples/test_unit/Rakefile +6 -0
  19. data/examples/test_unit/features/step_definitions/test_unit_steps.rb +26 -0
  20. data/examples/test_unit/features/test_unit.feature +9 -0
  21. data/examples/tickets/features/tickets.feature +4 -2
  22. data/lib/autotest/discover.rb +1 -1
  23. data/lib/cucumber.rb +3 -3
  24. data/lib/cucumber/cli.rb +16 -6
  25. data/lib/cucumber/core_ext/proc.rb +31 -16
  26. data/lib/cucumber/executor.rb +35 -15
  27. data/lib/cucumber/formatters/ansicolor.rb +11 -13
  28. data/lib/cucumber/languages.yml +13 -1
  29. data/lib/cucumber/platform.rb +12 -0
  30. data/lib/cucumber/step_mother.rb +7 -1
  31. data/lib/cucumber/tree/feature.rb +3 -1
  32. data/lib/cucumber/tree/scenario.rb +17 -1
  33. data/lib/cucumber/treetop_parser/feature_de.rb +8 -8
  34. data/lib/cucumber/treetop_parser/feature_lt.rb +1591 -0
  35. data/lib/cucumber/version.rb +1 -1
  36. data/rails_generators/cucumber/templates/webrat_steps.rb +49 -0
  37. data/rails_generators/feature/templates/feature.erb +3 -3
  38. data/spec/cucumber/cli_spec.rb +33 -1
  39. data/spec/cucumber/executor_spec.rb +104 -28
  40. data/spec/cucumber/step_mother_spec.rb +7 -7
  41. data/spec/cucumber/tree/feature_spec.rb +31 -0
  42. data/spec/cucumber/tree/row_scenario_spec.rb +30 -0
  43. data/spec/spec_helper.rb +1 -0
  44. metadata +22 -7
@@ -1,4 +1,34 @@
1
- == 0.1.9
1
+ == 0.1.10 2008-11-25
2
+
3
+ This release mostly has smaller bugfixes. The most significant new feature is how
4
+ line numbers are specified. You can now run multiple features at specific lines numbers like this:
5
+
6
+ cucumber foo.feature:15 bar.feature:6:45:111
7
+
8
+ This will run foo.feature at line 15 and bar.feature at line 6, 45 and 111.
9
+
10
+ === New features
11
+ * Added example showing how to use Cucumber with Test::Unit + Matchy instead of RSpec (Aslak Hellesøy)
12
+ * Yield existing world object to World block (#87 Aslak Hellesøy)
13
+ * AUTOFEATURE=tRue works (case insensitive) (Aslak Hellesøy)
14
+ * Initial support for .NET via IronRuby. (Aslak Hellesøy)
15
+ * Lithuanian translation (sauliusgrigaitis)
16
+ * New webrat step defintions to wrap the new selects_time, selects_date, and selects_datetime methods. (Ben Mabey)
17
+ * Try to load webrat gem if it's not installed as a plugin (Aslak Hellesøy)
18
+ * Support example.feature:20 or example.feature:10:20:30 syntax for running features at specific line number(s). (#88 Joseph Wilk)
19
+
20
+ === Bugfixes
21
+ * Windows - all the 'a' characters in the output have gone on strike (#81 Luis Lavena, Joseph Wilk, Aslak Hellesøy)
22
+ * Raise a nice error when encountering step definition without block (#95 Aslak Hellesøy)
23
+ * Features written using Ruby where breaking due to missing a line number (#91 Joseph Wilk)
24
+ * Directly creating a Table meant the scenario table header was never set which was causing a formatter error (#91 Joseph Wilk)
25
+
26
+ === Removed features
27
+ * $KCODE='u' is no longer done automatically. Developers should do that explicitly when needed in step definitions or env.rb.
28
+ * Step definition without a block being treated as pending (#64 Joseph Wilk)
29
+ * The --line option has been removed. Use the new file.feature:line format instead.
30
+
31
+ == 0.1.9 2008-11-12
2
32
 
3
33
  With this release Cucumber supports 19 (!) natural languages:
4
34
 
@@ -30,6 +30,11 @@ examples/i18n/da/Rakefile
30
30
  examples/i18n/da/features/step_definitons/kalkulator_steps.rb
31
31
  examples/i18n/da/features/summering.feature
32
32
  examples/i18n/da/lib/kalkulator.rb
33
+ examples/i18n/de/Rakefile
34
+ examples/i18n/de/features/addition.feature
35
+ examples/i18n/de/features/division.feature
36
+ examples/i18n/de/features/step_definitons/calculator_steps.rb
37
+ examples/i18n/de/lib/calculator.rb
33
38
  examples/i18n/en/Rakefile
34
39
  examples/i18n/en/features/addition.feature
35
40
  examples/i18n/en/features/division.feature
@@ -62,6 +67,11 @@ examples/i18n/ja/features/addition.feature
62
67
  examples/i18n/ja/features/division.feature
63
68
  examples/i18n/ja/features/step_definitons/calculator_steps.rb
64
69
  examples/i18n/ja/lib/calculator.rb
70
+ examples/i18n/lt/Rakefile
71
+ examples/i18n/lt/features/addition.feature
72
+ examples/i18n/lt/features/division.feature
73
+ examples/i18n/lt/features/step_definitons/calculator_steps.rb
74
+ examples/i18n/lt/lib/calculator.rb
65
75
  examples/i18n/no/Rakefile
66
76
  examples/i18n/no/features/step_definitons/kalkulator_steps.rb
67
77
  examples/i18n/no/features/summering.feature
@@ -92,6 +102,9 @@ examples/java/src/cucumber/demo/Hello.java
92
102
  examples/selenium/Rakefile
93
103
  examples/selenium/features/search.feature
94
104
  examples/selenium/features/step_definitons/stories_steps.rb
105
+ examples/test_unit/Rakefile
106
+ examples/test_unit/features/step_definitions/test_unit_steps.rb
107
+ examples/test_unit/features/test_unit.feature
95
108
  examples/tickets/Rakefile
96
109
  examples/tickets/cucumber.yml
97
110
  examples/tickets/features/step_definitons/tickets_steps.rb
@@ -134,6 +147,7 @@ lib/cucumber/formatters/progress_formatter.rb
134
147
  lib/cucumber/languages.yml
135
148
  lib/cucumber/model.rb
136
149
  lib/cucumber/model/table.rb
150
+ lib/cucumber/platform.rb
137
151
  lib/cucumber/rails/rspec.rb
138
152
  lib/cucumber/rails/world.rb
139
153
  lib/cucumber/rake/task.rb
@@ -160,6 +174,7 @@ lib/cucumber/treetop_parser/feature_fr.rb
160
174
  lib/cucumber/treetop_parser/feature_id.rb
161
175
  lib/cucumber/treetop_parser/feature_it.rb
162
176
  lib/cucumber/treetop_parser/feature_ja.rb
177
+ lib/cucumber/treetop_parser/feature_lt.rb
163
178
  lib/cucumber/treetop_parser/feature_nl.rb
164
179
  lib/cucumber/treetop_parser/feature_no.rb
165
180
  lib/cucumber/treetop_parser/feature_parser.rb
@@ -1,5 +1,6 @@
1
1
  #!/usr/bin/env ruby
2
+ # Add '.rb' to work around a bug in IronRuby's File#dirname
3
+ $:.unshift(File.dirname(__FILE__ + '.rb') + '/../lib') unless $:.include?(File.dirname(__FILE__ + '.rb') + '/../lib')
2
4
 
3
- $:.unshift(File.dirname(__FILE__) + '/../lib') unless $:.include?(File.dirname(__FILE__) + '/../lib')
4
5
  require 'cucumber/cli'
5
6
  Cucumber::CLI.execute
@@ -57,7 +57,8 @@ $hoe = Hoe.new(GEM_NAME, VERS) do |p|
57
57
  # == Optional
58
58
  p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
59
59
  #p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
60
- p.extra_deps = [ ['term-ansicolor', '>= 1.0.3'], ['treetop', '>= 1.2.4'], ['rspec', '>= 1.1.5'], ['diff-lcs', '>= 1.1.2'] ]
60
+ p.extra_deps = [ ['term-ansicolor', '>= 1.0.3'], ['treetop', '>= 1.2.4'], ['diff-lcs', '>= 1.1.2'] ]
61
+ p.extra_dev_deps = [ ['rspec', '>= 1.1.11'] ]
61
62
 
62
63
  #p.spec_extras = {} # A hash of extra values to set in the gemspec.
63
64
 
@@ -10,7 +10,7 @@ Feature %|Addition
10
10
  And "I have entered 70 into the calculator"
11
11
  When "I add"
12
12
  Then "the result should be 120 on the screen"
13
- And "the result class should be Float"
13
+ And "the result class should be Fixnum"
14
14
  end
15
15
 
16
16
  Table do |t|
@@ -1,3 +1,4 @@
1
+ $KCODE='u'
1
2
  require 'spec'
2
3
  $:.unshift(File.dirname(__FILE__) + '/../../lib')
3
4
  require 'calculator'
@@ -0,0 +1,6 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new do |t|
5
+ t.cucumber_opts = "--language de"
6
+ end
@@ -0,0 +1,17 @@
1
+ Funktionalität: Addition
2
+ Um dumme Fehler zu vermeiden
3
+ möchte ich als Matheidiot
4
+ die Summe zweier Zahlen gesagt bekommen
5
+
6
+ Szenario: Zwei Zahlen hinzufügen
7
+ Gegeben sei ich habe 50 in den Taschenrechner eingegeben
8
+ Und ich habe 70 in den Taschenrechner eingegeben
9
+ Wenn ich add drücke
10
+ Dann sollte das Ergebniss auf dem Bildschirm 120 sein
11
+ Und die Ergebnissklasse sollte eine Fixnum sein
12
+
13
+ Mehr Beispiele:
14
+ | Eingabe_1 | Eingabe_2 | Knopf | Ausgabe | Klasse |
15
+ | 20 | 30 | add | 50 | Fixnum |
16
+ | 2 | 5 | add | 7 | Fixnum |
17
+ | 0 | 40 | add | 40 | Fixnum |
@@ -0,0 +1,10 @@
1
+ Funktionalität: Division
2
+ Um dumme Fehler zu vermeiden
3
+ müssen Kassierer in der Lage sein einen Bruchteil zu berechnen
4
+
5
+ Szenario: Normale Zahlen
6
+ Gegeben sei ich habe 3 in den Taschenrechner eingegeben
7
+ Und ich habe 2 in den Taschenrechner eingegeben
8
+ Wenn ich divide drücke
9
+ Dann sollte das Ergebniss auf dem Bildschirm 1.5 sein
10
+ Und die Ergebnissklasse sollte eine Float sein
@@ -0,0 +1,30 @@
1
+ require 'spec'
2
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
3
+ require 'calculator'
4
+
5
+ Before do
6
+ @calc = Calculator.new
7
+ end
8
+
9
+ After do
10
+ end
11
+
12
+ Given "ich habe $n in den Taschenrechner eingegeben" do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When /ich (\w+) drücke/ do |op|
17
+ @result = @calc.send op
18
+ end
19
+
20
+ Then /sollte das Ergebniss auf dem Bildschirm (.*) sein/ do |result|
21
+ @result.should == result.to_f
22
+ end
23
+
24
+ Then /die Ergebnissklasse sollte eine (\w*) sein/ do |class_name|
25
+ @result.class.name.should == class_name
26
+ end
27
+
28
+ Given /it should rain on (\w+)/ do |day|
29
+ @calc.rain?(day).should == true
30
+ end
@@ -0,0 +1,14 @@
1
+ class Calculator
2
+ def push(n)
3
+ @args ||= []
4
+ @args << n
5
+ end
6
+
7
+ def add
8
+ @args.inject(0){|n,sum| sum+=n}
9
+ end
10
+
11
+ def divide
12
+ @args[0].to_f / @args[1].to_f
13
+ end
14
+ end
@@ -2,4 +2,5 @@ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
2
2
  require 'cucumber/rake/task'
3
3
 
4
4
  Cucumber::Rake::Task.new do |t|
5
+ t.cucumber_opts = "--language en"
5
6
  end
@@ -0,0 +1,6 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../../../lib')
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new do |t|
5
+ t.cucumber_opts = "--language lt"
6
+ end
@@ -0,0 +1,17 @@
1
+ Sąvybė: Sudėtis
2
+ Norint išvengti kvailų klaidų
3
+ Kaip matematinis idiotas
4
+ Aš noriu, kad man pasakytų dviejų skaičių sumą
5
+
6
+ Scenarijus: dviejų skaičių sudėtis
7
+ Duota aš įvedžiau 50 į skaičiuotuvą
8
+ Ir aš įvedžiau 70 į skaičiuotuvą
9
+ Kai aš paspaudžiu "add"
10
+ Tada rezultatas ekrane turi būti 120
11
+ Ir rezultato klasė turi būti "Fixnum"
12
+
13
+ Daugiau pavyzdžių
14
+ | įvestis_1 | įvestis_2 | mygtukas | išvestis | klasė |
15
+ | 20 | 30 | add | 50 | Fixnum |
16
+ | 2 | 5 | add | 7 | Fixnum |
17
+ | 0 | 40 | add | 40 | Fixnum |
@@ -0,0 +1,10 @@
1
+ Feature: Dalyba
2
+ Norint išvengti klaidų
3
+ Kasininkai privalo mokėti skaičiuoti trupmenas
4
+
5
+ Scenarijus: Realieji skaičiai
6
+ Duota aš įvedžiau 3 į skaičiuotuvą
7
+ Ir aš įvedžiau 2 į skaičiuotuvą
8
+ Kai aš paspaudžiu "divide"
9
+ Tada rezultatas ekrane turi būti 1.5
10
+ Ir rezultato klasė turi būti "Float"
@@ -0,0 +1,31 @@
1
+ require 'spec'
2
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
3
+ require 'calculator'
4
+
5
+ Before do
6
+ @calc = Calculator.new
7
+ end
8
+
9
+ After do
10
+ end
11
+
12
+ Given "aš įvedžiau $n į skaičiuotuvą" do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When /aš paspaudžiu "(\w+)"/ do |op|
17
+ @result = @calc.send op
18
+ end
19
+
20
+ Then /rezultatas ekrane turi būti (.*)/ do |result|
21
+ @result.should == result.to_f
22
+ end
23
+
24
+ Then /rezultato klasė turi būti "(\w*)"/ do |class_name|
25
+ @result.class.name.should == class_name
26
+ end
27
+
28
+ Given /turi lyti (\w+)/ do |day|
29
+ @calc.rain?(day).should == true
30
+ end
31
+
@@ -0,0 +1,14 @@
1
+ class Calculator
2
+ def push(n)
3
+ @args ||= []
4
+ @args << n
5
+ end
6
+
7
+ def add
8
+ @args.inject(0){|n,sum| sum+=n}
9
+ end
10
+
11
+ def divide
12
+ @args[0].to_f / @args[1].to_f
13
+ end
14
+ end
@@ -0,0 +1,6 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new do |t|
5
+ t.cucumber_opts = "--format pretty"
6
+ end
@@ -0,0 +1,26 @@
1
+ require 'test/unit/assertions'
2
+ World do |o|
3
+ o.extend(Test::Unit::Assertions)
4
+ o
5
+ end
6
+
7
+ Given /^(\w+) = (\w+)$/ do |var, value|
8
+ instance_variable_set("@#{var}", value)
9
+ end
10
+
11
+ begin
12
+ require 'rubygems'
13
+ require 'matchy'
14
+ Then /^I can assert that (\w+) == (\w+)$/ do |var_a, var_b|
15
+ a = instance_variable_get("@#{var_a}")
16
+ b = instance_variable_get("@#{var_b}")
17
+ a.should == b
18
+ end
19
+ rescue LoadError
20
+ STDERR.puts "***** You should install matchy *****"
21
+ Then /^I can assert that (\w+) == (\w+)$/ do |var_a, var_b|
22
+ a = instance_variable_get("@#{var_a}")
23
+ b = instance_variable_get("@#{var_b}")
24
+ assert_equal(a, b)
25
+ end
26
+ end
@@ -0,0 +1,9 @@
1
+ Feature: Test::Unit
2
+ In order to please people who like Test::Unit
3
+ As a Cucumber user
4
+ I want to be able to use assert* in my step definitions
5
+
6
+ Scenario: assert_equal
7
+ Given x = 5
8
+ And y = 5
9
+ Then I can assert that x == y
@@ -17,6 +17,8 @@ Feature: Cucumber
17
17
  Then I should be working in London
18
18
  And I should be born in Oslo
19
19
  And I shoule see a multiline string like
20
- "A string
20
+ """
21
+ A string
21
22
  that spans
22
- several lines"
23
+ several lines
24
+ """
@@ -1,6 +1,6 @@
1
1
  Autotest.add_discovery do
2
2
  if File.directory?('features')
3
- if ENV['AUTOFEATURE'] == 'true'
3
+ if ENV['AUTOFEATURE'] =~ /true/i
4
4
  "cucumber"
5
5
  else
6
6
  puts "(Not running features. To run features in autotest, set AUTOFEATURE=true.)"
@@ -1,5 +1,8 @@
1
1
  $:.unshift(File.dirname(__FILE__)) unless
2
2
  $:.include?(File.dirname(__FILE__)) || $:.include?(File.expand_path(File.dirname(__FILE__)))
3
+
4
+ require 'jcode'
5
+ require 'cucumber/platform'
3
6
  require 'rubygems'
4
7
  require 'treetop/runtime'
5
8
  require 'treetop/ruby_extensions'
@@ -14,9 +17,6 @@ require 'cucumber/treetop_parser/feature_parser'
14
17
  require 'cucumber/cli'
15
18
  require 'cucumber/broadcaster'
16
19
 
17
- $KCODE='u'
18
- require 'jcode'
19
-
20
20
  module Cucumber
21
21
  LANGUAGE_FILE = File.expand_path(File.dirname(__FILE__) + '/cucumber/languages.yml')
22
22
 
@@ -22,7 +22,7 @@ module Cucumber
22
22
  end
23
23
  end
24
24
 
25
- attr_reader :options
25
+ attr_reader :options, :paths
26
26
  FORMATS = %w{pretty profile progress html autotest}
27
27
  DEFAULT_FORMAT = 'pretty'
28
28
 
@@ -56,9 +56,6 @@ module Cucumber
56
56
  @options[:require] ||= []
57
57
  @options[:require] << v
58
58
  end
59
- opts.on("-l LINE", "--line LINE", "Only execute the scenario at the given line") do |v|
60
- @options[:line] = v
61
- end
62
59
  opts.on("-s SCENARIO", "--scenario SCENARIO", "Only execute the scenario with the given name.",
63
60
  "If this option is given more than once, run all",
64
61
  "the specified scenarios.") do |v|
@@ -130,8 +127,9 @@ module Cucumber
130
127
  if @options[:formats].empty?
131
128
  @options[:formats][DEFAULT_FORMAT] = [@out_stream]
132
129
  end
133
-
130
+
134
131
  # Whatever is left after option parsing is the FILE arguments
132
+ args = extract_and_store_line_numbers(args)
135
133
  @paths += args
136
134
  end
137
135
 
@@ -164,7 +162,7 @@ Defined profiles in cucumber.yml:
164
162
  executor.formatters = build_formatter_broadcaster(step_mother)
165
163
  require_files
166
164
  load_plain_text_features(features)
167
- executor.line = @options[:line].to_i if @options[:line]
165
+ executor.lines_for_features = @options[:lines_for_features]
168
166
  executor.scenario_names = @options[:scenario_names] if @options[:scenario_names]
169
167
  executor.visit_features(features)
170
168
  exit 1 if executor.failed
@@ -172,6 +170,18 @@ Defined profiles in cucumber.yml:
172
170
 
173
171
  private
174
172
 
173
+ def extract_and_store_line_numbers(file_arguments)
174
+ @options[:lines_for_features] = Hash.new{|k,v| k[v] = []}
175
+ file_arguments.map do |arg|
176
+ _, file, lines = */^([\w\W]*?):([\d:]+)$/.match(arg)
177
+ unless file.nil?
178
+ @options[:lines_for_features][file] += lines.split(':').map { |line| line.to_i }
179
+ arg = file
180
+ end
181
+ arg
182
+ end
183
+ end
184
+
175
185
  # Requires files - typically step files and ruby feature files.
176
186
  def require_files
177
187
  ARGV.clear # Shut up RSpec
@@ -6,6 +6,37 @@ module Cucumber
6
6
  # Proc extension that allows a proc to be called in the context of any object.
7
7
  # Also makes it possible to tack a name onto a Proc.
8
8
  module CallIn
9
+ PROC_PATTERN = /[\d\w]+@(.*):(.*)>/
10
+
11
+ if Proc.new{}.to_s =~ PROC_PATTERN
12
+ def to_backtrace_line
13
+ "#{file_colon_line}:in `#{name}'"
14
+ end
15
+
16
+ def to_comment_line
17
+ "# #{file_colon_line}"
18
+ end
19
+
20
+ def file_colon_line
21
+ path, line = *to_s.match(PROC_PATTERN)[1..2]
22
+ path = File.expand_path(path)
23
+ pwd = Dir.pwd
24
+ path = path[pwd.length+1..-1]
25
+ "#{path}:#{line}"
26
+ end
27
+ else
28
+ # This Ruby implementation doesn't implement Proc#to_s correctly
29
+ STDERR.puts "*** THIS RUBY IMPLEMENTATION DOESN'T REPORT FILE AND LINE FOR PROCS ***"
30
+
31
+ def to_backtrace_line
32
+ nil
33
+ end
34
+
35
+ def to_comment_line
36
+ ""
37
+ end
38
+ end
39
+
9
40
  attr_accessor :name
10
41
 
11
42
  def call_in(obj, *args)
@@ -22,22 +53,6 @@ module Cucumber
22
53
  arity == -1 ? 0 : arity
23
54
  end
24
55
 
25
- def to_backtrace_line
26
- "#{file_colon_line}:in `#{name}'"
27
- end
28
-
29
- def to_comment_line
30
- "# #{file_colon_line}"
31
- end
32
-
33
- def file_colon_line
34
- path, line = *to_s.match(/[\d\w]+@(.*):(.*)>/)[1..2]
35
- path = File.expand_path(path)
36
- pwd = Dir.pwd
37
- path = path[pwd.length+1..-1]
38
- "#{path}:#{line}"
39
- end
40
-
41
56
  def meth
42
57
  @meth ||= "__cucumber_#{object_id}"
43
58
  end