cucumber 0.3.104 → 0.4.0.rc1

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 +50 -3
  2. data/Manifest.txt +20 -2
  3. data/Rakefile +4 -0
  4. data/config/hoe.rb +20 -14
  5. data/examples/i18n/tr/Rakefile +6 -0
  6. data/examples/i18n/tr/features/bo/314/210lme.feature +10 -0
  7. data/examples/i18n/tr/features/step_definitons/hesap_makinesi_ad/304/261mlar/304/261.rb +24 -0
  8. data/examples/i18n/tr/features/toplama.feature +18 -0
  9. data/examples/i18n/tr/lib/hesap_makinesi.rb +15 -0
  10. data/examples/python/features/step_definitions/fib_steps.py +9 -1
  11. data/examples/ruby2python/features/fibonacci.feature +19 -0
  12. data/examples/{python → ruby2python}/features/step_definitions/fib_steps.rb +0 -0
  13. data/examples/ruby2python/features/support/env.rb +21 -0
  14. data/examples/ruby2python/lib/fib.py +7 -0
  15. data/features/bug_475.feature +43 -0
  16. data/features/exception_in_before_block.feature +34 -1
  17. data/features/html_formatter.feature +1 -1
  18. data/features/language_help.feature +68 -0
  19. data/features/rake_task.feature +34 -60
  20. data/features/simplest.feature +11 -0
  21. data/features/step_definitions/simplest_steps.rb +6 -0
  22. data/features/support/env.rb +1 -1
  23. data/features/support/env.rb.simplest +7 -0
  24. data/features/table_diffing.feature +1 -1
  25. data/features/table_mapping.feature +35 -0
  26. data/features/transform.feature +133 -2
  27. data/features/usage_and_stepdefs_formatter.feature +4 -2
  28. data/gem_tasks/contributors.rake +2 -1
  29. data/lib/cucumber/ast/background.rb +17 -5
  30. data/lib/cucumber/ast/outline_table.rb +8 -1
  31. data/lib/cucumber/ast/scenario.rb +2 -1
  32. data/lib/cucumber/ast/step.rb +6 -1
  33. data/lib/cucumber/ast/step_invocation.rb +14 -1
  34. data/lib/cucumber/ast/table.rb +30 -6
  35. data/lib/cucumber/cli/configuration.rb +1 -1
  36. data/lib/cucumber/cli/language_help_formatter.rb +27 -14
  37. data/lib/cucumber/cli/options.rb +2 -1
  38. data/lib/cucumber/cli/profile_loader.rb +12 -4
  39. data/lib/cucumber/core_ext/instance_exec.rb +29 -25
  40. data/lib/cucumber/formatter/junit.rb +50 -45
  41. data/lib/cucumber/formatter/pdf.rb +16 -4
  42. data/lib/cucumber/formatter/usage.rb +2 -14
  43. data/lib/cucumber/language_support/language_methods.rb +23 -3
  44. data/lib/cucumber/languages.yml +14 -0
  45. data/lib/cucumber/parser/natural_language.rb +1 -1
  46. data/lib/cucumber/parser/table.rb +10 -7
  47. data/lib/cucumber/parser/table.tt +1 -1
  48. data/lib/cucumber/platform.rb +1 -0
  49. data/lib/cucumber/py_support/py_dsl.py +10 -8
  50. data/lib/cucumber/py_support/py_language.py +8 -0
  51. data/lib/cucumber/py_support/py_language.rb +24 -11
  52. data/lib/cucumber/rails/action_controller.rb +6 -1
  53. data/lib/cucumber/rails/active_record.rb +5 -4
  54. data/lib/cucumber/rake/task.rb +7 -82
  55. data/lib/cucumber/rb_support/rb_language.rb +0 -4
  56. data/lib/cucumber/rb_support/rb_step_definition.rb +4 -6
  57. data/lib/cucumber/rb_support/rb_transform.rb +9 -7
  58. data/lib/cucumber/step_definition_light.rb +20 -0
  59. data/lib/cucumber/step_match.rb +1 -1
  60. data/lib/cucumber/step_mother.rb +5 -1
  61. data/lib/cucumber/version.rb +3 -3
  62. data/lib/cucumber/webrat/element_locator.rb +2 -0
  63. data/rails_generators/cucumber/cucumber_generator.rb +8 -9
  64. data/rails_generators/cucumber/templates/cucumber +14 -6
  65. data/rails_generators/cucumber/templates/cucumber.rake +9 -1
  66. data/rails_generators/cucumber/templates/cucumber_environment.rb +5 -1
  67. data/rails_generators/cucumber/templates/env.rb +29 -14
  68. data/rails_generators/cucumber/templates/paths.rb +1 -1
  69. data/rails_generators/cucumber/templates/spork_env.rb +39 -17
  70. data/rails_generators/cucumber/templates/version_check.rb +29 -0
  71. data/rails_generators/cucumber/templates/webrat_steps.rb +5 -0
  72. data/spec/cucumber/ast/outline_table_spec.rb +21 -0
  73. data/spec/cucumber/ast/table_spec.rb +18 -0
  74. data/spec/cucumber/formatter/html_spec.rb +33 -69
  75. data/spec/cucumber/formatter/junit_spec.rb +73 -0
  76. data/spec/cucumber/formatter/spec_helper.rb +50 -0
  77. data/spec/cucumber/parser/table_parser_spec.rb +2 -2
  78. data/spec/cucumber/rb_support/rb_step_definition_spec.rb +10 -1
  79. data/spec/cucumber/step_mother_spec.rb +6 -0
  80. metadata +32 -8
  81. data/examples/python/features/support/env.rb +0 -21
