aslakhellesoy-cucumber 0.1.5 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (227) hide show
  1. data/History.txt +228 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +226 -0
  4. data/README.txt +41 -0
  5. data/Rakefile +9 -0
  6. data/TODO.txt +26 -0
  7. data/bin/cucumber +5 -0
  8. data/config/hoe.rb +69 -0
  9. data/config/requirements.rb +15 -0
  10. data/cucumber.yml +1 -0
  11. data/examples/calculator_ruby_features/Rakefile +6 -0
  12. data/examples/calculator_ruby_features/features/addition.rb +23 -0
  13. data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +43 -0
  14. data/examples/cs/README.textile +22 -0
  15. data/examples/cs/Rakefile +12 -0
  16. data/examples/cs/features/hello.feature +11 -0
  17. data/examples/cs/features/step_definitons/hello_steps.rb +25 -0
  18. data/examples/cs/features/step_definitons/tree_steps.rb +14 -0
  19. data/examples/cs/features/tree.feature +9 -0
  20. data/examples/cs/src/Hello.cs +18 -0
  21. data/examples/dos_line_endings/Rakefile +6 -0
  22. data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
  23. data/examples/i18n/README.textile +18 -0
  24. data/examples/i18n/Rakefile +16 -0
  25. data/examples/i18n/ar/Rakefile +6 -0
  26. data/examples/i18n/ar/features/addition.feature +17 -0
  27. data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +31 -0
  28. data/examples/i18n/ar/lib/calculator.rb +10 -0
  29. data/examples/i18n/da/Rakefile +6 -0
  30. data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +22 -0
  31. data/examples/i18n/da/features/summering.feature +17 -0
  32. data/examples/i18n/da/lib/kalkulator.rb +11 -0
  33. data/examples/i18n/en/Rakefile +5 -0
  34. data/examples/i18n/en/features/addition.feature +17 -0
  35. data/examples/i18n/en/features/division.feature +10 -0
  36. data/examples/i18n/en/features/step_definitons/calculator_steps.rb +31 -0
  37. data/examples/i18n/en/lib/calculator.rb +14 -0
  38. data/examples/i18n/es/Rakefile +6 -0
  39. data/examples/i18n/es/features/adicion.feature +17 -0
  40. data/examples/i18n/es/features/step_definitons/calculador_steps.rb +22 -0
  41. data/examples/i18n/es/lib/calculador.rb +11 -0
  42. data/examples/i18n/et/Rakefile +6 -0
  43. data/examples/i18n/et/features/liitmine.feature +17 -0
  44. data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +26 -0
  45. data/examples/i18n/et/lib/kalkulaator.rb +10 -0
  46. data/examples/i18n/fr/Rakefile +6 -0
  47. data/examples/i18n/fr/features/addition.feature +13 -0
  48. data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +22 -0
  49. data/examples/i18n/fr/lib/calculatrice.rb +10 -0
  50. data/examples/i18n/id/Rakefile +6 -0
  51. data/examples/i18n/id/features/addition.feature +17 -0
  52. data/examples/i18n/id/features/division.feature +10 -0
  53. data/examples/i18n/id/features/step_definitons/calculator_steps.rb +31 -0
  54. data/examples/i18n/id/lib/calculator.rb +14 -0
  55. data/examples/i18n/it/Rakefile +6 -0
  56. data/examples/i18n/it/features/somma.feature +10 -0
  57. data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +22 -0
  58. data/examples/i18n/it/lib/calcolatrice.rb +11 -0
  59. data/examples/i18n/ja/README.txt +5 -0
  60. data/examples/i18n/ja/Rakefile +6 -0
  61. data/examples/i18n/ja/features/addition.feature +17 -0
  62. data/examples/i18n/ja/features/division.feature +10 -0
  63. data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +30 -0
  64. data/examples/i18n/ja/lib/calculator.rb +14 -0
  65. data/examples/i18n/no/Rakefile +6 -0
  66. data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +22 -0
  67. data/examples/i18n/no/features/summering.feature +17 -0
  68. data/examples/i18n/no/lib/kalkulator.rb +11 -0
  69. data/examples/i18n/pt/Rakefile +6 -0
  70. data/examples/i18n/pt/features/adicao.feature +10 -0
  71. data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +22 -0
  72. data/examples/i18n/pt/lib/calculadora.rb +10 -0
  73. data/examples/i18n/ro/Rakefile +6 -0
  74. data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +22 -0
  75. data/examples/i18n/ro/features/suma.feature +10 -0
  76. data/examples/i18n/ro/lib/calculator.rb +11 -0
  77. data/examples/i18n/se/Rakefile +6 -0
  78. data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +22 -0
  79. data/examples/i18n/se/features/summering.feature +17 -0
  80. data/examples/i18n/se/lib/kalkulator.rb +11 -0
  81. data/examples/i18n/zh-CN/Rakefile +6 -0
  82. data/examples/i18n/zh-CN/features/addition.feature +17 -0
  83. data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +24 -0
  84. data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
  85. data/examples/java/README.textile +22 -0
  86. data/examples/java/Rakefile +12 -0
  87. data/examples/java/features/hello.feature +11 -0
  88. data/examples/java/features/step_definitons/hello_steps.rb +25 -0
  89. data/examples/java/features/step_definitons/tree_steps.rb +14 -0
  90. data/examples/java/features/tree.feature +9 -0
  91. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  92. data/examples/selenium/Rakefile +6 -0
  93. data/examples/selenium/features/search.feature +9 -0
  94. data/examples/selenium/features/step_definitons/stories_steps.rb +41 -0
  95. data/examples/tickets/Rakefile +11 -0
  96. data/examples/tickets/cucumber.yml +2 -0
  97. data/examples/tickets/features/step_definitons/tickets_steps.rb +32 -0
  98. data/examples/tickets/features/tickets.feature +22 -0
  99. data/examples/watir/Rakefile +6 -0
  100. data/examples/watir/features/search.feature +9 -0
  101. data/examples/watir/features/step_definitons/stories_steps.rb +51 -0
  102. data/features/see_features.feature +8 -0
  103. data/features/steps/features_steps.rb +9 -0
  104. data/gem_tasks/deployment.rake +34 -0
  105. data/gem_tasks/environment.rake +7 -0
  106. data/gem_tasks/features.rake +6 -0
  107. data/gem_tasks/fix_cr_lf.rake +10 -0
  108. data/gem_tasks/flog.rake +4 -0
  109. data/gem_tasks/gemspec.rake +6 -0
  110. data/gem_tasks/rspec.rake +21 -0
  111. data/gem_tasks/treetop.rake +41 -0
  112. data/lib/autotest/cucumber.rb +6 -0
  113. data/lib/autotest/cucumber_mixin.rb +109 -0
  114. data/lib/autotest/cucumber_rails.rb +6 -0
  115. data/lib/autotest/cucumber_rails_rspec.rb +6 -0
  116. data/lib/autotest/cucumber_rspec.rb +6 -0
  117. data/lib/autotest/discover.rb +9 -0
  118. data/lib/cucumber.rb +39 -0
  119. data/lib/cucumber/broadcaster.rb +20 -0
  120. data/lib/cucumber/cli.rb +269 -0
  121. data/lib/cucumber/core_ext/proc.rb +54 -0
  122. data/lib/cucumber/core_ext/string.rb +22 -0
  123. data/lib/cucumber/executor.rb +170 -0
  124. data/lib/cucumber/formatters.rb +1 -0
  125. data/lib/cucumber/formatters/ansicolor.rb +111 -0
  126. data/lib/cucumber/formatters/autotest_formatter.rb +23 -0
  127. data/lib/cucumber/formatters/cucumber.css +132 -0
  128. data/lib/cucumber/formatters/cucumber.js +11 -0
  129. data/lib/cucumber/formatters/html_formatter.rb +128 -0
  130. data/lib/cucumber/formatters/jquery.js +32 -0
  131. data/lib/cucumber/formatters/pretty_formatter.rb +234 -0
  132. data/lib/cucumber/formatters/profile_formatter.rb +92 -0
  133. data/lib/cucumber/formatters/progress_formatter.rb +58 -0
  134. data/lib/cucumber/languages.yml +235 -0
  135. data/lib/cucumber/model.rb +1 -0
  136. data/lib/cucumber/model/table.rb +28 -0
  137. data/lib/cucumber/rails/rspec.rb +12 -0
  138. data/lib/cucumber/rails/world.rb +73 -0
  139. data/lib/cucumber/rake/task.rb +101 -0
  140. data/lib/cucumber/step_methods.rb +49 -0
  141. data/lib/cucumber/step_mother.rb +89 -0
  142. data/lib/cucumber/tree.rb +18 -0
  143. data/lib/cucumber/tree/feature.rb +61 -0
  144. data/lib/cucumber/tree/features.rb +21 -0
  145. data/lib/cucumber/tree/given_scenario.rb +13 -0
  146. data/lib/cucumber/tree/scenario.rb +158 -0
  147. data/lib/cucumber/tree/step.rb +134 -0
  148. data/lib/cucumber/tree/table.rb +26 -0
  149. data/lib/cucumber/tree/top_down_visitor.rb +23 -0
  150. data/lib/cucumber/treetop_parser/feature.treetop.erb +206 -0
  151. data/lib/cucumber/treetop_parser/feature_ar.rb +1591 -0
  152. data/lib/cucumber/treetop_parser/feature_cy.rb +1591 -0
  153. data/lib/cucumber/treetop_parser/feature_da.rb +1591 -0
  154. data/lib/cucumber/treetop_parser/feature_de.rb +1591 -0
  155. data/lib/cucumber/treetop_parser/feature_en-tx.rb +1591 -0
  156. data/lib/cucumber/treetop_parser/feature_en.rb +1591 -0
  157. data/lib/cucumber/treetop_parser/feature_es.rb +1591 -0
  158. data/lib/cucumber/treetop_parser/feature_et.rb +1591 -0
  159. data/lib/cucumber/treetop_parser/feature_fr.rb +1591 -0
  160. data/lib/cucumber/treetop_parser/feature_id.rb +1591 -0
  161. data/lib/cucumber/treetop_parser/feature_it.rb +1591 -0
  162. data/lib/cucumber/treetop_parser/feature_ja.rb +1591 -0
  163. data/lib/cucumber/treetop_parser/feature_nl.rb +1591 -0
  164. data/lib/cucumber/treetop_parser/feature_no.rb +1591 -0
  165. data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
  166. data/lib/cucumber/treetop_parser/feature_pl.rb +1591 -0
  167. data/lib/cucumber/treetop_parser/feature_pt.rb +1591 -0
  168. data/lib/cucumber/treetop_parser/feature_ro.rb +1591 -0
  169. data/lib/cucumber/treetop_parser/feature_ro2.rb +1591 -0
  170. data/lib/cucumber/treetop_parser/feature_ru.rb +1591 -0
  171. data/lib/cucumber/treetop_parser/feature_se.rb +1591 -0
  172. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1591 -0
  173. data/lib/cucumber/version.rb +9 -0
  174. data/rails_generators/cucumber/USAGE +11 -0
  175. data/rails_generators/cucumber/cucumber_generator.rb +30 -0
  176. data/rails_generators/cucumber/templates/cucumber +7 -0
  177. data/rails_generators/cucumber/templates/cucumber.rake +7 -0
  178. data/rails_generators/cucumber/templates/env.rb +8 -0
  179. data/rails_generators/cucumber/templates/webrat_steps.rb +46 -0
  180. data/rails_generators/feature/USAGE +12 -0
  181. data/rails_generators/feature/feature_generator.rb +16 -0
  182. data/rails_generators/feature/templates/feature.erb +28 -0
  183. data/rails_generators/feature/templates/steps.erb +22 -0
  184. data/script/console +10 -0
  185. data/script/console.cmd +1 -0
  186. data/script/destroy +14 -0
  187. data/script/destroy.cmd +1 -0
  188. data/script/generate +14 -0
  189. data/script/generate.cmd +1 -0
  190. data/script/txt2html +74 -0
  191. data/script/txt2html.cmd +1 -0
  192. data/setup.rb +1585 -0
  193. data/spec/cucumber/broadcaster_spec.rb +27 -0
  194. data/spec/cucumber/cli_spec.rb +242 -0
  195. data/spec/cucumber/core_ext/proc_spec.rb +45 -0
  196. data/spec/cucumber/core_ext/string_spec.rb +34 -0
  197. data/spec/cucumber/executor_spec.rb +222 -0
  198. data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
  199. data/spec/cucumber/formatters/autotest_formatter_spec.rb +26 -0
  200. data/spec/cucumber/formatters/features.html +269 -0
  201. data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
  202. data/spec/cucumber/formatters/pretty_formatter_spec.rb +204 -0
  203. data/spec/cucumber/formatters/profile_formatter_spec.rb +192 -0
  204. data/spec/cucumber/formatters/progress_formatter_spec.rb +65 -0
  205. data/spec/cucumber/model/table_spec.rb +20 -0
  206. data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
  207. data/spec/cucumber/rails/stubs/test_help.rb +1 -0
  208. data/spec/cucumber/rails/world_spec.rb +11 -0
  209. data/spec/cucumber/sell_cucumbers.feature +19 -0
  210. data/spec/cucumber/step_mother_spec.rb +74 -0
  211. data/spec/cucumber/tree/feature_spec.rb +12 -0
  212. data/spec/cucumber/tree/row_scenario_spec.rb +25 -0
  213. data/spec/cucumber/tree/scenario_spec.rb +76 -0
  214. data/spec/cucumber/tree/step_spec.rb +50 -0
  215. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  216. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  217. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +98 -0
  218. data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
  219. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  220. data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
  221. data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
  222. data/spec/cucumber/treetop_parser/spaces.feature +10 -0
  223. data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
  224. data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
  225. data/spec/spec.opts +2 -0
  226. data/spec/spec_helper.rb +19 -0
  227. metadata +151 -35
