elight-cucumber 0.1.9

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 (186) hide show
  1. data/History.txt +150 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +186 -0
  4. data/README.txt +41 -0
  5. data/Rakefile +5 -0
  6. data/TODO.txt +26 -0
  7. data/bin/cucumber +4 -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/README.txt +5 -0
  12. data/examples/calculator/Rakefile +5 -0
  13. data/examples/calculator/features/addition.feature +17 -0
  14. data/examples/calculator/features/division.feature +10 -0
  15. data/examples/calculator/features/steps/calculator_steps.rb +31 -0
  16. data/examples/calculator/lib/calculator.rb +16 -0
  17. data/examples/calculator_ruby_features/Rakefile +6 -0
  18. data/examples/calculator_ruby_features/features/addition.rb +23 -0
  19. data/examples/calculator_ruby_features/features/steps/calculator_steps.rb +43 -0
  20. data/examples/calculatrice_francaise_avec_soit_scenario/Rakefile +6 -0
  21. data/examples/calculatrice_francaise_avec_soit_scenario/features/addition.feature +13 -0
  22. data/examples/calculatrice_francaise_avec_soit_scenario/features/calculatrice_steps.rb +31 -0
  23. data/examples/chinese_simplified_calculator/Rakefile +6 -0
  24. data/examples/chinese_simplified_calculator/features/addition.feature +17 -0
  25. data/examples/chinese_simplified_calculator/features/steps/calculator_steps.rb +24 -0
  26. data/examples/chinese_simplified_calculator/lib/calculator.rb +10 -0
  27. data/examples/cs/README.textile +22 -0
  28. data/examples/cs/Rakefile +12 -0
  29. data/examples/cs/features/hello.feature +11 -0
  30. data/examples/cs/features/steps/hello_steps.rb +25 -0
  31. data/examples/cs/features/steps/tree_steps.rb +14 -0
  32. data/examples/cs/features/tree.feature +9 -0
  33. data/examples/cs/src/Hello.cs +18 -0
  34. data/examples/danish_calculator/Rakefile +6 -0
  35. data/examples/danish_calculator/features/steps/kalkulator_steps.rb +22 -0
  36. data/examples/danish_calculator/features/summering.feature +17 -0
  37. data/examples/danish_calculator/lib/kalkulator.rb +11 -0
  38. data/examples/dos_line_endings/Rakefile +6 -0
  39. data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
  40. data/examples/estonian_calculator/Rakefile +6 -0
  41. data/examples/estonian_calculator/features/kalkulaator_steps.rb +35 -0
  42. data/examples/estonian_calculator/features/liitmine.feature +16 -0
  43. data/examples/japanese_calculator/README.txt +5 -0
  44. data/examples/japanese_calculator/Rakefile +6 -0
  45. data/examples/japanese_calculator/features/addition.feature +17 -0
  46. data/examples/japanese_calculator/features/division.feature +10 -0
  47. data/examples/japanese_calculator/features/steps/calculator_steps.rb +30 -0
  48. data/examples/japanese_calculator/lib/calculator.rb +16 -0
  49. data/examples/java/README.textile +22 -0
  50. data/examples/java/Rakefile +12 -0
  51. data/examples/java/features/hello.feature +11 -0
  52. data/examples/java/features/steps/hello_steps.rb +25 -0
  53. data/examples/java/features/steps/tree_steps.rb +14 -0
  54. data/examples/java/features/tree.feature +9 -0
  55. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  56. data/examples/norwegian_calculator/Rakefile +6 -0
  57. data/examples/norwegian_calculator/features/steps/kalkulator_steps.rb +22 -0
  58. data/examples/norwegian_calculator/features/summering.feature +17 -0
  59. data/examples/norwegian_calculator/lib/kalkulator.rb +11 -0
  60. data/examples/portuguese_calculator/Rakefile +6 -0
  61. data/examples/portuguese_calculator/features/adicao.feature +10 -0
  62. data/examples/portuguese_calculator/features/calculadora_steps.rb +31 -0
  63. data/examples/selenium/Rakefile +6 -0
  64. data/examples/selenium/features/search.feature +9 -0
  65. data/examples/selenium/features/steps/stories_steps.rb +41 -0
  66. data/examples/spanish_calculator/Rakefile +6 -0
  67. data/examples/spanish_calculator/features/adicion.feature +17 -0
  68. data/examples/spanish_calculator/features/steps/calculador_steps.rb +22 -0
  69. data/examples/swedish_calculator/Rakefile +5 -0
  70. data/examples/swedish_calculator/features/steps/kalkulator_steps.rb +22 -0
  71. data/examples/swedish_calculator/features/summering.feature +17 -0
  72. data/examples/swedish_calculator/lib/kalkulator.rb +11 -0
  73. data/examples/tickets/Rakefile +11 -0
  74. data/examples/tickets/cucumber.yml +2 -0
  75. data/examples/tickets/features/steps/tickets_steps.rb +32 -0
  76. data/examples/tickets/features/tickets.feature +22 -0
  77. data/examples/watir/Rakefile +6 -0
  78. data/examples/watir/features/search.feature +9 -0
  79. data/examples/watir/features/steps/stories_steps.rb +51 -0
  80. data/features/see_features.feature +8 -0
  81. data/features/steps/features_steps.rb +9 -0
  82. data/gem_tasks/deployment.rake +34 -0
  83. data/gem_tasks/environment.rake +7 -0
  84. data/gem_tasks/features.rake +6 -0
  85. data/gem_tasks/fix_cr_lf.rake +10 -0
  86. data/gem_tasks/flog.rake +4 -0
  87. data/gem_tasks/gemspec.rake +6 -0
  88. data/gem_tasks/rspec.rake +21 -0
  89. data/gem_tasks/treetop.rake +49 -0
  90. data/lib/cucumber.rb +35 -0
  91. data/lib/cucumber/cli.rb +191 -0
  92. data/lib/cucumber/core_ext/proc.rb +55 -0
  93. data/lib/cucumber/core_ext/string.rb +22 -0
  94. data/lib/cucumber/executor.rb +143 -0
  95. data/lib/cucumber/formatters.rb +1 -0
  96. data/lib/cucumber/formatters/ansicolor.rb +112 -0
  97. data/lib/cucumber/formatters/cucumber.css +132 -0
  98. data/lib/cucumber/formatters/cucumber.js +11 -0
  99. data/lib/cucumber/formatters/html_formatter.rb +128 -0
  100. data/lib/cucumber/formatters/jquery.js +32 -0
  101. data/lib/cucumber/formatters/pretty_formatter.rb +211 -0
  102. data/lib/cucumber/formatters/profile_formatter.rb +92 -0
  103. data/lib/cucumber/formatters/progress_formatter.rb +51 -0
  104. data/lib/cucumber/languages.yml +142 -0
  105. data/lib/cucumber/model.rb +1 -0
  106. data/lib/cucumber/model/table.rb +28 -0
  107. data/lib/cucumber/rails/rspec.rb +12 -0
  108. data/lib/cucumber/rails/world.rb +73 -0
  109. data/lib/cucumber/rake/task.rb +75 -0
  110. data/lib/cucumber/step_methods.rb +49 -0
  111. data/lib/cucumber/step_mother.rb +83 -0
  112. data/lib/cucumber/tree.rb +18 -0
  113. data/lib/cucumber/tree/feature.rb +60 -0
  114. data/lib/cucumber/tree/features.rb +21 -0
  115. data/lib/cucumber/tree/given_scenario.rb +13 -0
  116. data/lib/cucumber/tree/scenario.rb +150 -0
  117. data/lib/cucumber/tree/step.rb +133 -0
  118. data/lib/cucumber/tree/table.rb +26 -0
  119. data/lib/cucumber/tree/top_down_visitor.rb +23 -0
  120. data/lib/cucumber/treetop_parser/feature.treetop.erb +201 -0
  121. data/lib/cucumber/treetop_parser/feature_da.rb +1593 -0
  122. data/lib/cucumber/treetop_parser/feature_de.rb +1593 -0
  123. data/lib/cucumber/treetop_parser/feature_en-tx.rb +1593 -0
  124. data/lib/cucumber/treetop_parser/feature_en.rb +1593 -0
  125. data/lib/cucumber/treetop_parser/feature_es.rb +1593 -0
  126. data/lib/cucumber/treetop_parser/feature_et.rb +1593 -0
  127. data/lib/cucumber/treetop_parser/feature_fr.rb +1593 -0
  128. data/lib/cucumber/treetop_parser/feature_ja.rb +1593 -0
  129. data/lib/cucumber/treetop_parser/feature_nl.rb +1593 -0
  130. data/lib/cucumber/treetop_parser/feature_no.rb +1593 -0
  131. data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
  132. data/lib/cucumber/treetop_parser/feature_pt.rb +1593 -0
  133. data/lib/cucumber/treetop_parser/feature_ru.rb +1593 -0
  134. data/lib/cucumber/treetop_parser/feature_se.rb +1593 -0
  135. data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1593 -0
  136. data/lib/cucumber/version.rb +9 -0
  137. data/rails_generators/cucumber/cucumber_generator.rb +29 -0
  138. data/rails_generators/cucumber/templates/common_webrat.rb +42 -0
  139. data/rails_generators/cucumber/templates/cucumber +2 -0
  140. data/rails_generators/cucumber/templates/cucumber.rake +12 -0
  141. data/rails_generators/cucumber/templates/cucumber.yml +1 -0
  142. data/rails_generators/cucumber/templates/env.rb +8 -0
  143. data/rails_generators/feature/feature_generator.rb +17 -0
  144. data/rails_generators/feature/templates/feature.erb +28 -0
  145. data/rails_generators/feature/templates/steps.erb +22 -0
  146. data/script/console +10 -0
  147. data/script/console.cmd +1 -0
  148. data/script/destroy +14 -0
  149. data/script/destroy.cmd +1 -0
  150. data/script/generate +14 -0
  151. data/script/generate.cmd +1 -0
  152. data/script/txt2html +74 -0
  153. data/script/txt2html.cmd +1 -0
  154. data/setup.rb +1585 -0
  155. data/spec/cucumber/cli_spec.rb +56 -0
  156. data/spec/cucumber/core_ext/proc_spec.rb +45 -0
  157. data/spec/cucumber/core_ext/string_spec.rb +34 -0
  158. data/spec/cucumber/executor_spec.rb +130 -0
  159. data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
  160. data/spec/cucumber/formatters/features.html +269 -0
  161. data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
  162. data/spec/cucumber/formatters/pretty_formatter_spec.rb +111 -0
  163. data/spec/cucumber/formatters/profile_formatter_spec.rb +193 -0
  164. data/spec/cucumber/formatters/progress_formatter_spec.rb +45 -0
  165. data/spec/cucumber/model/table_spec.rb +20 -0
  166. data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
  167. data/spec/cucumber/rails/stubs/test_help.rb +1 -0
  168. data/spec/cucumber/rails/world_spec.rb +11 -0
  169. data/spec/cucumber/sell_cucumbers.feature +9 -0
  170. data/spec/cucumber/step_mother_spec.rb +53 -0
  171. data/spec/cucumber/tree/feature_spec.rb +12 -0
  172. data/spec/cucumber/tree/scenario_spec.rb +37 -0
  173. data/spec/cucumber/tree/step_spec.rb +31 -0
  174. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  175. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  176. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +96 -0
  177. data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
  178. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  179. data/spec/cucumber/treetop_parser/multiline_steps.feature +13 -0
  180. data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
  181. data/spec/cucumber/treetop_parser/spaces.feature +10 -0
  182. data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
  183. data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
  184. data/spec/spec.opts +2 -0
  185. data/spec/spec_helper.rb +19 -0
  186. metadata +288 -0
