cucumber 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (153) hide show
  1. data/History.txt +3 -0
  2. data/License.txt +20 -0
  3. data/Manifest.txt +152 -0
  4. data/README.txt +42 -0
  5. data/Rakefile +4 -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/Rakefile +6 -0
  12. data/examples/calculator/cucumber.yml +1 -0
  13. data/examples/calculator/features/addition.feature +16 -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/cs/README.textile +22 -0
  24. data/examples/cs/Rakefile +12 -0
  25. data/examples/cs/features/hello.feature +11 -0
  26. data/examples/cs/features/steps/hello_steps.rb +25 -0
  27. data/examples/cs/features/steps/tree_steps.rb +14 -0
  28. data/examples/cs/features/tree.feature +9 -0
  29. data/examples/cs/src/Hello.cs +18 -0
  30. data/examples/danish_calculator/Rakefile +6 -0
  31. data/examples/danish_calculator/features/steps/kalkulator_steps.rb +22 -0
  32. data/examples/danish_calculator/features/summering.feature +17 -0
  33. data/examples/danish_calculator/lib/kalkulator.rb +11 -0
  34. data/examples/estonian_calculator/Rakefile +6 -0
  35. data/examples/estonian_calculator/features/kalkulaator_steps.rb +35 -0
  36. data/examples/estonian_calculator/features/liitmine.feature +16 -0
  37. data/examples/java/README.textile +22 -0
  38. data/examples/java/Rakefile +12 -0
  39. data/examples/java/features/hello.feature +11 -0
  40. data/examples/java/features/steps/hello_steps.rb +25 -0
  41. data/examples/java/features/steps/tree_steps.rb +14 -0
  42. data/examples/java/features/tree.feature +9 -0
  43. data/examples/java/src/cucumber/demo/Hello.java +16 -0
  44. data/examples/norwegian_calculator/Rakefile +6 -0
  45. data/examples/norwegian_calculator/features/steps/kalkulator_steps.rb +22 -0
  46. data/examples/norwegian_calculator/features/summering.feature +17 -0
  47. data/examples/norwegian_calculator/lib/kalkulator.rb +11 -0
  48. data/examples/portuguese_calculator/Rakefile +6 -0
  49. data/examples/portuguese_calculator/features/adicao.feature +10 -0
  50. data/examples/portuguese_calculator/features/calculadora_steps.rb +31 -0
  51. data/examples/selenium/Rakefile +6 -0
  52. data/examples/selenium/features/search.feature +9 -0
  53. data/examples/selenium/features/steps/stories_steps.rb +41 -0
  54. data/examples/spanish_calculator/Rakefile +6 -0
  55. data/examples/spanish_calculator/features/adicion.feature +17 -0
  56. data/examples/spanish_calculator/features/steps/calculador_steps.rb +22 -0
  57. data/examples/spanish_calculator/lib/Calculador.rb +11 -0
  58. data/examples/tickets/Rakefile +4 -0
  59. data/examples/tickets/features/steps/tickets_steps.rb +5 -0
  60. data/examples/tickets/features/tickets.feature +7 -0
  61. data/examples/watir/Rakefile +6 -0
  62. data/examples/watir/features/search.feature +9 -0
  63. data/examples/watir/features/steps/stories_steps.rb +51 -0
  64. data/features/see_features.feature +8 -0
  65. data/features/steps/features_steps.rb +9 -0
  66. data/gem_tasks/deployment.rake +34 -0
  67. data/gem_tasks/environment.rake +7 -0
  68. data/gem_tasks/features.rake +6 -0
  69. data/gem_tasks/fix_cr_lf.rake +10 -0
  70. data/gem_tasks/flog.rake +4 -0
  71. data/gem_tasks/gemspec.rake +6 -0
  72. data/gem_tasks/rspec.rake +21 -0
  73. data/gem_tasks/treetop.rake +27 -0
  74. data/generators/cucumber/cucumber_generator.rb +27 -0
  75. data/generators/cucumber/templates/common_webrat.rb +51 -0
  76. data/generators/cucumber/templates/cucumber +2 -0
  77. data/generators/cucumber/templates/cucumber.rake +7 -0
  78. data/generators/cucumber/templates/env.rb +8 -0
  79. data/generators/feature/feature_generator.rb +17 -0
  80. data/generators/feature/templates/feature.erb +27 -0
  81. data/generators/feature/templates/steps.erb +22 -0
  82. data/lib/cucumber.rb +32 -0
  83. data/lib/cucumber/cli.rb +163 -0
  84. data/lib/cucumber/core_ext/proc.rb +43 -0
  85. data/lib/cucumber/core_ext/string.rb +22 -0
  86. data/lib/cucumber/executor.rb +120 -0
  87. data/lib/cucumber/formatters.rb +1 -0
  88. data/lib/cucumber/formatters/ansicolor.rb +90 -0
  89. data/lib/cucumber/formatters/cucumber.css +132 -0
  90. data/lib/cucumber/formatters/cucumber.js +11 -0
  91. data/lib/cucumber/formatters/html_formatter.rb +125 -0
  92. data/lib/cucumber/formatters/jquery.js +32 -0
  93. data/lib/cucumber/formatters/pretty_formatter.rb +126 -0
  94. data/lib/cucumber/formatters/progress_formatter.rb +42 -0
  95. data/lib/cucumber/languages.yml +83 -0
  96. data/lib/cucumber/rails/rspec.rb +12 -0
  97. data/lib/cucumber/rails/world.rb +75 -0
  98. data/lib/cucumber/rake/task.rb +75 -0
  99. data/lib/cucumber/step_methods.rb +45 -0
  100. data/lib/cucumber/step_mother.rb +82 -0
  101. data/lib/cucumber/tree.rb +18 -0
  102. data/lib/cucumber/tree/feature.rb +53 -0
  103. data/lib/cucumber/tree/features.rb +21 -0
  104. data/lib/cucumber/tree/given_scenario.rb +13 -0
  105. data/lib/cucumber/tree/scenario.rb +110 -0
  106. data/lib/cucumber/tree/step.rb +123 -0
  107. data/lib/cucumber/tree/table.rb +26 -0
  108. data/lib/cucumber/tree/top_down_visitor.rb +23 -0
  109. data/lib/cucumber/treetop_parser/feature.treetop.erb +159 -0
  110. data/lib/cucumber/treetop_parser/feature_da.rb +1214 -0
  111. data/lib/cucumber/treetop_parser/feature_de.rb +1214 -0
  112. data/lib/cucumber/treetop_parser/feature_en.rb +1214 -0
  113. data/lib/cucumber/treetop_parser/feature_es.rb +1214 -0
  114. data/lib/cucumber/treetop_parser/feature_et.rb +1214 -0
  115. data/lib/cucumber/treetop_parser/feature_fr.rb +1214 -0
  116. data/lib/cucumber/treetop_parser/feature_no.rb +1214 -0
  117. data/lib/cucumber/treetop_parser/feature_parser.rb +32 -0
  118. data/lib/cucumber/treetop_parser/feature_pt.rb +1214 -0
  119. data/lib/cucumber/treetop_parser/feature_ru.rb +1214 -0
  120. data/lib/cucumber/treetop_parser/feature_se.rb +1214 -0
  121. data/lib/cucumber/version.rb +9 -0
  122. data/script/console +10 -0
  123. data/script/console.cmd +1 -0
  124. data/script/destroy +14 -0
  125. data/script/destroy.cmd +1 -0
  126. data/script/generate +14 -0
  127. data/script/generate.cmd +1 -0
  128. data/script/txt2html +74 -0
  129. data/script/txt2html.cmd +1 -0
  130. data/setup.rb +1585 -0
  131. data/spec/cucumber/cli_spec.rb +36 -0
  132. data/spec/cucumber/core_ext/proc_spec.rb +39 -0
  133. data/spec/cucumber/core_ext/string_spec.rb +34 -0
  134. data/spec/cucumber/executor_spec.rb +131 -0
  135. data/spec/cucumber/formatters/ansicolor_spec.rb +23 -0
  136. data/spec/cucumber/formatters/features.html +269 -0
  137. data/spec/cucumber/formatters/html_formatter_spec.rb +59 -0
  138. data/spec/cucumber/formatters/pretty_formatter_spec.rb +17 -0
  139. data/spec/cucumber/formatters/progress_formatter_spec.rb +44 -0
  140. data/spec/cucumber/sell_cucumbers.feature +9 -0
  141. data/spec/cucumber/step_mother_spec.rb +53 -0
  142. data/spec/cucumber/tree/scenario_spec.rb +15 -0
  143. data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
  144. data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
  145. data/spec/cucumber/treetop_parser/feature_parser_spec.rb +73 -0
  146. data/spec/cucumber/treetop_parser/fit_scenario.feature +7 -0
  147. data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
  148. data/spec/cucumber/treetop_parser/multiple_tables.feature +27 -0
  149. data/spec/cucumber/treetop_parser/spaces.feature +10 -0
  150. data/spec/cucumber/treetop_parser/with_comments.feature +6 -0
  151. data/spec/spec.opts +2 -0
  152. data/spec/spec_helper.rb +23 -0
  153. metadata +259 -0