@@ -4,4 +4,4 @@ Feature: HTML formatter
4
4
 
5
5
  Scenario: Everything in examples/self_test
6
6
  When I run cucumber -q --format html --out tmp/a.html features
7
- Then "examples/self_test/tmp/a.html" should have the same contents as "features/html_formatter/a.html"
7
+ Then "examples/self_test/tmp/a.html" should have the same contents as "features/html_formatter/a.html"
@@ -0,0 +1,68 @@
1
+ Feature: Language help
2
+ In order to figure out the keywords to use for a language
3
+ I want to be able to get help on the language from the CLI
4
+
5
+ Scenario: Get help for Portuguese language
6
+ When I run cucumber -l pt help
7
+ Then it should pass with
8
+ """
9
+ | name | 'Portuguese' |
10
+ | native | 'português' |
11
+ | encoding | 'UTF-8' |
12
+ | space_after_keyword | 'true' |
13
+ | feature | 'Funcionalidade' |
14
+ | background | 'Contexto' |
15
+ | scenario | 'Cenário' / 'Cenario' |
16
+ | scenario_outline | 'Esquema do Cenário' / 'Esquema do Cenario' |
17
+ | examples | 'Exemplos' |
18
+ | given | 'Dado' |
19
+ | when | 'Quando' |
20
+ | then | 'Então' / 'Entao' |
21
+ | and | 'E' |
22
+ | but | 'Mas' |
23
+
24
+ """
25
+ Scenario: List languages
26
+ When I run cucumber -l help
27
+ Then it should pass with
28
+ """
29
+ | ar | Arabic | العربية |
30
+ | bg | Bulgarian | български |
31
+ | cat | Catalan | català |
32
+ | cy | Welsh | Cymraeg |
33
+ | cz | Czech | Česky |
34
+ | da | Danish | dansk |
35
+ | de | German | Deutsch |
36
+ | en | English | English |
37
+ | en-au | Australian | Australian |
38
+ | en-lol | LOLCAT | LOLCAT |
39
+ | en-tx | Texan | Texan |
40
+ | es | Spanish | español |
41
+ | et | Estonian | eesti keel |
42
+ | fi | Finnish | suomi |
43
+ | fr | French | français |
44
+ | he | Hebrew | עברית |
45
+ | hr | Croatian | hrvatski |
46
+ | hu | Hungarian | magyar |
47
+ | id | Indonesian | Bahasa Indonesia |
48
+ | it | Italian | italiano |
49
+ | ja | Japanese | 日本語 |
50
+ | ko | Korean | 한국어 |
51
+ | lt | Lithuanian | lietuvių kalba |
52
+ | lv | Latvian | latviešu |
53
+ | nl | Dutch | Nederlands |
54
+ | no | Norwegian | norsk |
55
+ | pl | Polish | polski |
56
+ | pt | Portuguese | português |
57
+ | ro | Romanian | română |
58
+ | ro2 | Romanian (diacritical) | română (diacritical) |
59
+ | ru | Russian | русский |
60
+ | se | Swedish | Svenska |
61
+ | sk | Slovak | Slovensky |
62
+ | tr | Turkish | Türkçe |
63
+ | uz | Uzbek | Узбекча |
64
+ | vi | Vietnamese | Tiếng Việt |
65
+ | zh-CN | Chinese simplified | 简体中文 |
66
+ | zh-TW | Chinese traditional | 繁體中文 |
67
+
68
+ """
@@ -27,11 +27,11 @@ Feature: Rake task
27
27
  $LOAD_PATH.unshift(CUCUMBER_LIB)