@@ -0,0 +1,17 @@
1
+ Egenskab: Summering
2
+ For at slippe for at lave dumme fejl
3
+ Som en regnskabsfører
4
+ Vil jeg kunne lægge sammen
5
+
6
+ Scenarie: to tal
7
+ Givet at jeg har indtastet 5
8
+ Og at jeg har indtastet 7
9
+ Når jeg summerer
10
+ Så skal resultatet være 12
11
+
12
+ Scenarie: tre tal
13
+ Givet at jeg har indtastet 5
14
+ Og at jeg har indtastet 7
15
+ Og at jeg har indtastet 1
16
+ Når jeg summerer
17
+ Så skal resultatet være 14
@@ -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 = "--format pretty"
6
+ end
@@ -0,0 +1,9 @@
1
+ Feature: DOS line endings
2
+ In order to have less bug reports
3
+ As a windows developer
4
+ I want to write features with DOS line endigs
5
+
6
+ Scenario: Just lots of DOS
7
+ Given I am on DOS
8
+ And Any version of Windows is really just DOS
9
+ Then Windows still sucks
@@ -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 --language et"
6
+ end
@@ -0,0 +1,35 @@
1
+ require 'spec'
2
+
3
+ class Kalkulaator
4
+ def push(n)
5
+ @args ||= []
6
+ @args << n
7
+ end
8
+
9
+ def liida
10
+ @args.inject(0) {|n,sum| sum+n}
11
+ end
12
+ end
13
+
14
+ Before do
15
+ @calc = Kalkulaator.new
16
+ end
17
+
18
+ After do
19
+ end
20
+
21
+ Given /olen sisestanud kalkulaatorisse numbri (\d+)/ do |n|
22
+ @calc.push n.to_i
23
+ end
24
+
25
+ When /ma vajutan (.*)/ do |op|
26
+ @result = @calc.send op
27
+ end
28
+
29
+ Then /vastuseks peab ekraanil kuvatama (\d*)/ do |result|
30
+ @result.should == result.to_i
31
+ end
32
+
33
+ Then /vastuseklass peab olema tüüpi (\w*)/ do |class_name|
34
+ @result.class.name.should == class_name
35
+ end
@@ -0,0 +1,16 @@
1
+ Omadus: Liitmine
2
+ Selleks et vältida rumalaid vigu
3
+ Olles matemaatika-puupea
4
+ Tahan et mulle öeldaks kahe numbri summa
5
+
6
+ Stsenaarium: Liida kaks numbrit
7
+ Eeldades et olen sisestanud kalkulaatorisse numbri 50
8
+ Ja olen sisestanud kalkulaatorisse numbri 70
9
+ Kui ma vajutan liida
10
+ Siis vastuseks peab ekraanil kuvatama 120
11
+ Ja vastuseklass peab olema tüüpi Fixnum
12
+
13
+ | input_1 | input_2 | button | output | class |
14
+ | 20 | 30 | liida | 50 | Fixnum |
15
+ | 2 | 5 | liida | 7 | Fixnum |
16
+ | 0 | 40 | liida | 40 | Fixnum |
@@ -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') # If you're running off a Cucumber gem you can skip this line
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new do |t|
5
+ t.cucumber_opts = "--format pretty --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,16 @@
1
+ class Calculator
2
+ def push(n)
3
+ n += 2 if n == 0 # a really stupid bug
4
+
5
+ @args ||= []
6
+ @args << n
7
+ end
8
+
9
+ def add
10
+ @args.inject(0){|n,sum| sum+=n}
11
+ end
12
+
13
+ def divide
14
+ @args[0].to_f / @args[1].to_f
15
+ end
16
+ end
@@ -0,0 +1,22 @@
1
+ h1. Using Cucumber with Java
2
+
3
+ This directory contains code to demonstrate how Cucumber can be used to develop Java code.
4
+ You need JRuby 1.1.3 or higher installed and JRuby's bin directory on your PATH.
5
+
6
+ h2. Installing required gems
7
+
8
+ jruby -S gem install aslakhellesoy-cucumber
9
+ jruby -S gem install diff-lcs
10
+
11
+ h2. Running the scenarios
12
+
13
+ Open a shell in this directory (java) and execute the following command:
14
+
15
+ <pre><code>
16
+ jruby -S rake features
17
+ </code></pre>
18
+
19
+ This will compile the java code and package it in a jar file, and then run Cucumber against
20
+ that code.
21
+
22
+ There is a deliberate error. See if you can fix it!
@@ -0,0 +1,12 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new(:features) do |t|
5
+ t.cucumber_opts = "--format pretty"
6
+ end
7
+
8
+ task :features => :compile
9
+
10
+ task :compile do
11
+ sh "javac src/cucumber/demo/Hello.java && jar cf src/cucumber_demo.jar -C src cucumber/demo/Hello.class"
12
+ end
@@ -0,0 +1,11 @@
1
+ Feature: Hello
2
+ In order to have more friends
3
+ I want to say hello
4
+
5
+ Scenario: Personal greeting
6
+ Given my name is Aslak
7
+ When I greet David
8
+ Then he should hear Hi, David. I'm Aslak.
9
+ And I should remember David as a friend
10
+ And I should get David's phone number
11
+
@@ -0,0 +1,25 @@
1
+ require 'spec' # so we can call .should
2
+ $LOAD_PATH.unshift(File.dirname(__FILE__) + '/../../src') # so the jar is found
3
+ require 'cucumber_demo' # puts the jar on the classpath
4
+ include_class 'cucumber.demo.Hello'
5
+
6
+ Given /my name is (\w+)/ do |name|
7
+ @hello = Hello.new # A java object
8
+ @name = name
9
+ end
10
+
11
+ When /I greet (.*)/ do |someone|
12
+ @greeting = @hello.greet(someone, @name)
13
+ end
14
+
15
+ Then /he should hear (.*)\./ do |message|
16
+ @greeting.should == message
17
+ end
18
+
19
+ Then /I should remember (\w+) as a friend/ do |name|
20
+ @hello.friend?(name).should == true
21
+ end
22
+
23
+ Then /I should get (\w+)'s phone number/ do |name| #'
24
+ @hello.getPhoneNumber(name).should_not == nil
25
+ end
@@ -0,0 +1,14 @@
1
+ require 'spec'
2
+ include_class 'java.util.TreeSet'
3
+
4
+ Given /I have an empty set/ do
5
+ @set = TreeSet.new
6
+ end
7
+
8
+ When /I add (\w+)/ do |s|
9
+ @set.add(s)
10
+ end
11
+
12
+ Then /the contents should be (.*)/ do |s|
13
+ @set.to_a.join(" ").should == s
14
+ end
@@ -0,0 +1,9 @@
1
+ Feature: Tree
2
+ In order to have more robust Java software
3
+ I want to use Cucumber against Java classes
4
+
5
+ Scenario: Use java.util.TreeSet
6
+ Given I have an empty set
7
+ When I add hello
8
+ And I add world
9
+ Then the contents should be hello world
@@ -0,0 +1,16 @@
1
+ package cucumber.demo;
2
+
3
+ public class Hello {
4
+ public String greet(String who, String from) {
5
+ return "Hi, " + who + ". I'm " + from;
6
+ }
7
+
8
+ public boolean isFriend(String who) {
9
+ return true;
10
+ }
11
+
12
+ public String getPhoneNumber(String who) {
13
+ throw new RuntimeException("NOPE");
14
+ //return "98219458";
15
+ }
16
+ }
@@ -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 --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 = "--format pretty --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,31 @@
1
+ require 'spec'
2
+
3
+ class Calculadora
4
+ def push(n)
5
+ @args ||= []
6
+ @args << n
7
+ end
8
+
9
+ def soma
10
+ @args.inject(0) {|n,sum| sum+n}
11
+ end
12
+ end
13
+
14
+ Before do
15
+ @calc = Calculadora.new
16
+ end
17
+
18
+ After do
19
+ end
20
+
21
+ Given /que eu digitei (\d+) na calculadora/ do |n|
22
+ @calc.push n.to_i
23
+ end
24
+
25
+ When 'eu aperto o botão de soma' do
26
+ @result = @calc.soma
27
+ end
28
+
29
+ Then /o resultado na calculadora deve ser (\d*)/ do |result|
30
+ @result.should == result.to_i
31
+ 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