@@ -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
@@ -0,0 +1,9 @@
1
+ Feature: Search
2
+ In order to learn more
3
+ As an information seeker
4
+ I want to find more information
5
+
6
+ Scenario: Find what I'm looking for
7
+ Given I am on the Google search page
8
+ When I search for "rspec"
9
+ Then I should see a link to "RSpec-1.1.4: Overview":http://rspec.info/
@@ -0,0 +1,41 @@
1
+ require 'spec'
2
+ require 'selenium'
3
+
4
+ class GoogleSearch
5
+ def initialize(browser)
6
+ @browser = browser
7
+ end
8
+
9
+ def goto
10
+ @browser.open 'http://www.google.com/'
11
+ end
12
+
13
+ def search(text)
14
+ @browser.type('q',text)
15
+ @browser.click 'btnG'
16
+ @browser.wait_for_page_to_load
17
+ end
18
+ end
19
+
20
+ Before do
21
+ @browser = Selenium::SeleniumDriver.new("localhost", 4444, "*chrome", "http://localhost", 15000)
22
+ @browser.start
23
+ end
24
+
25
+ After do
26
+ @browser.stop
27
+ end
28
+
29
+ Given 'I am on the Google search page' do
30
+ @page = GoogleSearch.new(@browser)
31
+ @page.goto
32
+ end
33
+
34
+ When /I search for "(.*)"/ do |query|
35
+ @page.search(query)
36
+ end
37
+
38
+ Then /I should see a link to "(.*)":(.*)/ do |text, expected_url|
39
+ observed_url = @browser.get_attribute("link=#{text}@href")
40
+ observed_url.should == expected_url
41
+ 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 es"
6
+ end
@@ -0,0 +1,17 @@
1
+ Característica: adición
2
+ Para evitar hacer errores tontos
3
+ Como contador
4
+ Quiero saber la suma de los números
5
+
6
+ Escenario: dos números
7
+ Dado que he introducido 5
8
+ Y he introducido 7
9
+ Cuando añado
10
+ Entonces el resultado debe ser 12
11
+
12
+ Escenario: tres números
13
+ Dado que he introducido 5
14
+ Y he introducido 7
15
+ Y he introducido 1
16
+ Cuando añado
17
+ Entonces el resultado debe ser 14
@@ -0,0 +1,22 @@
1
+ require 'spec'
2
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
3
+ require 'calculador'
4
+
5
+ Before do
6
+ @calc = Calculador.new
7
+ end
8
+
9
+ After do
10
+ end
11
+
12
+ Given /he introducido (\d+)/ do |n|
13
+ @calc.push n.to_i
14
+ end
15
+
16
+ When 'añado' do
17
+ @result = @calc.add
18
+ end
19
+
20
+ Then /el resultado debe ser (\d*)/ do |result|
21
+ @result.should == result.to_i
22
+ end
@@ -0,0 +1,11 @@
1
+ class Calculador
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,4 @@
1
+ $:.unshift(File.dirname(__FILE__) + '/../../lib')
2
+ require 'cucumber/rake/task'
3
+
4
+ Cucumber::Rake::Task.new
@@ -0,0 +1,5 @@
1
+ require 'spec'
2
+
3
+ Given "be_empty" do
4
+ [1,2].should_not be_empty
5
+ end
@@ -0,0 +1,7 @@
1
+ Feature: Cucumber
2
+ In order to have a happy user base
3
+ As a Cucumber user
4
+ I don't want no stinkin bugs
5
+
6
+ Scenario: RSpec be_*
7
+ Given be_empty
@@ -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: Search
2
+ In order to learn more
3
+ As an information seeker
4
+ I want to find more information
5
+
6
+ Scenario: Find what I'm looking for
7
+ Given I am on the Google search page
8
+ When I search for "rspec"
9
+ Then I should see a link to "RSpec-1.1.5: Overview":http://rspec.info/
@@ -0,0 +1,51 @@
1
+ require 'spec'
2
+
3
+ case PLATFORM
4
+ when /darwin/
5
+ require 'safariwatir'
6
+ Browser = Watir::Safari
7
+ when /win32|mingw/
8
+ require 'watir'
9
+ Browser = Watir::IE
10
+ when /java/
11
+ require 'celerity'
12
+ Browser = Celerity::Browser
13
+ else
14
+ raise "This platform is not supported (#{PLATFORM})"
15
+ end
16
+
17
+ Before do
18
+ @b = Browser.new
19
+ end
20
+
21
+ After do
22
+ @b.close
23
+ end
24
+
25
+ class GoogleSearch
26
+ def initialize(b)
27
+ @b = b
28
+ end
29
+
30
+ def goto
31
+ @b.goto 'http://www.google.com/'
32
+ end
33
+
34
+ def search(text)
35
+ @b.text_field(:name, 'q').set(text)
36
+ @b.button(:name, 'btnG').click
37
+ end
38
+ end
39
+
40
+ Given 'I am on the Google search page' do
41
+ @page = GoogleSearch.new(@b)
42
+ @page.goto
43
+ end
44
+
45
+ When /I search for "(.*)"/ do |query|
46
+ @page.search(query)
47
+ end
48
+
49
+ Then /I should see a link to "(.*)":(.*)/ do |text, url|
50
+ @b.link(:url, url).text.should == text
51
+ end
@@ -0,0 +1,8 @@
1
+ Feature: See features
2
+ In order to make Cucumber features more accessible
3
+ I should be able to see the existing features in a system
4
+
5
+ Scenario: See features as HTML
6
+ Given the feature server is running
7
+ When I visit "/features"
8
+ Then I should see a link to "See features"
@@ -0,0 +1,9 @@
1
+ Given /the feature server is running/ do
2
+ raise "TODO"
3
+ end
4
+
5
+ When /I visit "(.*)"/ do |resource|
6
+ end
7
+
8
+ Then /I should see a link to "(.*)"/ do |text|
9
+ end
@@ -0,0 +1,34 @@
1
+ desc 'Release the website and new gem version'
2
+ task :deploy => [:check_version, :website, :release] do
3
+ puts "Remember to create SVN tag:"
4
+ puts "svn copy svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/trunk " +
5
+ "svn+ssh://#{rubyforge_username}@rubyforge.org/var/svn/#{PATH}/tags/REL-#{VERS} "
6
+ puts "Suggested comment:"
7
+ puts "Tagging release #{CHANGES}"
8
+ end
9
+
10
+ desc 'Runs tasks website_generate and install_gem as a local deployment of the gem'
11
+ task :local_deploy => [:website_generate, :install_gem]
12
+
13
+ task :check_version do
14
+ unless ENV['VERSION']
15
+ puts 'Must pass a VERSION=x.y.z release version'
16
+ exit
17
+ end
18
+ unless ENV['VERSION'] == VERS
19
+ puts "Please update your version.rb to match the release version, currently #{VERS}"
20
+ exit
21
+ end
22
+ end
23
+
24
+ desc 'Install the package as a gem, without generating documentation(ri/rdoc)'
25
+ task :install_gem_no_doc => [:clean, :package] do
26
+ sh "#{'sudo ' unless Hoe::WINDOZE }gem install pkg/*.gem --no-rdoc --no-ri"
27
+ end
28
+
29
+ namespace :manifest do
30
+ desc 'Recreate Manifest.txt to include ALL files'
31
+ task :refresh do
32
+ `rake check_manifest | patch -p0 > Manifest.txt`
33
+ end
34
+ end
@@ -0,0 +1,7 @@
1
+ task :ruby_env do
2
+ RUBY_APP = if RUBY_PLATFORM =~ /java/
3
+ "jruby"
4
+ else
5
+ "ruby"
6
+ end unless defined? RUBY_APP
7
+ 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