28
28
  require 'cucumber/rake/task'
29
29
 
30
- Cucumber::Rake::Task.new(:features) do |t|
30
+ Cucumber::Rake::Task.new do |t|
31
31
  t.profile = "foo"
32
32
  end
33
33
  """
34
- When I run rake features
34
+ When I run rake cucumber
35
35
  Then it should pass
36
36
  And the output should contain
37
37
  """
@@ -44,6 +44,32 @@ Feature: Rake task
44
44
  1 step (1 undefined)
45
45
  """
46
46
 
47
+ Scenario: rake task without a profile
48
+ Given a file named "Rakefile" with:
49
+ """
50
+ $LOAD_PATH.unshift(CUCUMBER_LIB)
51
+ require 'cucumber/rake/task'
52
+
53
+ Cucumber::Rake::Task.new do |t|
54
+ t.cucumber_opts = %w{--quiet --no-color}
55
+ end
56
+ """
57
+ When I run rake cucumber
58
+ Then it should pass
59
+ And the output should contain
60
+ """
61
+ Feature: Sample
62
+
63
+ Scenario: Wanted
64
+ Given I want to run this
65
+
66
+ Scenario: Unwanted
67
+ Given I don't want this ran
68
+
69
+ 2 scenarios (2 undefined)
70
+ 2 steps (2 undefined)
71
+ """
72
+
47
73
  Scenario: rake task with a defined profile and cucumber_opts
48
74
  Given the following profile is defined:
49
75
  """
@@ -54,12 +80,12 @@ Feature: Rake task
54
80
  $LOAD_PATH.unshift(CUCUMBER_LIB)
55
81
  require 'cucumber/rake/task'
56
82
 
57
- Cucumber::Rake::Task.new(:features) do |t|
83
+ Cucumber::Rake::Task.new do |t|
58
84
  t.profile = "bar"
59
85
  t.cucumber_opts = %w{--quiet --no-color}
60
86
  end
61
87
  """
62
- When I run rake features
88
+ When I run rake cucumber
63
89
  Then it should pass
64
90
  And the output should contain
65
91
  """
@@ -72,58 +98,6 @@ Feature: Rake task
72
98
  1 step (1 undefined)
73
99
  """
74
100
 
75
- Scenario: rake task with a defined profile and feature list
76
- Given a file named "features/the_one_i_want_to_run.feature" with:
77
- """
78
- Feature: Desired
79
-
80
- Scenario: Something
81
- Given this is missing
82
- """
83
- Given the following profile is defined:
84
- """
85
- baz: ['--quiet', '--no-color']
86
- """
87
- And a file named "Rakefile" with:
88
- """
89
- $LOAD_PATH.unshift(CUCUMBER_LIB)
90
- require 'cucumber/rake/task'
91
-
92
- Cucumber::Rake::Task.new(:features) do |t|
93
- t.profile = "baz"
94
- t.feature_list = ['features/the_one_i_want_to_run.feature']
95
- end
96
- """
97
- When I run rake features
98
- Then it should pass
99
- And the output should contain
100
- """
101
- Feature: Desired
102
-
103
- Scenario: Something
104
- Given this is missing
105
-
106
- 1 scenario (1 undefined)
107
- 1 step (1 undefined)
108
- """
109
-
110
- Scenario: deprecation warnings
111
- Given a file named "Rakefile" with:
112
- """
113
- $LOAD_PATH.unshift(CUCUMBER_LIB)
114
- require 'cucumber/rake/task'
115
-
116
- Cucumber::Rake::Task.new(:features) do |t|
117
- t.feature_list = ['features/missing_step_definitions.feature']
118
- end
119
- """
120
- When I run rake features
121
- Then it should pass
122
- And STDERR should match
123
- """
124
- Cucumber::Rake::Task#feature_list is deprecated and will be removed in 0.4.0. Please use profiles for complex settings: http://wiki.github.com/aslakhellesoy/cucumber/using-rake#profiles
125
- """
126
-
127
101
  Scenario: respect requires
128
102
  Given a file named "features/support/env.rb"
129
103
  And a file named "features/support/dont_require_me.rb"
@@ -136,13 +110,13 @@ Feature: Rake task
136
110
  $LOAD_PATH.unshift(CUCUMBER_LIB)
137
111
  require 'cucumber/rake/task'
138
112
 
139
- Cucumber::Rake::Task.new(:features) do |t|
113
+ Cucumber::Rake::Task.new do |t|
140
114
  t.profile = "no_bomb"
141
115
  t.cucumber_opts = %w{--quiet --no-color}
142
116
  end
143
117
  """