@@ -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 = "--language it"
6
+ end
@@ -0,0 +1,10 @@
1
+ Funzionalità: somma
2
+ Per evitare di fare errori stupidi
3
+ Come utente
4
+ Voglio sapere la somma di due numeri
5
+
6
+ Scenario: la somma di due numeri
7
+ Dato che ho inserito 5
8
+ E che ho inserito 7
9
+ Quando premo somma
10
+ Allora il risultato deve essere 12
@@ -0,0 +1,22 @@
1
+ require 'spec'
2
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
3
+ require 'calcolatrice'
4
+
5
+ Before do
6
+ @calc = Calcolatrice.new
7
+ end
8
+
9
+ After do
10
+ end
11
+
12
+ Given /che ho inserito (\d+)/ do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When 'premo somma' do
17
+ @result = @calc.add
18
+ end
19
+
20
+ Then /il risultato deve essere (\d*)/ do |result|
21
+ @result.should == result.to_i
22
+ end
@@ -0,0 +1,11 @@
1
+ class Calcolatrice
2
+ def push(n)
3
+ @args ||= []
4
+ @args << n
5
+ end
6
+
7
+ def add
8
+ #@args[0] + @args[1]
9
+ @args.inject(0){|n,sum| sum+=n}
10
+ end
11
+ end
@@ -0,0 +1,5 @@
1
+ Run the features with
2
+
3
+ rake features
4
+
5
+ There is a bug in the calculator. Can you spot it and fix it?
@@ -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 ja"
6
+ end
@@ -0,0 +1,17 @@
1
+ フィーチャ: 加算
2
+ バカな間違いを避けるために
3
+ 数学オンチとして
4
+ 2つの数の合計を知りたい
5
+
6
+ シナリオ: 2つの数の加算について
7
+ 前提 50 を入力
8
+ かつ 70 を入力
9
+ もし add ボタンを押した
10
+ ならば 結果は 120 を表示
11
+ かつ 結果のクラスは Fixnum
12
+
13
+ 他のサンプル:
14
+ | 入力1 | 入力2 | 実行 | 表示 | クラス |
15
+ | 20 | 30 | add | 50 | Fixnum |
16
+ | 2 | 5 | add | 7 | Fixnum |
17
+ | 0 | 40 | add | 40 | Fixnum |
@@ -0,0 +1,10 @@
1
+ フィーチャ: 除算
2
+ バカな間違いを避けるために
3
+ 有理数も計算できること
4
+
5
+ シナリオ: ふつうの数値
6
+ 前提 3 を入力
7
+ かつ 2 を入力
8
+ もし divide ボタンを押した
9
+ ならば 結果は 1.5 を表示
10
+ かつ 結果のクラスは Float
@@ -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 "$n を入力" do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When /(\w+) ボタンを押した/ do |op|
17
+ @result = @calc.send op
18
+ end
19
+
20
+ Then /結果は (.*) を表示/ do |result|
21
+ @result.should == result.to_f
22
+ end
23
+
24
+ Then /結果のクラスは (\w*)/ 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
@@ -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 no"
6
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec'
2
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
3
+ require 'kalkulator'
4
+
5
+ Before do
6
+ @calc = Kalkulator.new
7
+ end
8
+
9
+ After do
10
+ end
11
+
12
+ Given /at jeg har tastet inn (\d+)/ do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When 'jeg summerer' do
17
+ @result = @calc.add
18
+ end
19
+
20
+ Then /skal resultatet være (\d*)/ do |result|
21
+ @result.should == result.to_i
22
+ end
@@ -0,0 +1,17 @@
1
+ Egenskap: Summering
2
+ For å slippe å gjøre dumme feil
3
+ Som en regnskapsfører
4
+ Vil jeg kunne legge sammen
5
+
6
+ Scenario: to tall
7
+ Gitt at jeg har tastet inn 5
8
+ Og at jeg har tastet inn 7
9
+ Når jeg summerer
10
+ Så skal resultatet være 12
11
+
12
+ Scenario: tre tall
13
+ Gitt at jeg har tastet inn 5
14
+ Og at jeg har tastet inn 7
15
+ Og at jeg har tastet inn 1
16
+ Når jeg summerer
17
+ Så skal resultatet være 13
@@ -0,0 +1,11 @@
1
+ class Kalkulator
2
+ def push(n)
3
+ @args ||= []
4
+ @args << n
5
+ end
6
+
7
+ def add
8
+ #@args[0] + @args[1]
9
+ @args.inject(0){|n,sum| sum+=n}
10
+ end
11
+ 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 pt"
6
+ end
@@ -0,0 +1,10 @@
1
+ Funcionalidade: Adição
2
+ Para evitar erros bobos
3
+ Como um péssimo matemático
4
+ Eu quero saber como somar dois números
5
+
6
+ Cenário: Adicionar dois números
7
+ Dado que eu digitei 50 na calculadora
8
+ E que eu digitei 70 na calculadora
9
+ Quando eu aperto o botão de soma
10
+ Então o resultado na calculadora deve ser 120
@@ -0,0 +1,22 @@
1
+ require 'spec'
2
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
3
+ require 'calculadora'
4
+
5
+ Before do
6
+ @calc = Calculadora.new
7
+ end
8
+
9
+ After do
10
+ end
11
+
12
+ Given /que eu digitei (\d+) na calculadora/ do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When 'eu aperto o botão de soma' do
17
+ @result = @calc.soma
18
+ end
19
+
20
+ Then /o resultado na calculadora deve ser (\d*)/ do |result|
21
+ @result.should == result.to_i
22
+ end
@@ -0,0 +1,10 @@
1
+ class Calculadora
2
+ def push(n)
3
+ @args ||= []
4
+ @args << n
5
+ end
6
+
7
+ def soma
8
+ @args.inject(0) {|n,sum| sum+n}
9
+ end
10
+ 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 ro"
6
+ end
@@ -0,0 +1,22 @@
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 /introduc (\d+)/ do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When 'apas suma' do
17
+ @result = @calc.add
18
+ end
19
+
20
+ Then /rezultatul trebuie sa fie (\d*)/ do |result|
21
+ @result.should == result.to_i
22
+ end
@@ -0,0 +1,10 @@
1
+ Functionalitate: suma
2
+ Pentru a nu face erori stupide
3
+ Ca utilizator
4
+ Vreau sa stiu suma a doua numere
5
+
6
+ Scenariu: suma a doua numere
7
+ Daca introduc 5
8
+ Si apoi introduc 7
9
+ Cand apas suma
10
+ Atunci rezultatul trebuie sa fie 12
@@ -0,0 +1,11 @@
1
+ class Calculator
2
+ def push(n)
3
+ @args ||= []
4
+ @args << n
5
+ end
6
+
7
+ def add
8
+ #@args[0] + @args[1]
9
+ @args.inject(0){|n,sum| sum+=n}
10
+ end
11
+ 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 se"
6
+ end
@@ -0,0 +1,22 @@
1
+ require 'spec'
2
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
3
+ require 'kalkulator'
4
+
5
+ Before do
6
+ @calc = Kalkulator.new
7
+ end
8
+
9
+ After do
10
+ end
11
+
12
+ Given /att jag har knappat in (\d+)/ do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When 'jag summerar' do
17
+ @result = @calc.add
18
+ end
19
+
20
+ Then /ska resultatet vara (\d+)/ do |result|
21
+ @result.should == result.to_i
22
+ end
@@ -0,0 +1,17 @@
1
+ Egenskap: Summering
2
+ För att slippa att göra dumma fel
3
+ Som räknare
4
+ Vill jag kunna lägga samman
5
+
6
+ Scenario: två tal
7
+ Givet att jag har knappat in 5
8
+ Och att jag har knappat in 7
9
+ När jag summerar
10
+ Så ska resultatet vara 12
11
+
12
+ Scenario: tre tal
13
+ Givet att jag har knappat in 5
14
+ Och att jag har knappat in 4
15
+ Och att jag har knappat in 3
16
+ När jag summerar
17
+ Så ska resultatet vara 12
@@ -0,0 +1,11 @@
1
+ class Kalkulator
2
+ def push(n)
3
+ @args ||= []
4
+ @args << n
5
+ end
6
+
7
+ def add
8
+ #@args[0] + @args[1]
9
+ @args.inject(0){|n,sum| sum+=n}
10
+ end
11
+ 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 zh-CN"
6
+ end
@@ -0,0 +1,17 @@
1
+ 功能:加法
2
+ 为了避免一些愚蠢的错误
3
+ 作为一个数学白痴
4
+ 我希望有人告诉我数字相加的结果
5
+
6
+ 场景: 两个数相加
7
+ 假如我已经在计算器里输入6
8
+ 而且我已经在计算器里输入7
9
+ 当我按相加按钮
10
+ 那么我应该在屏幕上看到的结果是13
11
+
12
+ 场景: 三个数相加
13
+ 假如我已经在计算器里输入6
14
+ 而且我已经在计算器里输入7
15
+ 而且我已经在计算器里输入1
16
+ 当我按相加按钮
17
+ 那么我应该在屏幕上看到的结果是14
@@ -0,0 +1,24 @@
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 "我已经在计算器里输入$n" do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When /我按(.*)按钮/ do |op|
17
+ if op == '相加'
18
+ @result = @calc.send "add"
19
+ end
20
+ end
21
+
22
+ Then /我应该在屏幕上看到的结果是(.*)/ do |result|
23
+ @result.should == result.to_f
24
+ end