aslakhellesoy-cucumber 0.1.99.21 → 0.1.99.22

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 (55) hide show
  1. data/History.txt +20 -7
  2. data/Manifest.txt +24 -1
  3. data/examples/i18n/Rakefile +3 -3
  4. data/examples/i18n/fr/features/addition.feature +13 -11
  5. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +10 -12
  6. data/examples/i18n/fr/lib/calculatrice.rb +1 -1
  7. data/examples/i18n/ja/features/addition.feature +10 -10
  8. data/examples/i18n/ja/features/division.feature +2 -2
  9. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +3 -3
  10. data/examples/i18n/ko/features/addition.feature +3 -3
  11. data/examples/i18n/ko/features/division.feature +3 -3
  12. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +2 -9
  13. data/examples/i18n/no/features/support/env.rb +6 -0
  14. data/examples/i18n/zh-TW/Rakefile +6 -0
  15. data/examples/i18n/zh-TW/features/addition.feature +16 -0
  16. data/examples/i18n/zh-TW/features/division.feature +10 -0
  17. data/examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb +24 -0
  18. data/examples/i18n/zh-TW/lib/calculator.rb +14 -0
  19. data/examples/self_test/features/step_definitions/sample_steps.rb +3 -1
  20. data/examples/sinatra/Rakefile +6 -0
  21. data/examples/sinatra/app.rb +14 -0
  22. data/examples/sinatra/features/add.feature +11 -0
  23. data/examples/sinatra/features/step_definitions/add_steps.rb +15 -0
  24. data/examples/sinatra/features/support/env.rb +20 -0
  25. data/examples/sinatra/views/add.erb +5 -0
  26. data/examples/sinatra/views/layout.erb +8 -0
  27. data/features/cucumber_cli.feature +7 -2
  28. data/features/step_definitions/cucumber_steps.rb +0 -1
  29. data/lib/autotest/cucumber_mixin.rb +3 -2
  30. data/lib/cucumber/ast/table.rb +23 -4
  31. data/lib/cucumber/ast/tags.rb +2 -2
  32. data/lib/cucumber/cli/configuration.rb +28 -11
  33. data/lib/cucumber/cli/language_help_formatter.rb +1 -1
  34. data/lib/cucumber/cli/main.rb +8 -1
  35. data/lib/cucumber/formatter/color_io.rb +6 -0
  36. data/lib/cucumber/languages.yml +37 -10
  37. data/lib/cucumber/parser/feature.rb +1 -1
  38. data/lib/cucumber/parser/feature.tt +1 -1
  39. data/lib/cucumber/rake/task.rb +39 -6
  40. data/lib/cucumber/step_definition.rb +7 -0
  41. data/lib/cucumber/step_mother.rb +12 -1
  42. data/lib/cucumber/version.rb +1 -1
  43. data/rails_generators/cucumber/cucumber_generator.rb +22 -3
  44. data/rails_generators/cucumber/templates/cucumber.rake +13 -5
  45. data/rails_generators/cucumber/templates/env.rb +2 -1
  46. data/rails_generators/cucumber/templates/paths.rb +18 -11
  47. data/rails_generators/cucumber/templates/webrat_steps.rb +23 -7
  48. data/spec/cucumber/ast/table_spec.rb +36 -9
  49. data/spec/cucumber/ast/tags_spec.rb +13 -1
  50. data/spec/cucumber/cli/configuration_spec.rb +33 -4
  51. data/spec/cucumber/cli/main_spec.rb +45 -6
  52. data/spec/cucumber/parser/feature_parser_spec.rb +2 -2
  53. data/spec/cucumber/step_definition_spec.rb +8 -0
  54. metadata +21 -4
  55. data/examples/i18n/ja/README.txt +0 -5
data/History.txt CHANGED
@@ -1,9 +1,9 @@
1
1
  == Git (0.2 alpha)
2
2
 
3
3
  This is a major rewrite of Cucumber's internals. The rewrite was done to address technical