144
118
 
145
- When I run rake features
119
+ When I run rake cucumber
146
120
  Then it should pass
147
121
  And the output should not contain
148
122
  """
@@ -162,11 +136,11 @@ Feature: Rake task
162
136
  $LOAD_PATH.unshift(CUCUMBER_LIB)
163
137
  require 'cucumber/rake/task'
164
138
 
165
- Cucumber::Rake::Task.new(:features) do |t|
139
+ Cucumber::Rake::Task.new do |t|
166
140
  t.cucumber_opts = %w{--quiet --no-color}
167
141
  end
168
142
  """
169
- When I run rake features
143
+ When I run rake cucumber
170
144
  Then it should pass
171
145
  And the output should contain
172
146
  """
@@ -0,0 +1,11 @@
1
+ Feature: Sample
2
+
3
+ Background:
4
+ Given this step works
5
+
6
+ Scenario: Run a good step
7
+ Given this step works
8
+
9
+
10
+
11
+
@@ -0,0 +1,6 @@
1
+ require 'rubygems'
2
+ require 'ruby-debug'
3
+
4
+ Given /^this step works$/ do
5
+ end
6
+
@@ -107,7 +107,7 @@ class CucumberWorld
107
107
  exec cmd
108
108
  end
109
109
  end
110
- sleep 0.2
110
+ sleep 1.0
111
111
  end
112
112
 
113
113
  def terminate_background_jobs
@@ -0,0 +1,7 @@
1
+ require 'rubygems'
2
+
3
+ class SomeException < Exception; end
4
+
5
+ Before do
6
+ raise SomeException.new("I cannot even start this scenario")
7
+ end
@@ -32,7 +32,7 @@ Feature: Table diffing
32
32
  | x | y |
33
33
  | a | b |
34
34
  | a | c |
35
- Tables were not identical (RuntimeError)
35
+ Tables were not identical (Cucumber::Ast::Table::Different)
36
36
  ./features/step_definitions/table_steps.rb:2:in `/the table should be:/'
37
37
  features/tables.feature:3:in `Then the table should be:'
38
38
 
@@ -0,0 +1,35 @@
1
+ Feature: Table mapping
2
+ Scenario: Mapping table shouldn't change output
3
+ Given a standard Cucumber project directory structure
4
+ And a file named "features/f.feature" with:
5
+ """
6
+ Feature: F
7
+ Scenario: S
8
+ Given a table:
9
+ | who |
10
+ | aslak |
11
+ """
12
+ And a file named "features/step_definitions/steps.rb" with:
13
+ """
14
+ Given /a table:/ do |table|
15
+ table.map_headers!(/who/i => 'Who')
16
+ table.map_column!('Who') { |who| "Cuke" }
17
+ table.hashes[0]['Who'] = "Joe"
18
+ table.hashes.should == [{"Who"=>"Joe"}]
19
+ end
20
+ """
21
+ When I run cucumber features/f.feature
22
+ Then STDERR should be empty
23
+ And it should pass with
24
+ """
25
+ Feature: F
26
+
27
+ Scenario: S # features/f.feature:2
28
+ Given a table: # features/step_definitions/steps.rb:1
29
+ | who |
30
+ | aslak |
31
+
32
+ 1 scenario (1 passed)
33
+ 1 step (1 passed)
34
+
35
+ """
@@ -23,6 +23,10 @@ Feature: transform
23
23
  array.should be_kind_of(Array)
24
24
  end
25
25
 
26
+ Then /^I should transform ('\w+' to Nil)$/ do |string|
27
+ string.should be_nil
28
+ end
29
+
26
30
  Then /^I should not transform ('\d+') to an Integer$/ do |string|
27
31
  string.should be_kind_of(String)
28
32
  end
@@ -37,6 +41,8 @@ Feature: transform
37
41
  Float.induced_from Transform("'#{integer_string}' to an Integer")
38
42
  end
39
43
 
44
+ Transform(/^('\w+') to Nil$/) {|str| nil }
45
+
40
46
  Transform(/^('\w+') to a Symbol$/) {|str| str.to_sym }
41
47
 
42
48
  module MyHelpers
@@ -71,6 +77,9 @@ Feature: transform
71
77
  Scenario: transform with matches that use current world
72
78
  Then I should transform 'abc' to an Array
73
79
 
80
+ Scenario: transform with matches that return nil
81
+ Then I should transform 'nil' to Nil
82
+
74
83
  Scenario: transform without matches
75
84
  Then I should not transform '10' to an Integer
76
85
  """
