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.
- data/History.txt +228 -0
- data/License.txt +20 -0
- data/Manifest.txt +226 -0
- data/README.txt +41 -0
- data/Rakefile +9 -0
- data/TODO.txt +26 -0
- data/bin/cucumber +5 -0
- data/config/hoe.rb +69 -0
- data/config/requirements.rb +15 -0
- data/cucumber.yml +1 -0
- data/examples/calculator_ruby_features/Rakefile +6 -0
- data/examples/calculator_ruby_features/features/addition.rb +23 -0
- data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +43 -0
- data/examples/cs/README.textile +22 -0
- data/examples/cs/Rakefile +12 -0
- data/examples/cs/features/hello.feature +11 -0
- data/examples/cs/features/step_definitons/hello_steps.rb +25 -0
- data/examples/cs/features/step_definitons/tree_steps.rb +14 -0
- data/examples/cs/features/tree.feature +9 -0
- data/examples/cs/src/Hello.cs +18 -0
- data/examples/dos_line_endings/Rakefile +6 -0
- data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
- data/examples/i18n/README.textile +18 -0
- data/examples/i18n/Rakefile +16 -0
- data/examples/i18n/ar/Rakefile +6 -0
- data/examples/i18n/ar/features/addition.feature +17 -0
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +31 -0
- data/examples/i18n/ar/lib/calculator.rb +10 -0
- data/examples/i18n/da/Rakefile +6 -0
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +22 -0
- data/examples/i18n/da/features/summering.feature +17 -0
- data/examples/i18n/da/lib/kalkulator.rb +11 -0
- data/examples/i18n/en/Rakefile +5 -0
- data/examples/i18n/en/features/addition.feature +17 -0
- data/examples/i18n/en/features/division.feature +10 -0
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +31 -0
- data/examples/i18n/en/lib/calculator.rb +14 -0
- data/examples/i18n/es/Rakefile +6 -0
- data/examples/i18n/es/features/adicion.feature +17 -0
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +22 -0
- data/examples/i18n/es/lib/calculador.rb +11 -0
- data/examples/i18n/et/Rakefile +6 -0
- data/examples/i18n/et/features/liitmine.feature +17 -0
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +26 -0
- data/examples/i18n/et/lib/kalkulaator.rb +10 -0
- data/examples/i18n/fr/Rakefile +6 -0
- data/examples/i18n/fr/features/addition.feature +13 -0
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +22 -0
- data/examples/i18n/fr/lib/calculatrice.rb +10 -0
- data/examples/i18n/id/Rakefile +6 -0
- data/examples/i18n/id/features/addition.feature +17 -0
- data/examples/i18n/id/features/division.feature +10 -0
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +31 -0
- data/examples/i18n/id/lib/calculator.rb +14 -0
- data/examples/i18n/it/Rakefile +6 -0
- data/examples/i18n/it/features/somma.feature +10 -0
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +22 -0
- data/examples/i18n/it/lib/calcolatrice.rb +11 -0
- data/examples/i18n/ja/README.txt +5 -0
- data/examples/i18n/ja/Rakefile +6 -0
- data/examples/i18n/ja/features/addition.feature +17 -0
- data/examples/i18n/ja/features/division.feature +10 -0
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +30 -0
- data/examples/i18n/ja/lib/calculator.rb +14 -0
- data/examples/i18n/no/Rakefile +6 -0
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +22 -0
- data/examples/i18n/no/features/summering.feature +17 -0
- data/examples/i18n/no/lib/kalkulator.rb +11 -0
- data/examples/i18n/pt/Rakefile +6 -0
- data/examples/i18n/pt/features/adicao.feature +10 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +22 -0
- data/examples/i18n/pt/lib/calculadora.rb +10 -0
- data/examples/i18n/ro/Rakefile +6 -0
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +22 -0
- data/examples/i18n/ro/features/suma.feature +10 -0
- data/examples/i18n/ro/lib/calculator.rb +11 -0
- data/examples/i18n/se/Rakefile +6 -0
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +22 -0
- data/examples/i18n/se/features/summering.feature +17 -0
- data/examples/i18n/se/lib/kalkulator.rb +11 -0
- data/examples/i18n/zh-CN/Rakefile +6 -0
- data/examples/i18n/zh-CN/features/addition.feature +17 -0
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/zh-CN/lib/calculator.rb +10 -0
- data/examples/java/README.textile +22 -0
- data/examples/java/Rakefile +12 -0
- data/examples/java/features/hello.feature +11 -0
- data/examples/java/features/step_definitons/hello_steps.rb +25 -0
- data/examples/java/features/step_definitons/tree_steps.rb +14 -0
- data/examples/java/features/tree.feature +9 -0
- data/examples/java/src/cucumber/demo/Hello.java +16 -0
- data/examples/selenium/Rakefile +6 -0
- data/examples/selenium/features/search.feature +9 -0
- data/examples/selenium/features/step_definitons/stories_steps.rb +41 -0
- data/examples/tickets/Rakefile +11 -0
- data/examples/tickets/cucumber.yml +2 -0
- data/examples/tickets/features/step_definitons/tickets_steps.rb +32 -0
- data/examples/tickets/features/tickets.feature +22 -0
- data/examples/watir/Rakefile +6 -0
- data/examples/watir/features/search.feature +9 -0
- data/examples/watir/features/step_definitons/stories_steps.rb +51 -0
- data/features/see_features.feature +8 -0
- data/features/steps/features_steps.rb +9 -0
- data/gem_tasks/deployment.rake +34 -0
- data/gem_tasks/environment.rake +7 -0
- data/gem_tasks/features.rake +6 -0
- data/gem_tasks/fix_cr_lf.rake +10 -0
- data/gem_tasks/flog.rake +4 -0
- data/gem_tasks/gemspec.rake +6 -0
- data/gem_tasks/rspec.rake +21 -0
- data/gem_tasks/treetop.rake +41 -0
- data/lib/autotest/cucumber.rb +6 -0
- data/lib/autotest/cucumber_mixin.rb +109 -0
- data/lib/autotest/cucumber_rails.rb +6 -0
- data/lib/autotest/cucumber_rails_rspec.rb +6 -0
- data/lib/autotest/cucumber_rspec.rb +6 -0
- data/lib/autotest/discover.rb +9 -0
- data/lib/cucumber.rb +39 -0
- data/lib/cucumber/broadcaster.rb +20 -0
- data/lib/cucumber/cli.rb +269 -0
- data/lib/cucumber/core_ext/proc.rb +54 -0
- data/lib/cucumber/core_ext/string.rb +22 -0
- data/lib/cucumber/executor.rb +170 -0
- data/lib/cucumber/formatters.rb +1 -0
- data/lib/cucumber/formatters/ansicolor.rb +111 -0
- data/lib/cucumber/formatters/autotest_formatter.rb +23 -0
- data/lib/cucumber/formatters/cucumber.css +132 -0
- data/lib/cucumber/formatters/cucumber.js +11 -0
- data/lib/cucumber/formatters/html_formatter.rb +128 -0
- data/lib/cucumber/formatters/jquery.js +32 -0
- data/lib/cucumber/formatters/pretty_formatter.rb +234 -0
- data/lib/cucumber/formatters/profile_formatter.rb +92 -0
- data/lib/cucumber/formatters/progress_formatter.rb +58 -0
- data/lib/cucumber/languages.yml +235 -0
- data/lib/cucumber/model.rb +1 -0
- data/lib/cucumber/model/table.rb +28 -0
- data/lib/cucumber/rails/rspec.rb +12 -0
- data/lib/cucumber/rails/world.rb +73 -0
- data/lib/cucumber/rake/task.rb +101 -0
- data/lib/cucumber/step_methods.rb +49 -0
- data/lib/cucumber/step_mother.rb +89 -0
- data/lib/cucumber/tree.rb +18 -0
- data/lib/cucumber/tree/feature.rb +61 -0
- data/lib/cucumber/tree/features.rb +21 -0
- data/lib/cucumber/tree/given_scenario.rb +13 -0
- data/lib/cucumber/tree/scenario.rb +158 -0
- data/lib/cucumber/tree/step.rb +134 -0
- data/lib/cucumber/tree/table.rb +26 -0
- data/lib/cucumber/tree/top_down_visitor.rb +23 -0
- data/lib/cucumber/treetop_parser/feature.treetop.erb +206 -0
- data/lib/cucumber/treetop_parser/feature_ar.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_cy.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_da.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_de.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_en.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_es.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_et.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_fr.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_id.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_it.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ja.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_nl.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_no.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
- data/lib/cucumber/treetop_parser/feature_pl.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_pt.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ro.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ro2.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_ru.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_se.rb +1591 -0
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1591 -0
- data/lib/cucumber/version.rb +9 -0
- data/rails_generators/cucumber/USAGE +11 -0
- data/rails_generators/cucumber/cucumber_generator.rb +30 -0
- data/rails_generators/cucumber/templates/cucumber +7 -0
- data/rails_generators/cucumber/templates/cucumber.rake +7 -0
- data/rails_generators/cucumber/templates/env.rb +8 -0
- data/rails_generators/cucumber/templates/webrat_steps.rb +46 -0
- data/rails_generators/feature/USAGE +12 -0
- data/rails_generators/feature/feature_generator.rb +16 -0
- data/rails_generators/feature/templates/feature.erb +28 -0
- data/rails_generators/feature/templates/steps.erb +22 -0
- data/script/console +10 -0
- data/script/console.cmd +1 -0
- data/script/destroy +14 -0
- data/script/destroy.cmd +1 -0
- data/script/generate +14 -0
- data/script/generate.cmd +1 -0
- data/script/txt2html +74 -0
- data/script/txt2html.cmd +1 -0
- data/setup.rb +1585 -0
- data/spec/cucumber/broadcaster_spec.rb +27 -0
- data/spec/cucumber/cli_spec.rb +242 -0
- data/spec/cucumber/core_ext/proc_spec.rb +45 -0
- data/spec/cucumber/core_ext/string_spec.rb +34 -0
- data/spec/cucumber/executor_spec.rb +222 -0
- data/spec/cucumber/formatters/ansicolor_spec.rb +35 -0
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +26 -0
- data/spec/cucumber/formatters/features.html +269 -0
- data/spec/cucumber/formatters/html_formatter_spec.rb +74 -0
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +204 -0
- data/spec/cucumber/formatters/profile_formatter_spec.rb +192 -0
- data/spec/cucumber/formatters/progress_formatter_spec.rb +65 -0
- data/spec/cucumber/model/table_spec.rb +20 -0
- data/spec/cucumber/rails/stubs/mini_rails.rb +17 -0
- data/spec/cucumber/rails/stubs/test_help.rb +1 -0
- data/spec/cucumber/rails/world_spec.rb +11 -0
- data/spec/cucumber/sell_cucumbers.feature +19 -0
- data/spec/cucumber/step_mother_spec.rb +74 -0
- data/spec/cucumber/tree/feature_spec.rb +12 -0
- data/spec/cucumber/tree/row_scenario_spec.rb +25 -0
- data/spec/cucumber/tree/scenario_spec.rb +76 -0
- data/spec/cucumber/tree/step_spec.rb +50 -0
- data/spec/cucumber/treetop_parser/empty_feature.feature +4 -0
- data/spec/cucumber/treetop_parser/empty_scenario.feature +9 -0
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +98 -0
- data/spec/cucumber/treetop_parser/fit_scenario.feature +8 -0
- data/spec/cucumber/treetop_parser/given_scenario.feature +9 -0
- data/spec/cucumber/treetop_parser/multiline_steps.feature +17 -0
- data/spec/cucumber/treetop_parser/multiple_tables.feature +29 -0
- data/spec/cucumber/treetop_parser/spaces.feature +10 -0
- data/spec/cucumber/treetop_parser/test_dos.feature +25 -0
- data/spec/cucumber/treetop_parser/with_comments.feature +10 -0
- data/spec/spec.opts +2 -0
- data/spec/spec_helper.rb +19 -0
- metadata +151 -35
data/README.txt
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
= Cucumber
|
2
|
+
|
3
|
+
* http://github.com/aslakhellesoy/cucumber
|
4
|
+
|
5
|
+
== DESCRIPTION:
|
6
|
+
|
7
|
+
Cucumber executes plain text documentation of code against that code.
|
8
|
+
Documentation: http://github.com/aslakhellesoy/cucumber/wikis/home
|
9
|
+
|
10
|
+
== REQUIREMENTS:
|
11
|
+
|
12
|
+
* FIX (list of requirements)
|
13
|
+
|
14
|
+
== INSTALL:
|
15
|
+
|
16
|
+
* gem install cucumber
|
17
|
+
|
18
|
+
== LICENSE:
|
19
|
+
|
20
|
+
(The MIT License)
|
21
|
+
|
22
|
+
Copyright (c) 2008 Aslak Hellesøy
|
23
|
+
|
24
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
25
|
+
a copy of this software and associated documentation files (the
|
26
|
+
'Software'), to deal in the Software without restriction, including
|
27
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
28
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
29
|
+
permit persons to whom the Software is furnished to do so, subject to
|
30
|
+
the following conditions:
|
31
|
+
|
32
|
+
The above copyright notice and this permission notice shall be
|
33
|
+
included in all copies or substantial portions of the Software.
|
34
|
+
|
35
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
36
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
37
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
38
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
39
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
40
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
41
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
ENV['NODOT'] = 'true' # We don't want class diagrams in RDoc
|
2
|
+
require 'config/requirements'
|
3
|
+
require 'config/hoe' # setup Hoe + all gem configuration
|
4
|
+
|
5
|
+
Dir['gem_tasks/**/*.rake'].each { |rake| load rake }
|
6
|
+
|
7
|
+
# Hoe gives us :default => :test, but we don't have Test::Unit tests.
|
8
|
+
Rake::Task[:default].clear_prerequisites
|
9
|
+
task :default => [:spec, :features]
|
data/TODO.txt
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
== FEATURES/PROBLEMS:
|
2
|
+
|
3
|
+
* TODO: OK Refactor: Extract explicit node classes with RDoc (for better API doc)
|
4
|
+
* TODO: OK Get rid of the compile method. Compile the parser in Rake.
|
5
|
+
* TODO: OK Make grammar support \r\n, \r and \n (Add some fixture features for that)
|
6
|
+
* TODO: OK Make grammar support indentation
|
7
|
+
* TODO: OK Make grammar be totally relaxed about narrative
|
8
|
+
* TODO: OK Add a yaml file for different languages
|
9
|
+
* TODO: OK Custom nodes for the syntax tree
|
10
|
+
* TODO: OK Actually execute the features
|
11
|
+
* TODO: Make rake run specs by default
|
12
|
+
* TODO: OK Make it work with pure ruby regexen
|
13
|
+
* TODO: OK Make it work with string steps
|
14
|
+
* TODO: bin/cucumber --require [dir|file|glob]* --language no --format [file]*
|
15
|
+
* TODO: OK Pending steps shold print a block of code that can be pasted into code
|
16
|
+
* TODO: cucumber --where "Some text from a step" that prints "__FILE__:__LINE__ (STEP PATTERN)"
|
17
|
+
* TODO: Customisable trace output (like javascriptlint)
|
18
|
+
* TODO: Experiment: Make $variables become @variables
|
19
|
+
* TODO: OK GivenScenario
|
20
|
+
* TODO: OK PureRuby
|
21
|
+
* Make two trees include accept mixin
|
22
|
+
* TODO: Call steps from steps
|
23
|
+
* TODO: i18n in ruby too
|
24
|
+
* TODO: Don't load any treetop files if no .feature files are found
|
25
|
+
* TODO: Summary prints execution time
|
26
|
+
* TODO: --nocolor option
|
data/bin/cucumber
ADDED
data/config/hoe.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require 'cucumber/version'
|
2
|
+
|
3
|
+
AUTHOR = 'Aslak Hellesøy' # can also be an array of Authors
|
4
|
+
EMAIL = "aslak.hellesoy@gmail.com"
|
5
|
+
DESCRIPTION = "Executable Feature scenarios"
|
6
|
+
GEM_NAME = 'cucumber' # what ppl will type to install your gem
|
7
|
+
HOMEPATH = "http://github.com/aslakhellesoy/cucumber"
|
8
|
+
RUBYFORGE_PROJECT = 'rspec'
|
9
|
+
|
10
|
+
@config_file = "~/.rubyforge/user-config.yml"
|
11
|
+
@config = nil
|
12
|
+
RUBYFORGE_USERNAME = "aslak_hellesoy"
|
13
|
+
def rubyforge_username
|
14
|
+
unless @config
|
15
|
+
begin
|
16
|
+
@config = YAML.load(File.read(File.expand_path(@config_file)))
|
17
|
+
rescue
|
18
|
+
puts <<-EOS
|
19
|
+
ERROR: No rubyforge config file found: #{@config_file}
|
20
|
+
Run 'rubyforge setup' to prepare your env for access to Rubyforge
|
21
|
+
- See http://newgem.rubyforge.org/rubyforge.html for more details
|
22
|
+
EOS
|
23
|
+
exit
|
24
|
+
end
|
25
|
+
end
|
26
|
+
RUBYFORGE_USERNAME.replace @config["username"]
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
REV = nil
|
31
|
+
# UNCOMMENT IF REQUIRED:
|
32
|
+
# REV = YAML.load(`svn info`)['Revision']
|
33
|
+
VERS = Cucumber::VERSION::STRING + (REV ? ".#{REV}" : "")
|
34
|
+
RDOC_OPTS = ['--quiet', '--title', 'Cucumber documentation',
|
35
|
+
"--opname", "index.html",
|
36
|
+
"--line-numbers",
|
37
|
+
"--main", "README.textile",
|
38
|
+
"--inline-source"]
|
39
|
+
|
40
|
+
class Hoe
|
41
|
+
def extra_deps
|
42
|
+
@extra_deps.reject! { |x| Array(x).first == 'hoe' }
|
43
|
+
@extra_deps
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# Generate all the Rake tasks
|
48
|
+
# Run 'rake -T' to see list of generated tasks (from gem root directory)
|
49
|
+
$hoe = Hoe.new(GEM_NAME, VERS) do |p|
|
50
|
+
p.developer(AUTHOR, EMAIL)
|
51
|
+
p.description = DESCRIPTION
|
52
|
+
p.summary = DESCRIPTION
|
53
|
+
p.url = HOMEPATH
|
54
|
+
p.rubyforge_name = RUBYFORGE_PROJECT if RUBYFORGE_PROJECT
|
55
|
+
p.clean_globs |= ['**/.*.sw?', '*.gem', '.config', '**/.DS_Store', '**/*.class', '**/*.jar'] #An array of file patterns to delete on clean.
|
56
|
+
|
57
|
+
# == Optional
|
58
|
+
p.changes = p.paragraphs_of("History.txt", 0..1).join("\n\n")
|
59
|
+
#p.extra_deps = [] # An array of rubygem dependencies [name, version], e.g. [ ['active_support', '>= 1.3.1'] ]
|
60
|
+
p.extra_deps = [ ['term-ansicolor', '>= 1.0.3'], ['treetop', '>= 1.2.4'], ['rspec', '>= 1.1.5'], ['diff-lcs', '>= 1.1.2'] ]
|
61
|
+
|
62
|
+
#p.spec_extras = {} # A hash of extra values to set in the gemspec.
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
CHANGES = $hoe.paragraphs_of('History.txt', 0..1).join("\\n\\n")
|
67
|
+
PATH = (RUBYFORGE_PROJECT == GEM_NAME) ? RUBYFORGE_PROJECT : "#{RUBYFORGE_PROJECT}/#{GEM_NAME}"
|
68
|
+
$hoe.remote_rdoc_dir = File.join(PATH.gsub(/^#{RUBYFORGE_PROJECT}\/?/,''), 'rdoc')
|
69
|
+
$hoe.rsync_args = '-av --delete --ignore-errors'
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
include FileUtils
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
%w[rake hoe].each do |req_gem|
|
6
|
+
begin
|
7
|
+
require req_gem
|
8
|
+
rescue LoadError
|
9
|
+
puts "This Rakefile requires the '#{req_gem}' RubyGem."
|
10
|
+
puts "Installation: gem install #{req_gem} -y"
|
11
|
+
exit
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
$:.unshift(File.join(File.dirname(__FILE__), %w[.. lib]))
|
data/cucumber.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
default: --format progress features
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'cucumber/cli' # Needed in order to run the feature with ruby
|
2
|
+
|
3
|
+
Feature %|Addition
|
4
|
+
In order to avoid silly mistakes
|
5
|
+
As a math idiot
|
6
|
+
I want to be told the sum of two numbers| do
|
7
|
+
|
8
|
+
Scenario "Add two numbers" do
|
9
|
+
Given "I have entered 50 into the calculator"
|
10
|
+
And "I have entered 70 into the calculator"
|
11
|
+
When "I add"
|
12
|
+
Then "the result should be 120 on the screen"
|
13
|
+
And "the result class should be Float"
|
14
|
+
end
|
15
|
+
|
16
|
+
Table do |t|
|
17
|
+
t | "input_1" | "input_2" | "output" | "class" | t
|
18
|
+
# This is kind of dumb - but it illustrates how scenarios can be "generated" in code.
|
19
|
+
10.times do |n|
|
20
|
+
t | n | n*2 | n*3 | Fixnum | t
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'spec'
|
2
|
+
|
3
|
+
class Calculator
|
4
|
+
def push(n)
|
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
|
17
|
+
|
18
|
+
Before do
|
19
|
+
@calc = Calculator.new
|
20
|
+
end
|
21
|
+
|
22
|
+
After do
|
23
|
+
end
|
24
|
+
|
25
|
+
Given /I have entered (\d+) into the calculator/ do |n|
|
26
|
+
@calc.push n.to_i
|
27
|
+
end
|
28
|
+
|
29
|
+
When 'I add' do
|
30
|
+
@result = @calc.add
|
31
|
+
end
|
32
|
+
|
33
|
+
When 'I divide' do
|
34
|
+
@result = @calc.divide
|
35
|
+
end
|
36
|
+
|
37
|
+
Then /the result should be (\d*) on the screen/ do |result|
|
38
|
+
@result.should == result.to_i
|
39
|
+
end
|
40
|
+
|
41
|
+
Then /the result class should be (\w*)/ do |class_name|
|
42
|
+
@result.class.name.should == class_name
|
43
|
+
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 "csc /target:library /out:Cucumber.Demo.dll src\\Hello.cs"
|
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 'dotnet'
|
4
|
+
loadLibrary 'Cucumber.Demo'
|
5
|
+
|
6
|
+
Given /my name is (\w+)/ do |name|
|
7
|
+
@hello = Hello.new # A .net 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.isFriend(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
|
+
require 'dotnet'
|
3
|
+
|
4
|
+
Given /I have an empty set/ do
|
5
|
+
@set = System.Collections.ArrayList.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,18 @@
|
|
1
|
+
using System;
|
2
|
+
|
3
|
+
namespace Cucumber.Demo {
|
4
|
+
public class Hello {
|
5
|
+
public string Greet(string who, string from) {
|
6
|
+
return "Hi, " + who + ". I'm " + from;
|
7
|
+
}
|
8
|
+
|
9
|
+
public bool IsFriend(string who) {
|
10
|
+
return true;
|
11
|
+
}
|
12
|
+
|
13
|
+
public string GetPhoneNumber(string who) {
|
14
|
+
return "99999";
|
15
|
+
//throw new Exception("My phone is secret!");
|
16
|
+
}
|
17
|
+
}
|
18
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
h1. Internationalisation (i18n) examples
|
2
|
+
|
3
|
+
Under this directory you'll find examples of Cucumber features written in
|
4
|
+
many of the natural languages Cucumber supports.
|
5
|
+
|
6
|
+
For a full list of what languages Cucumber supports - run <pre>cucumber --help</pre>
|
7
|
+
|
8
|
+
h2. Running all the examples
|
9
|
+
|
10
|
+
Open a shell in this directory and run
|
11
|
+
|
12
|
+
<pre>rake i18n</pre>
|
13
|
+
|
14
|
+
h2. Running examples for a specific language
|
15
|
+
|
16
|
+
Open a shell in the directory for the specific language and run
|
17
|
+
|
18
|
+
<pre>rake features</pre>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
desc 'Run features for all languages'
|
2
|
+
task :i18n do
|
3
|
+
dir = File.dirname(__FILE__)
|
4
|
+
Dir["#{dir}/*"].each do |f|
|
5
|
+
if File.directory?(f)
|
6
|
+
lang = f[dir.length+1..-1]
|
7
|
+
Dir.chdir(f) do
|
8
|
+
rake("features")
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def rake(args)
|
15
|
+
ruby(File.join(Gem.bindir, 'rake'), args)
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
خاصية: الجمع
|
2
|
+
من اجل تجنب الأخطاء السخيفة
|
3
|
+
كشخص غبي في الرياضيات
|
4
|
+
اريد معرفة ناتج جمع عددين
|
5
|
+
|
6
|
+
سيناريو: جمع عددين
|
7
|
+
بفرض كتابة ٥٠ في الآلة الحاسبة
|
8
|
+
و كتابة ٧٠ في الآلة الحاسبة
|
9
|
+
متى يتم الضغط على جمع
|
10
|
+
اذاً يظهر ١٢ على الشاشة
|
11
|
+
و الناتج يجب ان يكون Fixnum
|
12
|
+
|
13
|
+
امثلة اكثر:
|
14
|
+
| input_1 | input_2 | button | output | class |
|
15
|
+
| 20 | 30 | جمع | 50 | Fixnum |
|
16
|
+
| 2 | 5 | جمع | 7 | Fixnum |
|
17
|
+
| 0 | 40 | جمع | 40 | Fixnum |
|