4
- debt and to have a codebase that is easier to evolve and maintain. There are some major
5
- changes to the Gherkin language, so this release is not fully backwards compatible. You
6
- may have to edit your feature files a little. Most importantly, "GivenScenario" and
4
+ debt and to have a code base that is easier to evolve and maintain. There are some major
5
+ changes to the Gherkin language, so this release is not fully backwards compatible with the 0.1.x series.
6
+ You may have to edit your feature files a little. Most importantly, "GivenScenario" and
7
7
  "More Examples" no longer exist. See the "Removed features" section below for more details
8
8
  on how to use alternatives.
9
9
 
@@ -79,6 +79,8 @@ pure Ruby users have been enjoying for a while.
79
79
  ** Full jar and simple jar
80
80
 
81
81
  == Bugfixes
82
+ * Add support for using << in formatters to ensure the html formatter works (#210 Joseph Wilk)
83
+ * Explicitly require env.rb files first to avoid potential load order problems. (#213, Ben Mabey, Randy Harmon)
82
84
  * Depend on polyglot version (0.2.4) to avoid masking require errors. (Aslak Hellesøy).
83
85
  * -n option does not suppress the line info for a Scenario Outline (#175 Aslak Hellesøy)
84
86
  * Errors with rspec-rails matchers in cucumber 0.1.99 (#173 David Chelimsky)
@@ -92,6 +94,19 @@ pure Ruby users have been enjoying for a while.
92
94
  * Pending steps in > steps called from steps (#65 Aslak Hellesøy)
93
95
 
94
96
  === New features
97
+ * New -S/--step-definitions option. Useful (among other things) for tools that implement automcompletion. (#208 Aslak Hellesøy).
98
+ * The cucumber.rake file defines a dummy :features task if Cucumber is not installed (#225 Josh Nichols)
99
+ * Added map_column to AST tables to ease casting of cell values into relevant types (#223 Rob Holland)
100
+ Given /^an expense report for (.*) with the following posts:$/ do |date, posts_table|
101
+ posts_table.map_column!('amount') { |a| a.to_i }
102
+ posts_table.hashes.each do |post|
103
+ # post['amount'] is a Fixnum, rather than a String
104
+ end
105
+ end
106
+ Mapping a column which is not specified in the table will produce an error unless you explicitly pass a 2nd false argument. This is to allow different Scenarios to re-use the step definition with different table columns.
107
+ * New --no-diff option (#218 Bryan Ash)
108
+ * Rails generators supports testunit and rspec option, defaulting to rspec (#217 Josh Nichols)
109
+ * Sinatra Example (#204 Rob Holland)
95
110
  * Keywords can be aliased in languages.yml. See English for an example (examples: Examples|Scenarios)
96
111
  * Adding support for Background (#153 Joseph Wilk)
97
112
  * Added Česky/Czech (Vojtech Salbaba)
@@ -104,10 +119,7 @@ pure Ruby users have been enjoying for a while.
104
119
  * Call multiline steps from other steps (#144 Aslak Hellesøy)
105
120
  * Run cucumber with --autoformat DIR to reformat (pretty print) all of your feature files. (Aslak Hellesøy)
106
121
  * New --strict option exits with an error code if there are undefined steps. (#52 Aslak Hellesøy)
107
- * Given, When, Then are automatically aliased to current language.
108
- Ruby 1.8 doesn't allow non-ascii method names in the source, so unless you're on 1.9
109
- you will have to use Given, When, Then or set up your own aliases. Here is Norwegian:
110
- Cucumber.alias_steps(%w{Naar Saa}) # Når, Så already aliased, but can't be called. (Aslak Hellesøy)
122
+ * Given, When, Then methods (used in step definitions) are automatically aliased to current language. Use $KCODE='u' in env.rb if needed.
111
123
  * Run cucumber --language help to see all supported languages. (Aslak Hellesøy)
112
124
  * Run cucumber --language LANG help to see keywords for a given language. (Aslak Hellesøy)
113
125
  * Multiline arguments (tables and """ strings) are printed in the output. (Aslak Hellesøy)
@@ -118,6 +130,7 @@ pure Ruby users have been enjoying for a while.
118
130
  * "GivenScenario" is gone. Instead you can call Steps from Steps, or wait for "Background (#153)"
119
131
  * "More Examples" is gone. "Scenario" + "More Examples" is no longer supported. Use "Scenario Outline" + "Examples" instead.
120
132
  * Pure Ruby features are no longer supported.
133
+ * Remove --color option in autotest. Can be added manually in cucumber.yml (#215 Jean-Michel Garnier)
121
134
 
122
135
  == (0.16.4 aslakhellesoy-webrat gem on GitHub)
123
136
 
data/Manifest.txt CHANGED
@@ -61,7 +61,6 @@ examples/i18n/it/Rakefile
61
61
  examples/i18n/it/features/somma.feature
62
62
  examples/i18n/it/features/step_definitons/calcolatrice_steps.rb
63
63
  examples/i18n/it/lib/calcolatrice.rb
64
- examples/i18n/ja/README.txt
65
64
  examples/i18n/ja/Rakefile
66
65
  examples/i18n/ja/features/addition.feature
67
66
  examples/i18n/ja/features/division.feature
@@ -80,6 +79,7 @@ examples/i18n/lt/lib/calculator.rb
80
79
  examples/i18n/no/Rakefile
81
80
  examples/i18n/no/features/step_definitons/kalkulator_steps.rb
82
81
  examples/i18n/no/features/summering.feature
82
+ examples/i18n/no/features/support/env.rb
83
83
  examples/i18n/no/lib/kalkulator.rb
84
84
  examples/i18n/pt/Rakefile
85
85
  examples/i18n/pt/features/adicao.feature
@@ -89,6 +89,14 @@ examples/i18n/ro/Rakefile
89
89
  examples/i18n/ro/features/step_definitons/calculator_steps.rb
90
90
  examples/i18n/ro/features/suma.feature
91
91
  examples/i18n/ro/lib/calculator.rb
92
+ examples/i18n/ru/Rakefile
93
+ examples/i18n/ru/features/addition.feature
94
+ examples/i18n/ru/features/consecutive_calculations.feature
95
+ examples/i18n/ru/features/division.feature
96
+ examples/i18n/ru/features/step_definitons/calculator_steps.rb
97
+ examples/i18n/ru/features/support/env.rb
98
+ examples/i18n/ru/features/support/world.rb
99
+ examples/i18n/ru/lib/calculator.rb
92
100
  examples/i18n/se/Rakefile
93
101
  examples/i18n/se/features/step_definitons/kalkulator_steps.rb
94
102
  examples/i18n/se/features/summering.feature
@@ -97,6 +105,11 @@ examples/i18n/zh-CN/Rakefile
97
105
  examples/i18n/zh-CN/features/addition.feature
98
106
  examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb
99
107
  examples/i18n/zh-CN/lib/calculator.rb
108
+ examples/i18n/zh-TW/Rakefile
109
+ examples/i18n/zh-TW/features/addition.feature
110
+ examples/i18n/zh-TW/features/division.feature
111
+ examples/i18n/zh-TW/features/step_definitons/calculator_steps.rb
112
+ examples/i18n/zh-TW/lib/calculator.rb
100
113
  examples/java/README.textile
101
114
  examples/java/Rakefile
102
115
  examples/java/features/hello.feature
@@ -126,12 +139,20 @@ examples/self_test/features/background/pending_background.feature
126
139
  examples/self_test/features/background/scenario_outline_failing_background.feature
127
140
  examples/self_test/features/background/scenario_outline_passing_background.feature
128
141
  examples/self_test/features/call_undefined_step_from_step_def.feature
142
+ examples/self_test/features/failing_expectation.feature
129
143
  examples/self_test/features/lots_of_undefined.feature
130
144
  examples/self_test/features/outline_sample.feature
131
145
  examples/self_test/features/sample.feature
132
146
  examples/self_test/features/step_definitions/sample_steps.rb
133
147
  examples/self_test/features/support/env.rb
134
148
  examples/self_test/features/support/tag_count_formatter.rb
149
+ examples/sinatra/Rakefile
150
+ examples/sinatra/app.rb
151
+ examples/sinatra/features/add.feature
152
+ examples/sinatra/features/step_definitions/add_steps.rb
153
+ examples/sinatra/features/support/env.rb
154
+ examples/sinatra/views/add.erb
155
+ examples/sinatra/views/layout.erb
135
156
  examples/test_unit/Rakefile
136
157
  examples/test_unit/features/step_definitions/test_unit_steps.rb
137
158
  examples/test_unit/features/test_unit.feature
@@ -155,6 +176,7 @@ examples/watir/features/step_definitons/search_steps.rb
155
176
  examples/watir/features/support/env.rb
156
177
  features/background.feature
157
178
  features/cucumber_cli.feature
179
+ features/cucumber_cli_diff_disabled.feature
158
180
  features/cucumber_cli_outlines.feature
159
181
  features/custom_formatter.feature
160
182
  features/report_called_undefined_steps.feature
@@ -257,6 +279,7 @@ spec/cucumber/cli/main_spec.rb
257
279
  spec/cucumber/core_ext/proc_spec.rb
258
280
  spec/cucumber/core_ext/string_spec.rb
259
281
  spec/cucumber/formatter/ansicolor_spec.rb
282
+ spec/cucumber/formatter/color_io_spec.rb
260
283
  spec/cucumber/formatter/html/cucumber.css
261
284
  spec/cucumber/formatter/html/cucumber.js
262
285
  spec/cucumber/formatter/html/index.html
@@ -21,12 +21,12 @@ end
21
21
 
22
22
  def supported?(lang)
23
23
  if RUBY_VERSION =~ /^1\.9/
24
- !%w{ar ja ko zh-CN}.index(lang)
24
+ !%w{ar ko zh-CN}.index(lang)
25
25
  else
26
- !%w{ar ja ko}.index(lang)
26
+ !%w{ar ko}.index(lang)
27
27
  end
28
28
  end
29
29
 
30
30
  def rake(args)
31
31
  ruby($0, args) rescue nil
32
- end
32
+ end
@@ -1,15 +1,17 @@
1
1
  Fonctionnalité: Addition
2
- Afin de financer mon bonus avec l'argent des pigeons
3
- En tant que trader
4
- Je souhaite pouvoir additionner 2 chiffres
2
+ Afin de gagner du temps lors du calcul de la facture
3
+ En tant que commerçant
4
+ Je souhaite pouvoir faire une additionn
5
5
 
6
- Scénario esquisse: Addition de produits dérivés
7
- Etant donné que je tape 2
8
- Et que je tape 1
9
- Lorsque je tape additionner
10
- Alors le résultat doit être 3
6
+ Plan du Scénario: Addition de deux nombres
7
+ Soit une calculatrice
8
+ Et que j'entre <a> pour le premier nombre
9
+ Et que je tape sur la touche "+"
10
+ Et que j'entre <b> pour le second nombre
11
+ Lorsque je tape sur la touche "="
12
+ Alors le résultat affiché doit être <somme>
11
13
 
12
14
  Exemples:
13
- | a | b | sum |
14
- | 2 | 2 | 4 |
15
- | 2 | 3 | 5 |
15
+ | a | b | somme |
16
+ | 2 | 2 | 4 |
17
+ | 2 | 3 | 5 |
@@ -4,24 +4,22 @@ $:.unshift(File.dirname(__FILE__) + '/../../lib') # This line is not needed in y
4
4
  require 'cucumber/formatters/unicode'
5
5
  require 'calculatrice'
6
6
 
7
- Before do
8
- @calc = Calulatrice.new
7
+ Soit /^une calculatrice$/ do
8
+ @calc = Calculatrice.new
9
9
  end
10
10
 
11
- After do
11
+ Et /^que j'entre (\d+) pour le (.*) nombre/ do |n, x|
12
+ @calc.push n.to_i
12
13
  end
13
14
 
14
- # Etant donné que je tape ...
15
- Given /que je tape (\d+)/ do |n|
16
- @calc.push n.to_i
15
+ Lorsque /^je tape sur la touche "="$/ do
16
+ @expected_result = @calc.additionner
17
17
  end
18
18
 
19
- # Lorsque je tape additionner
20
- When 'je tape additionner' do
21
- @result = @calc.additionner
19
+ Alors /le résultat affiché doit être (\d*)/ do |result|
20
+ result.to_i.should == @expected_result
22
21
  end
23
22
 
24
- # Alors le résultat doit être ...
25
- Then /le résultat doit être (\d*)/ do |result|
26
- @result.should == result.to_i
23
+ Soit /^que je tape sur la touche "\+"$/ do
24
+ # noop
27
25
  end
@@ -1,4 +1,4 @@
1
- class Calulatrice
1
+ class Calculatrice
2
2
  def push(n)
3
3
  @args ||= []
4
4
  @args << n
@@ -3,14 +3,14 @@
3
3
  数学オンチとして
4
4
  2つの数の合計を知りたい
5
5
 
6
- シナリオ: 2つの数の加算について
7
- 前提 50 を入力
8
- かつ 70 を入力
9
- もし add ボタンを押した
10
- ならば 結果は 120 を表示
6
+ シナリオテンプレート: 2つの数の加算について
7
+ 前提 <値1> を入力
8
+ かつ <値2> を入力
9
+ もし <ボタン> を押した
10
+ ならば <結果> を表示
11
11
 
12
- 他のサンプル:
13
- | 入力1 | 入力2 | 実行 | 表示 |
14
- | 20 | 30 | add | 50 |
15
- | 2 | 5 | add | 7 |
16
- | 0 | 40 | add | 40 |
12
+ 例:
13
+ | 1 | 2 | ボタン | 結果 |
14
+ | 20 | 30 | add | 50 |
15
+ | 2 | 5 | add | 7 |
16
+ | 0 | 40 | add | 40 |
@@ -5,5 +5,5 @@
5
5
  シナリオ: ふつうの数値
6
6
  前提 3 を入力
7
7
  かつ 2 を入力
8
- もし divide ボタンを押した
9
- ならば 結果は 1.5 を表示
8
+ もし divide を押した
9
+ ならば 1.5 を表示
@@ -1,4 +1,4 @@
1
- # encoding: Shift_JIS
1
+ # encoding: UTF-8
2
2
  require 'spec/expectations'
3
3
  $:.unshift(File.dirname(__FILE__) + '/../../lib') # This line is not needed in your own project
4
4
  require 'cucumber/formatters/unicode'
@@ -15,10 +15,10 @@ Given "$n を入力" do |n|
15
15
  @calc.push n.to_i
16
16
  end
17
17
 
18
- When /(\w+) ボタンを押した/ do |op|
18
+ When /(\w+) を押した/ do |op|
19
19
  @result = @calc.send op
20
20
  end
21
21
 
22
- Then /結果は (.*) を表示/ do |result|
22
+ Then /(.*) を表示/ do |result|
23
23
  @result.should == result.to_f
24
24
  end
@@ -1,12 +1,12 @@
1
1
  기능: 덧셈
2
- 어이없는 실수을 방지하기 위해
2
+ 예기치못한 실수을 방지하기 위해
3
3
  수학을 잘 못하는 사람으로써
4
4
  두숫자의 합을 알고 싶다
5
5
 
6
- 예: 두 숫자를 더하기
6
+ 시나리오: 두 숫자를 더하기
7
7
  조건 계산기에 50을 입력했음
8
8
  그리고 계산기에 70을 입력했음
9
- 만일 내가 add를 누루면
9
+ 만일 내가 add를 누르면
10
10
  그러면 화면에 출력된 결과는 120이다
11
11
 
12
12
  다른 예:
@@ -1,10 +1,10 @@
1
1
  기능: 나눗셈
2
- 어이없는 실수을 방지하기 위해
2
+ 예기치못한 실수을 방지하기 위해
3
3
  분수를 계산 능력 요구한다
4
4
 
5
- 예: 보통 숫자
5
+ 시나리오: 보통 숫자
6
6
  조건 계산기에 3을 입력했음
7
7
  그리고 계산기에 2을 입력했음
8
- 만일 내가 divide를 누루면
8
+ 만일 내가 divide를 누르면
9
9
  그러면 화면에 출력된 결과는 1.5이다
10
10
 
@@ -1,11 +1,4 @@
1
1
  # encoding: utf-8
2
- require 'spec/expectations'
3
- $:.unshift(File.dirname(__FILE__) + '/../../lib') # This line is not needed in your own project
4
- require 'cucumber/formatters/unicode'
5
- require 'kalkulator'
6
-
7
- # Not necessary with Ruby 1.9 - Gitt, Når Så automatically aliased.
8
- Cucumber.alias_steps %w{Naar Saa}
9
2
 
10
3
  Before do
11
4
  @calc = Kalkulator.new
@@ -15,10 +8,10 @@ Gitt /at jeg har tastet inn (\d+)/ do |n|
15
8
  @calc.push n.to_i
16
9
  end
17
10
 
18
- Naar 'jeg summerer' do
11
+ Når 'jeg summerer' do
19
12
  @result = @calc.add
20
13
  end
21
14
 
22
- Saa /skal resultatet være (\d*)/ do |result|
15
+ /skal resultatet være (\d*)/ do |result|
23
16
  @result.should == result.to_i
24
17
  end
@@ -0,0 +1,6 @@
1
+ # encoding: utf-8
2
+ $KCODE='u' unless Cucumber::RUBY_1_9
3
+ require 'spec/expectations'
4
+ $:.unshift(File.dirname(__FILE__) + '/../../lib') # This line is not needed in your own project
5
+ require 'cucumber/formatters/unicode'
6
+ require 'kalkulator'
@@ -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 zh-TW"
6
+ end
@@ -0,0 +1,16 @@
1
+ 功能: 加法
2
+ 為了避免愚蠢的錯誤
3
+ 作為一個數學白痴
4
+ 我希望有人能告訴我兩個數相加的結果
5
+
6
+ 場景大綱: 將兩個數相加
7
+ 假設我已經在計算機上輸入 <數值_1>
8
+ 而且我已經在計算機上輸入 <數值_2>
9
+ 當我按下 <按鈕>
10
+ 那麼螢幕上應該顯示 <結果>
11
+
12
+ 例子:
13
+ | 數值_1 | 數值_2 | 按鈕 | 結果 |
14
+ | 20 | 30 | add | 50 |
15
+ | 2 | 5 | add | 7 |
16
+ | 0 | 40 | add | 40 |
@@ -0,0 +1,10 @@
1
+ 功能: 除法
2
+ 為了避免愚蠢的錯誤
3
+ 收銀機必須要能夠計算除法
4
+ 而且必需能顯示非整數的結果
5
+
6
+ 場景: 將兩個數相除
7
+ 假設我已經在計算機上輸入 3
8
+ 而且我已經在計算機上輸入 2
9
+ 當我按下 divide
10
+ 那麼螢幕上應該顯示 1.5
@@ -0,0 +1,24 @@
1
+ # encoding: utf-8
2
+ require 'spec/expectations'
3
+ $:.unshift(File.dirname(__FILE__) + '/../../lib') # This line is not needed in your own project
4
+ require 'cucumber/formatters/unicode'
5
+ require 'calculator'
6
+
7
+ Before do
8
+ @calc = Calculator.new
9
+ end
10
+
11
+ After do
12
+ end
13
+
14
+ Given /我已經在計算機上輸入 (\d+)/ do |n|
15
+ @calc.push n.to_i
16
+ end
17
+
18
+ When /我按下 (\w+)/ do |op|
19
+ @result = @calc.send op
20
+ end
21
+
22
+ Then /螢幕上應該顯示 (.*)/ do |result|
23
+ @result.should == result.to_f
24
+ 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
@@ -59,4 +59,6 @@ Then /^the multiline string should be$/ do |string|
59
59
  @multiline.should == string
60
60
  end
61
61
 
62
-
62
+ Given /^failing expectation$/ do
63
+ 'this'.should == 'that'
64
+ 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,14 @@
1
+ begin
2
+ require 'sinatra'
3
+ rescue LoadError
4
+ require 'rubygems'
5
+ require 'sinatra'
6
+ end
7
+
8
+ get '/add' do
9
+ erb :add
10
+ end
11
+
12
+ post '/add' do
13
+ "Answer: #{params[:first].to_i + params[:second].to_i}"
14
+ end
@@ -0,0 +1,11 @@
1
+ Feature: Addition
2
+ In order to avoid silly mistakes
3
+ As a math idiot
4
+ I want to be told the sum of two numbers
5
+
6
+ Scenario: Add two numbers
7
+ Given I visit the calculator page
8
+ And I fill in '50' for 'first'
9
+ And I fill in '70' for 'second'
10
+ When I press 'Add'
11
+ Then I should see 'Answer: 120'
@@ -0,0 +1,15 @@
1
+ Given /^I visit the calculator page$/ do
2
+ visit '/add'
3
+ end
4
+
5
+ Given /^I fill in '(.*)' for '(.*)'$/ do |value, field|
6
+ fill_in(field, :with => value)
7
+ end
8
+
9
+ When /^I press '(.*)'$/ do |name|
10
+ click_button(name)
11
+ end
12
+
13
+ Then /^I should see '(.*)'$/ do |text|
14
+ response.body.should =~ /#{text}/m
15
+ end
@@ -0,0 +1,20 @@
1
+ # Sinatra
2
+ require File.join(File.dirname(__FILE__), *%w[.. .. app])
3
+ # Force the application name because polyglot breaks the auto-detection logic.
4
+ Sinatra::Application.app_file = File.join(File.dirname(__FILE__), *%w[.. .. app.rb])
5
+
6
+ # RSpec
7
+ require 'spec/expectations'
8
+
9
+ # Webrat
10
+ require 'webrat'
11
+ Webrat.configure do |config|
12
+ config.mode = :sinatra
13
+ end
14
+
15
+ World do
16
+ include Webrat::Matchers
17
+ include Webrat::HaveTagMatcher
18
+
19
+ Webrat::SinatraSession.new
20
+ end
@@ -0,0 +1,5 @@
1
+ <form method='post' action='/add'>
2
+ <input name='first'/>
3
+ <input name='second'/>
4
+ <input type='submit' value='Add'/>
5
+ </form>
@@ -0,0 +1,8 @@
1
+ <html>
2
+ <head>
3
+ <title>Addition</title>
4
+ </head>
5
+ <body>
6
+ <%= yield %>
7
+ </body>
8
+ </html>
@@ -159,6 +159,11 @@ Feature: Cucumber command line
159
159
  Scenario: Call via another
160
160
  Given call step "a step definition that calls an undefined step"
161
161
 
162
+ Feature: Failing expectation
163
+
164
+ Scenario: Failing expectation
165
+ Given failing expectation
166
+
162
167
  Feature: Lots of undefined
163
168
 
164
169
  Scenario: Implement me
@@ -206,8 +211,8 @@ Feature: Cucumber command line
206
211
  hello
207
212
  \"\"\"
208
213
 
209
- 11 scenarios
210
- 11 skipped steps
214
+ 12 scenarios
215
+ 12 skipped steps
211
216
  7 undefined steps
212
217
 
213
218
  """
@@ -13,7 +13,6 @@ When /^I run cucumber (.*)$/ do |cmd|
13
13
  end
14
14
 
15
15
  Then /^it should (fail|pass) with$/ do |success, output|
16
- #puts @out
17
16
  @out.should == output
18
17
  if success == 'fail'
19
18
  @status.should_not == 0
@@ -95,7 +95,7 @@ module Autotest::CucumberMixin
95
95
  ensure
96
96
  $stdout.sync = old_sync
97
97
  end
98
- self.features_to_run = dirty_features_file.read
98
+ self.features_to_run = dirty_features_file.read.strip
99
99
  self.tainted = true unless self.features_to_run == []
100
100
  end
101
101
  hook :ran_features
@@ -115,7 +115,8 @@ module Autotest::CucumberMixin
115
115
  else
116
116
  args = %w{--format} << (features_to_run == :all ? "progress" : "pretty")
117
117
  end
118
- args += %w{--color --format rerun --out} << dirty_features_filename
118
+ # No --color option as some IDEs (Netbeans) don't output them very well (1 failed step)
119
+ args += %w{--format rerun --out} << dirty_features_filename
119
120
  args << (features_to_run == :all ? "features" : features_to_run)
120
121
  args = args.join(' ')
121
122
 
@@ -16,6 +16,7 @@ module Cucumber
16
16
  @raw = raw
17
17
  @cells_class = Cells
18
18
  @cell_class = Cell
19
+ @conversion_procs = Hash.new(lambda{|cell_value| cell_value})
19
20
  end
20
21
 
21
22
  def at_lines?(lines)
@@ -41,6 +42,8 @@ module Cucumber
41
42
  #
42
43
  # [{'a' => '2', 'b' => '3', 'sum' => '5'}, {'a' => '7', 'b' => '9', 'sum' => '16'}]
43
44
  #
45
+ # Use #map_column! to specify how values in a column are converted.
46
+ #
44
47
  def hashes
45
48
  @hashes ||= cells_rows[1..-1].map do |row|
46
49
  row.to_hash
@@ -75,10 +78,22 @@ module Cucumber
75
78
  [:table, *cells_rows.map{|row| row.to_sexp}]
76
79
  end
77
80
 
81
+ # Change how #hashes converts column values. The +column_name+ argument identifies the column
82
+ # and +conversion_proc+ performs the conversion for each cell in that column. If +strict+ is
83
+ # true, an error will be raised if the column named +column_name+ is not found. If +strict+
84
+ # is false, no error will be raised.
85
+ def map_column!(column_name, strict=true, &conversion_proc)
86
+ verify_column(column_name) if strict
87
+ @conversion_procs[column_name] = conversion_proc
88
+ end
89
+
78
90
  def to_hash(cells) #:nodoc:
79
- hash = {}
80
- @raw[0].each_with_index do |key, n|
81
- hash[key] = cells.value(n)
91
+ hash = Hash.new do |hash, key|
92
+ hash[key.to_s] if key.is_a?(Symbol)
93
+ end
94
+ @raw[0].each_with_index do |column_name, column_index|
95
+ value = @conversion_procs[column_name].call(cells.value(column_index))
96
+ hash[column_name] = value
82
97
  end
83
98
  hash
84
99
  end
@@ -87,12 +102,16 @@ module Cucumber
87
102
  cells_rows.index(cells)
88
103
  end
89
104
 
105
+ def verify_column(column_name)
106
+ raise %{The column named "#{column_name}" does not exist} unless @raw[0].include?(column_name)
107
+ end
108
+
90
109
  def arguments_replaced(arguments) #:nodoc:
91
110
  raw_with_replaced_args = raw.map do |row|
92
111
  row.map do |cell|
93
112
  cell_with_replaced_args = cell
94
113
  arguments.each do |name, value|
95
- cell_with_replaced_args = cell_with_replaced_args.gsub(name, value)
114
+ cell_with_replaced_args = value ? cell_with_replaced_args.gsub(name, value) : nil
96
115
  end
97
116
  cell_with_replaced_args
98
117
  end