@@ -91,10 +100,132 @@ Feature: transform
91
100
  Scenario: transform with matches that use current world
92
101
  Then I should transform 'abc' to an Array
93
102
 
103
+ Scenario: transform with matches that return nil
104
+ Then I should transform 'nil' to Nil
105
+
94
106
  Scenario: transform without matches
95
107
  Then I should not transform '10' to an Integer
96
108
 
97
- 5 scenarios (5 passed)
98
- 5 steps (5 passed)
109
+ 6 scenarios (6 passed)
110
+ 6 steps (6 passed)
99
111
 
100
112
  """
113
+
114
+ Scenario: run a table scenario with an unrelated registered transform
115
+ Given a file named "features/transform_sample.feature" with:
116
+ """
117
+ Feature: Step argument transformations
118
+
119
+ Scenario: A table
120
+ Then I should check the following table:
121
+ | letter | letter_plus_a |
122
+ | r | ra |
123
+ | m | ma |
124
+ | p | pa |
125
+ """
126
+ And a file named "features/support/table.rb" with:
127
+ """
128
+ Transform /^table:number,number_plus_a$/ do |table|
129
+ :not_what_you_were_expecting
130
+ end
131
+
132
+ Then "I should check the following table:" do |table|
133
+ table.hashes.each do |hash|
134
+ hash['letter_plus_a'].should == (hash['letter'] + 'a')
135
+ end
136
+ end
137
+ """
138
+ When I run cucumber -s features
139
+ Then it should pass with
140
+ """
141
+ Feature: Step argument transformations
142
+
143
+ Scenario: A table
144
+ Then I should check the following table:
145
+ | letter | letter_plus_a |
146
+ | r | ra |
147
+ | m | ma |
148
+ | p | pa |
149
+
150
+ 1 scenario (1 passed)
151
+ 1 step (1 passed)
152
+
153
+ """
154
+
155
+ Scenario: run a table scenario with an related registered transform not using table
156
+ Given a file named "features/transform_sample.feature" with:
157
+ """
158
+ Feature: Step argument transformations
159
+
160
+ Scenario: A table
161
+ Then I should check the following table:
162
+ | letter | letter_plus_a |
163
+ | r | ra |
164
+ | m | ma |
165
+ | p | pa |
166
+ """
167
+ And a file named "features/support/table.rb" with:
168
+ """
169
+ Transform /^table:letter,letter_plus_a$/ do |table|
170
+ 1
171
+ end
172
+
173
+ Then "I should check the following table:" do |columns|
174
+ columns.should == 1
175
+ end
176
+ """
177
+ When I run cucumber -s features
178
+ Then it should pass with
179
+ """
180
+ Feature: Step argument transformations
181
+
182
+ Scenario: A table
183
+ Then I should check the following table:
184
+ | letter | letter_plus_a |
185
+ | r | ra |
186
+ | m | ma |
187
+ | p | pa |
188
+
189
+ 1 scenario (1 passed)
190
+ 1 step (1 passed)
191
+
192
+ """
193
+
194
+ Scenario: run a table scenario with an related registered transform using table
195
+ Given a file named "features/transform_sample.feature" with:
196
+ """
197
+ Feature: Step argument transformations
198
+
199
+ Scenario: A table
200
+ Then I should check the following table:
201
+ | letter | letter_plus_a |
202
+ | r | ra |
203
+ | m | ma |
204
+ | p | pa |
205
+ """
206
+ And a file named "features/support/table.rb" with:
207
+ """
208
+ Transform /^table:letter,letter_plus_a$/ do |table|
209
+ table.rows.map { |row| row.join(',') }
210
+ end
211
+
212
+ Then "I should check the following table:" do |rows_in_table|
213
+ rows_in_table.should == ['r,ra','m,ma','p,pa']
214
+ end
215
+ """
216
+ When I run cucumber -b -s features
217
+ Then it should pass with
218
+ """
219
+ Feature: Step argument transformations
220
+
221
+ Scenario: A table
222
+ Then I should check the following table:
223
+ | letter | letter_plus_a |
224
+ | r | ra |
225
+ | m | ma |
226
+ | p | pa |
227
+
228
+ 1 scenario (1 passed)
229
+ 1 step (1 passed)
230
+
231
+ """