kosmas58-cucumber 0.1.16.6 → 0.1.99.21
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.
- data/History.txt +126 -2
- data/License.txt +1 -1
- data/Manifest.txt +0 -270
- data/Rakefile +1 -1
- data/bin/cucumber +2 -2
- data/config/hoe.rb +7 -2
- data/examples/cs/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/README.textile +1 -1
- data/examples/i18n/Rakefile +3 -3
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -6
- data/examples/i18n/da/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/de/features/addition.feature +6 -6
- data/examples/i18n/de/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/en/features/addition.feature +6 -6
- data/examples/i18n/en/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/es/features/adicion.feature +11 -12
- data/examples/i18n/es/features/step_definitons/calculador_steps.rb +7 -10
- data/examples/i18n/es/lib/calculador.rb +4 -1
- data/examples/i18n/et/features/liitmine.feature +7 -6
- data/examples/i18n/et/features/step_definitions/kalkulaator_steps.rb +1 -1
- data/examples/i18n/fi/features/step_definitons/laskin_steps.rb +1 -1
- data/examples/i18n/fi/features/yhteenlasku.feature +2 -2
- data/examples/i18n/fr/features/addition.feature +2 -2
- data/examples/i18n/fr/features/step_definitions/calculatrice_steps.rb +1 -1
- data/examples/i18n/id/features/addition.feature +6 -6
- data/examples/i18n/id/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/it/features/step_definitons/calcolatrice_steps.rb +1 -1
- data/examples/i18n/ja/features/step_definitons/calculator_steps.rb +2 -3
- data/examples/i18n/ko/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/lt/features/addition.feature +7 -6
- data/examples/i18n/lt/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/i18n/no/features/step_definitons/kalkulator_steps.rb +7 -7
- data/examples/i18n/no/features/summering.feature +1 -0
- data/examples/i18n/pt/features/step_definitions/calculadora_steps.rb +1 -1
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/se/features/step_definitons/kalkulator_steps.rb +1 -1
- data/examples/i18n/zh-CN/features/step_definitons/calculator_steps.rb +2 -2
- data/examples/java/src/cucumber/demo/Hello.java +16 -0
- data/examples/jbehave/README.textile +17 -0
- data/examples/jbehave/features/support/env.rb +7 -0
- data/examples/jbehave/features/trading.feature +24 -0
- data/examples/jbehave/pom.xml +48 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/converters/TraderConverter.java +32 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Stock.java +42 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/model/Trader.java +29 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/persistence/TraderPersister.java +22 -0
- data/examples/jbehave/src/main/java/cukes/jbehave/examples/trader/scenarios/TraderSteps.java +65 -0
- data/examples/self_test/README.textile +4 -1
- data/examples/{calculator_ruby_features → self_test}/Rakefile +3 -3
- data/examples/self_test/features/background/failing_background.feature +10 -0
- data/examples/self_test/features/background/failing_background_after_success.feature +11 -0
- data/examples/self_test/features/background/multiline_args_background.feature +32 -0
- data/examples/self_test/features/background/passing_background.feature +10 -0
- data/examples/self_test/features/background/pending_background.feature +10 -0
- data/examples/self_test/features/background/scenario_outline_failing_background.feature +16 -0
- data/examples/self_test/features/background/scenario_outline_passing_background.feature +16 -0
- data/examples/self_test/features/call_undefined_step_from_step_def.feature +7 -0
- data/examples/self_test/features/lots_of_undefined.feature +8 -0
- data/examples/self_test/features/outline_sample.feature +11 -5
- data/examples/self_test/features/sample.feature +8 -3
- data/examples/self_test/features/step_definitions/sample_steps.rb +53 -4
- data/examples/self_test/features/support/env.rb +1 -0
- data/examples/self_test/features/support/tag_count_formatter.rb +25 -0
- data/examples/tickets/features/172.feature +28 -0
- data/examples/tickets/features/177/1.feature +29 -0
- data/examples/tickets/features/177/2.feature +21 -0
- data/examples/tickets/features/177/3.feature +18 -0
- data/examples/tickets/features/180.feature +7 -0
- data/examples/tickets/features/scenario_outline.feature +6 -1
- data/examples/tickets/features/step_definitons/tickets_steps.rb +27 -3
- data/examples/tickets/features/tickets.feature +4 -0
- data/features/background.feature +223 -0
- data/features/cucumber_cli.feature +218 -98
- data/features/cucumber_cli_outlines.feature +54 -37
- data/features/custom_formatter.feature +11 -0
- data/features/report_called_undefined_steps.feature +32 -0
- data/features/step_definitions/cucumber_steps.rb +7 -3
- data/features/step_definitions/extra_steps.rb +1 -1
- data/features/support/env.rb +2 -1
- data/gem_tasks/flog.rake +1 -1
- data/gem_tasks/gemspec.rake +2 -2
- data/gem_tasks/jar.rake +67 -0
- data/lib/autotest/cucumber_mixin.rb +17 -23
- data/lib/cucumber.rb +63 -11
- data/lib/cucumber/ast.rb +29 -0
- data/lib/cucumber/ast/background.rb +88 -0
- data/lib/cucumber/ast/comment.rb +26 -0
- data/lib/cucumber/ast/examples.rb +26 -0
- data/lib/cucumber/ast/feature.rb +66 -0
- data/lib/cucumber/ast/features.rb +39 -0
- data/lib/cucumber/ast/filter.rb +22 -0
- data/lib/cucumber/ast/outline_table.rb +49 -0
- data/lib/cucumber/ast/py_string.rb +52 -0
- data/lib/cucumber/ast/scenario.rb +103 -0
- data/lib/cucumber/ast/scenario_outline.rb +92 -0
- data/lib/cucumber/ast/step.rb +161 -0
- data/lib/cucumber/ast/steps.rb +13 -0
- data/lib/cucumber/ast/table.rb +218 -0
- data/lib/cucumber/ast/tags.rb +40 -0
- data/lib/cucumber/ast/visitor.rb +109 -0
- data/lib/cucumber/broadcaster.rb +1 -6
- data/lib/cucumber/cli/configuration.rb +339 -0
- data/lib/cucumber/cli/language_help_formatter.rb +59 -0
- data/lib/cucumber/cli/main.rb +100 -0
- data/lib/cucumber/core_ext/exception.rb +41 -8
- data/lib/cucumber/core_ext/instance_exec.rb +54 -0
- data/lib/cucumber/core_ext/proc.rb +29 -65
- data/lib/cucumber/core_ext/string.rb +19 -0
- data/lib/cucumber/formatter.rb +1 -0
- data/lib/cucumber/{formatters → formatter}/ansicolor.rb +14 -16
- data/lib/cucumber/formatter/color_io.rb +17 -0
- data/lib/cucumber/formatter/console.rb +119 -0
- data/lib/cucumber/formatter/cucumber.css +55 -0
- data/lib/cucumber/formatter/cucumber.sass +49 -0
- data/lib/cucumber/formatter/html.rb +121 -0
- data/lib/cucumber/formatter/pretty.rb +167 -0
- data/lib/cucumber/formatter/profile.rb +77 -0
- data/lib/cucumber/formatter/progress.rb +68 -0
- data/lib/cucumber/formatter/rerun.rb +35 -0
- data/lib/cucumber/formatter/unicode.rb +35 -0
- data/lib/cucumber/formatters/unicode.rb +2 -35
- data/lib/cucumber/jbehave.rb +102 -0
- data/lib/cucumber/languages.yml +128 -75
- data/lib/cucumber/parser.rb +43 -0
- data/lib/cucumber/parser/basic.rb +0 -0
- data/lib/cucumber/parser/feature.rb +1490 -0
- data/lib/cucumber/parser/feature.tt +188 -0
- data/lib/cucumber/parser/i18n.tt +31 -0
- data/lib/cucumber/parser/table.rb +402 -0
- data/lib/cucumber/parser/table.tt +59 -0
- data/lib/cucumber/parser/treetop_ext.rb +75 -0
- data/lib/cucumber/platform.rb +3 -17
- data/lib/cucumber/rails/rspec.rb +5 -2
- data/lib/cucumber/step_definition.rb +87 -0
- data/lib/cucumber/step_mother.rb +151 -66
- data/lib/cucumber/version.rb +2 -2
- data/rails_generators/cucumber/USAGE +3 -2
- data/rails_generators/cucumber/cucumber_generator.rb +33 -23
- data/rails_generators/cucumber/templates/cucumber +2 -1
- data/rails_generators/cucumber/templates/cucumber.rake +6 -1
- data/rails_generators/cucumber/templates/env.rb +1 -1
- data/rails_generators/feature/USAGE +3 -0
- data/rails_generators/feature/feature_generator.rb +30 -6
- data/spec/cucumber/ast/background_spec.rb +58 -0
- data/spec/cucumber/ast/feature_factory.rb +54 -0
- data/spec/cucumber/ast/feature_spec.rb +60 -0
- data/spec/cucumber/ast/py_string_spec.rb +40 -0
- data/spec/cucumber/ast/scenario_outline_spec.rb +64 -0
- data/spec/cucumber/ast/scenario_spec.rb +82 -0
- data/spec/cucumber/ast/step_spec.rb +45 -0
- data/spec/cucumber/ast/table_spec.rb +81 -0
- data/spec/cucumber/ast/tags_spec.rb +23 -0
- data/spec/cucumber/broadcaster_spec.rb +4 -17
- data/spec/cucumber/cli/configuration_spec.rb +239 -0
- data/spec/cucumber/cli/main_spec.rb +164 -0
- data/spec/cucumber/core_ext/proc_spec.rb +27 -35
- data/spec/cucumber/core_ext/string_spec.rb +8 -0
- data/spec/cucumber/{formatters → formatter}/ansicolor_spec.rb +2 -2
- data/spec/cucumber/formatter/html/cucumber.css +37 -0
- data/spec/cucumber/formatter/html/cucumber.js +13 -0
- data/spec/cucumber/formatter/html/index.html +45 -0
- data/spec/cucumber/formatter/html/jquery-1.3.min.js +19 -0
- data/spec/cucumber/formatter/html/jquery.uitableedit.js +100 -0
- data/spec/cucumber/formatters/profile_formatter_spec.rb +17 -16
- data/spec/cucumber/parser/feature_parser_spec.rb +281 -0
- data/spec/cucumber/parser/table_parser_spec.rb +48 -0
- data/spec/cucumber/step_definition_spec.rb +62 -0
- data/spec/cucumber/step_mother_spec.rb +50 -51
- data/spec/cucumber/treetop_parser/empty_feature.feature +1 -1
- data/spec/cucumber/treetop_parser/scenario_outline.feature +1 -1
- data/spec/cucumber/treetop_parser/spaces.feature +3 -1
- data/spec/cucumber/treetop_parser/with_comments.feature +1 -1
- data/spec/cucumber/treetop_parser/with_tags.feature +18 -0
- data/spec/cucumber/world/pending_spec.rb +13 -12
- data/spec/spec_helper.rb +1 -1
- metadata +107 -79
- data/examples/calculator_ruby_features/features/addition.rb +0 -39
- data/examples/calculator_ruby_features/features/step_definitons/calculator_steps.rb +0 -43
- data/gem_tasks/treetop.rake +0 -41
- data/lib/cucumber/cli.rb +0 -355
- data/lib/cucumber/executor.rb +0 -205
- data/lib/cucumber/formatters.rb +0 -1
- data/lib/cucumber/formatters/autotest_formatter.rb +0 -23
- data/lib/cucumber/formatters/cucumber.css +0 -132
- data/lib/cucumber/formatters/cucumber.js +0 -11
- data/lib/cucumber/formatters/html_formatter.rb +0 -152
- data/lib/cucumber/formatters/jquery.js +0 -32
- data/lib/cucumber/formatters/pretty_formatter.rb +0 -285
- data/lib/cucumber/formatters/profile_formatter.rb +0 -92
- data/lib/cucumber/formatters/progress_formatter.rb +0 -61
- data/lib/cucumber/model.rb +0 -1
- data/lib/cucumber/model/table.rb +0 -32
- data/lib/cucumber/step_methods.rb +0 -49
- data/lib/cucumber/tree.rb +0 -16
- data/lib/cucumber/tree/feature.rb +0 -105
- data/lib/cucumber/tree/features.rb +0 -21
- data/lib/cucumber/tree/given_scenario.rb +0 -13
- data/lib/cucumber/tree/scenario.rb +0 -240
- data/lib/cucumber/tree/step.rb +0 -173
- data/lib/cucumber/tree/table.rb +0 -26
- data/lib/cucumber/tree/top_down_visitor.rb +0 -23
- data/lib/cucumber/treetop_parser/feature.treetop.erb +0 -254
- data/lib/cucumber/treetop_parser/feature_ar.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_cy.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_da.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_de.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en-lol.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_en.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_es.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_et.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_fi.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_fr.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_id.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_it.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ja.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ko.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_lt.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_nl.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_no.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_parser.rb +0 -36
- data/lib/cucumber/treetop_parser/feature_pl.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_pt.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ro.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ro2.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_ru.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_se.rb +0 -1951
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +0 -1951
- data/lib/cucumber/world.rb +0 -1
- data/lib/cucumber/world/pending.rb +0 -22
- data/setup.rb +0 -1585
- data/spec/cucumber/cli_spec.rb +0 -521
- data/spec/cucumber/executor_spec.rb +0 -382
- data/spec/cucumber/formatters/autotest_formatter_spec.rb +0 -26
- data/spec/cucumber/formatters/features.html +0 -269
- data/spec/cucumber/formatters/html_formatter_spec.rb +0 -110
- data/spec/cucumber/formatters/pretty_formatter_spec.rb +0 -410
- data/spec/cucumber/formatters/progress_formatter_spec.rb +0 -81
- data/spec/cucumber/model/table_spec.rb +0 -32
- data/spec/cucumber/tree/feature_spec.rb +0 -122
- data/spec/cucumber/tree/row_scenario_outline_spec.rb +0 -73
- data/spec/cucumber/tree/row_scenario_spec.rb +0 -55
- data/spec/cucumber/tree/row_step_outline_spec.rb +0 -38
- data/spec/cucumber/tree/scenario_outline_spec.rb +0 -50
- data/spec/cucumber/tree/scenario_spec.rb +0 -134
- data/spec/cucumber/tree/step_outline_spec.rb +0 -17
- data/spec/cucumber/tree/step_spec.rb +0 -59
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +0 -120
data/lib/cucumber/version.rb
CHANGED
@@ -7,7 +7,8 @@ Description:
|
|
7
7
|
Also see the feature generator, which you can use to generate skeletons
|
8
8
|
for new features.
|
9
9
|
|
10
|
-
If you set
|
10
|
+
If you set the language option, then a subdirectory features/[language] will be generated instead.
|
11
|
+
Now your are able to use features in different languages.
|
11
12
|
|
12
13
|
Examples:
|
13
|
-
`./script/generate cucumber
|
14
|
+
`./script/generate cucumber`
|
@@ -1,29 +1,34 @@
|
|
1
|
-
require
|
1
|
+
require "rbconfig"
|
2
2
|
|
3
3
|
# This generator bootstraps a Rails project for use with Cucumber
|
4
|
-
class CucumberGenerator < Rails::Generator::Base
|
5
|
-
DEFAULT_SHEBANG = File.join(Config::CONFIG[
|
6
|
-
Config::CONFIG[
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
super
|
4
|
+
class CucumberGenerator < Rails::Generator::Base
|
5
|
+
DEFAULT_SHEBANG = File.join(Config::CONFIG["bindir"],
|
6
|
+
Config::CONFIG["ruby_install_name"])
|
7
|
+
|
8
|
+
attr_reader :language
|
9
|
+
|
10
|
+
def initialize(runtime_args, runtime_options = {})
|
11
|
+
super
|
12
|
+
@features_path = "features"
|
12
13
|
end
|
13
14
|
|
14
|
-
def manifest
|
15
|
+
def manifest
|
16
|
+
if options[:language]
|
17
|
+
@language = options[:language]
|
18
|
+
set_language(@language)
|
19
|
+
end
|
15
20
|
record do |m|
|
16
|
-
m.directory File.join(@features_path,
|
17
|
-
m.file
|
21
|
+
m.directory File.join(@features_path, "step_definitions")
|
22
|
+
m.file "webrat_steps.rb", File.join(@features_path, "step_definitions", "webrat_steps.rb")
|
18
23
|
|
19
|
-
m.directory
|
20
|
-
m.file
|
21
|
-
m.file
|
24
|
+
m.directory "features/support"
|
25
|
+
m.file "env.rb", "features/support/env.rb"
|
26
|
+
m.file "paths.rb", "features/support/paths.rb"
|
22
27
|
|
23
|
-
m.directory
|
24
|
-
m.
|
28
|
+
m.directory "lib/tasks"
|
29
|
+
m.template "cucumber.rake", "lib/tasks/cucumber.rake"
|
25
30
|
|
26
|
-
m.file
|
31
|
+
m.file "cucumber", "script/cucumber", {
|
27
32
|
:chmod => 0755, :shebang => options[:shebang] == DEFAULT_SHEBANG ? nil : options[:shebang]
|
28
33
|
}
|
29
34
|
end
|
@@ -32,13 +37,18 @@ class CucumberGenerator < Rails::Generator::Base
|
|
32
37
|
protected
|
33
38
|
|
34
39
|
def banner
|
35
|
-
"Usage: #{$0} cucumber
|
40
|
+
"Usage: #{$0} cucumber"
|
36
41
|
end
|
37
|
-
|
42
|
+
|
43
|
+
def add_options!(opt)
|
44
|
+
opt.separator ""
|
45
|
+
opt.separator "Options:"
|
46
|
+
opt.on("-l", "--language=lang", String, "Use a [language] subdirectoy in /features.") { |v| options[:language] = v }
|
47
|
+
end
|
48
|
+
|
38
49
|
# Load up the transations for the passed language, and modify the features_path accordingly
|
39
50
|
def set_language(language)
|
40
|
-
@
|
41
|
-
@features_path = File.join(@features_path, @language) if @language
|
51
|
+
@features_path = File.join(@features_path, language)
|
42
52
|
end
|
43
|
-
|
53
|
+
|
44
54
|
end
|
@@ -1,7 +1,8 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
begin
|
3
3
|
load File.expand_path(File.dirname(__FILE__) + "/../vendor/plugins/cucumber/bin/cucumber")
|
4
|
-
rescue LoadError
|
4
|
+
rescue LoadError => e
|
5
|
+
raise unless e.to_s =~ /cucumber/
|
5
6
|
require "rubygems"
|
6
7
|
load File.join(Gem.bindir, "cucumber")
|
7
8
|
end
|
@@ -2,6 +2,11 @@ $:.unshift(RAILS_ROOT + '/vendor/plugins/cucumber/lib')
|
|
2
2
|
require 'cucumber/rake/task'
|
3
3
|
|
4
4
|
Cucumber::Rake::Task.new(:features) do |t|
|
5
|
-
|
5
|
+
<% if language %>
|
6
|
+
t.language = "<%= language%>"
|
7
|
+
t.cucumber_opts = "--format pretty --language <%= language%>"
|
8
|
+
<% else %>
|
9
|
+
t.cucumber_opts = "--format pretty"
|
10
|
+
<% end %>
|
6
11
|
end
|
7
12
|
task :features => 'db:test:prepare'
|
@@ -1,5 +1,5 @@
|
|
1
1
|
# Sets up the Rails environment for Cucumber
|
2
|
-
ENV["RAILS_ENV"]
|
2
|
+
ENV["RAILS_ENV"] ||= "test"
|
3
3
|
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
|
4
4
|
require 'cucumber/rails/world'
|
5
5
|
require 'cucumber/formatters/unicode' # Comment out this line if you don't want Cucumber Unicode support
|
@@ -7,6 +7,9 @@ Description:
|
|
7
7
|
This generator can take an optional list of attribute pairs similar to Rails'
|
8
8
|
built-in resource generator.
|
9
9
|
|
10
|
+
If you set the language option, then a subdirectory features/[language] will be generated instead.
|
11
|
+
Now your are able to use features in different languages.
|
12
|
+
|
10
13
|
Examples:
|
11
14
|
`./script/generate feature post` # no attributes
|
12
15
|
`./script/generate feature post title:string body:text published:boolean`
|
@@ -1,10 +1,22 @@
|
|
1
1
|
# This generator bootstraps a Rails project for use with Cucumber
|
2
2
|
class FeatureGenerator < Rails::Generator::NamedBase
|
3
|
-
|
3
|
+
attr_reader :language
|
4
|
+
|
5
|
+
def initialize(runtime_args, runtime_options = {})
|
6
|
+
super
|
7
|
+
@features_path = "features"
|
8
|
+
end
|
9
|
+
|
10
|
+
def manifest
|
11
|
+
if options[:language]
|
12
|
+
@language = options[:language]
|
13
|
+
set_language(@language)
|
14
|
+
end
|
15
|
+
|
4
16
|
record do |m|
|
5
|
-
m.directory
|
6
|
-
m.template
|
7
|
-
m.template
|
17
|
+
m.directory File.join(@features_path, "step_definitions")
|
18
|
+
m.template "feature.erb", File.join(@features_path, "manage_#{plural_name}.feature")
|
19
|
+
m.template "steps.erb", File.join(@features_path, "step_definitions", "#{singular_name}_steps.rb")
|
8
20
|
end
|
9
21
|
end
|
10
22
|
|
@@ -12,11 +24,11 @@ class FeatureGenerator < Rails::Generator::NamedBase
|
|
12
24
|
attr_reader :name
|
13
25
|
|
14
26
|
def initialize(s)
|
15
|
-
@name, @type = *s.split(
|
27
|
+
@name, @type = *s.split(":")
|
16
28
|
end
|
17
29
|
|
18
30
|
def value(n)
|
19
|
-
if @type ==
|
31
|
+
if @type == "boolean"
|
20
32
|
(n % 2) == 0
|
21
33
|
else
|
22
34
|
"#{@name} #{n}"
|
@@ -33,4 +45,16 @@ class FeatureGenerator < Rails::Generator::NamedBase
|
|
33
45
|
def banner
|
34
46
|
"Usage: #{$0} feature ModelName [field:type, field:type]"
|
35
47
|
end
|
48
|
+
|
49
|
+
def add_options!(opt)
|
50
|
+
opt.separator ""
|
51
|
+
opt.separator "Options:"
|
52
|
+
opt.on("-l", "--language=lang", String, "Use a [language] subdirectoy in /features.") { |v| options[:language] = v }
|
53
|
+
end
|
54
|
+
|
55
|
+
# Load up the transations for the passed language, and modify the features_path accordingly
|
56
|
+
def set_language(language)
|
57
|
+
@features_path = File.join(@features_path, language)
|
58
|
+
end
|
59
|
+
|
36
60
|
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/ast'
|
3
|
+
|
4
|
+
module Cucumber
|
5
|
+
module Ast
|
6
|
+
describe Background do
|
7
|
+
|
8
|
+
it "should visit a step on the first background run" do
|
9
|
+
step = Step.new(7, "Given", "passing")
|
10
|
+
background = Background.new(
|
11
|
+
comment=Comment.new(""),
|
12
|
+
line=99,
|
13
|
+
keyword="",
|
14
|
+
steps=[
|
15
|
+
step
|
16
|
+
])
|
17
|
+
visitor = mock('visitor', :null_object => true)
|
18
|
+
|
19
|
+
visitor.should_receive(:visit_step).with(step)
|
20
|
+
|
21
|
+
background.accept(visitor)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "having already visited background once" do
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
@mock_step = mock('step', :null_object => true, :text_length => 1)
|
28
|
+
@background = Background.new(
|
29
|
+
comment=Comment.new(""),
|
30
|
+
line=99,
|
31
|
+
keyword="",
|
32
|
+
steps=[
|
33
|
+
@mock_step
|
34
|
+
])
|
35
|
+
|
36
|
+
@visitor = mock('visitor', :null_object => true)
|
37
|
+
@background.accept(@visitor)
|
38
|
+
end
|
39
|
+
|
40
|
+
it "should execute the steps" do
|
41
|
+
@mock_step.should_receive(:execute_as_new).and_return(mock('executed step', :null_object => true))
|
42
|
+
|
43
|
+
@background.accept(@visitor)
|
44
|
+
end
|
45
|
+
|
46
|
+
it "should visit the background if there was a exception when executing a step" do
|
47
|
+
mock_executed_step = mock('executed step', :null_object => true, :exception => Exception.new)
|
48
|
+
@mock_step.stub!(:execute_as_new).and_return(mock_executed_step)
|
49
|
+
|
50
|
+
@visitor.should_receive(:visit_background).with(@background)
|
51
|
+
|
52
|
+
@background.accept(@visitor)
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'cucumber/ast'
|
2
|
+
require 'cucumber/step_mother'
|
3
|
+
|
4
|
+
module Cucumber
|
5
|
+
module Ast
|
6
|
+
module FeatureFactory
|
7
|
+
class MyWorld
|
8
|
+
def flunk
|
9
|
+
raise "I flunked"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def create_feature(step_mother)
|
14
|
+
step_mother.extend(StepMother)
|
15
|
+
step_mother.Given /^a (.*) step with an inline arg:$/ do |what, table|
|
16
|
+
end
|
17
|
+
step_mother.Given /^a (.*) step$/ do |what|
|
18
|
+
flunk if what == 'failing'
|
19
|
+
end
|
20
|
+
step_mother.World do
|
21
|
+
MyWorld.new
|
22
|
+
end
|
23
|
+
|
24
|
+
table = Ast::Table.new([
|
25
|
+
%w{1 22 333},
|
26
|
+
%w{4444 55555 666666}
|
27
|
+
])
|
28
|
+
py_string = Ast::PyString.new(21, 22, %{
|
29
|
+
I like
|
30
|
+
Cucumber sandwich
|
31
|
+
}, 10)
|
32
|
+
f = Ast::Feature.new(
|
33
|
+
Ast::Comment.new("# My feature comment\n"),
|
34
|
+
Ast::Tags.new(6, ['one', 'two']),
|
35
|
+
"Pretty printing",
|
36
|
+
[Ast::Scenario.new(
|
37
|
+
Ast::Comment.new(" # My scenario comment \n# On two lines \n"),
|
38
|
+
Ast::Tags.new(8, ['three', 'four']),
|
39
|
+
9,
|
40
|
+
"Scenario:", "A Scenario",
|
41
|
+
[
|
42
|
+
Step.new(10, "Given", "a passing step with an inline arg:", table),
|
43
|
+
Step.new(11, "Given", "a happy step with an inline arg:", py_string),
|
44
|
+
Step.new(12, "Given", "a failing step")
|
45
|
+
]
|
46
|
+
)]
|
47
|
+
)
|
48
|
+
f.file = 'features/pretty_printing.feature'
|
49
|
+
f.features = Features.new(Filter.new({:tags => []}))
|
50
|
+
f
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/ast/feature_factory'
|
3
|
+
|
4
|
+
module Cucumber
|
5
|
+
module Ast
|
6
|
+
describe Feature do
|
7
|
+
include FeatureFactory
|
8
|
+
|
9
|
+
it "should convert to sexp" do
|
10
|
+
feature = create_feature(Object.new)
|
11
|
+
feature.to_sexp.should ==
|
12
|
+
[:feature,
|
13
|
+
"Pretty printing",
|
14
|
+
[:comment, "# My feature comment\n"],
|
15
|
+
[:tag, "one"],
|
16
|
+
[:tag, "two"],
|
17
|
+
[:scenario, 9, "Scenario:",
|
18
|
+
"A Scenario",
|
19
|
+
[:comment, " # My scenario comment \n# On two lines \n"],
|
20
|
+
[:tag, "three"],
|
21
|
+
[:tag, "four"],
|
22
|
+
[:step, 10, "Given", "a passing step with an inline arg:",
|
23
|
+
[:table,
|
24
|
+
[:row,
|
25
|
+
[:cell, "1"], [:cell, "22"], [:cell, "333"]],
|
26
|
+
[:row,
|
27
|
+
[:cell, "4444"], [:cell, "55555"], [:cell, "666666"]]]],
|
28
|
+
[:step, 11, "Given", "a happy step with an inline arg:",
|
29
|
+
[:py_string, "\n I like\nCucumber sandwich\n"]],
|
30
|
+
[:step, 12, "Given", "a failing step"]]]
|
31
|
+
end
|
32
|
+
|
33
|
+
it "should only visit scenarios that match" do
|
34
|
+
s1 = mock("Scenario 1")
|
35
|
+
s2 = mock("Scenario 2")
|
36
|
+
s3 = mock("Scenario 3")
|
37
|
+
[s1, s2, s3].each{|s| s.should_receive(:feature=)}
|
38
|
+
f = Ast::Feature.new(
|
39
|
+
Ast::Comment.new(""),
|
40
|
+
Ast::Tags.new(22, []),
|
41
|
+
"My feature",
|
42
|
+
[s1, s2, s3]
|
43
|
+
)
|
44
|
+
features = mock('Features')
|
45
|
+
f.features = features
|
46
|
+
|
47
|
+
f.lines = [33]
|
48
|
+
|
49
|
+
features.should_receive(:visit?).with(s1, [33]).and_return(false)
|
50
|
+
features.should_receive(:visit?).with(s2, [33]).and_return(true)
|
51
|
+
features.should_receive(:visit?).with(s3, [33]).and_return(false)
|
52
|
+
|
53
|
+
s2.should_receive(:accept)
|
54
|
+
|
55
|
+
visitor = Visitor.new(nil)
|
56
|
+
visitor.visit_feature(f)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/ast/py_string'
|
3
|
+
|
4
|
+
module Cucumber
|
5
|
+
module Ast
|
6
|
+
describe PyString do
|
7
|
+
it "should handle unindented" do
|
8
|
+
ps = PyString.new(10, 13, "4.1\n4.2\n", 0)
|
9
|
+
ps.to_s.should == "4.1\n4.2\n"
|
10
|
+
end
|
11
|
+
|
12
|
+
it "should handle indented" do
|
13
|
+
# """
|
14
|
+
ps = PyString.new(10, 13, " 4.1\n 4.2\n", 2)
|
15
|
+
ps.to_s.should == " 4.1\n 4.2\n"
|
16
|
+
end
|
17
|
+
|
18
|
+
describe "replacing arguments" do
|
19
|
+
|
20
|
+
before(:each) do
|
21
|
+
@ps = PyString.new(10, 13, "<book>\n<qty>\n", 0)
|
22
|
+
end
|
23
|
+
|
24
|
+
it "should return a new py_string with arguments replaced with values" do
|
25
|
+
py_string_with_replaced_arg = @ps.arguments_replaced({'<book>' => 'Life is elsewhere', '<qty>' => '5'})
|
26
|
+
|
27
|
+
py_string_with_replaced_arg.to_s.should == "Life is elsewhere\n5\n"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "should not change the original py_string" do
|
31
|
+
py_string_with_replaced_arg = @ps.arguments_replaced({'<book>' => 'Life is elsewhere'})
|
32
|
+
|
33
|
+
@ps.to_s.should_not include("Life is elsewhere")
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../../spec_helper'
|
2
|
+
require 'cucumber/step_mother'
|
3
|
+
require 'cucumber/ast'
|
4
|
+
require 'cucumber/core_ext/string'
|
5
|
+
|
6
|
+
module Cucumber
|
7
|
+
module Ast
|
8
|
+
describe ScenarioOutline do
|
9
|
+
before do
|
10
|
+
@step_mother = Object.new
|
11
|
+
@step_mother.extend(StepMother)
|
12
|
+
@step_mother.Given(/^there are (\d+) cucumbers$/) do |n|
|
13
|
+
@initial = n.to_i
|
14
|
+
end
|
15
|
+
@step_mother.When(/^I eat (\d+) cucumbers$/) do |n|
|
16
|
+
@eaten = n.to_i
|
17
|
+
end
|
18
|
+
@step_mother.Then(/^I should have (\d+) cucumbers$/) do |n|
|
19
|
+
(@initial - @eaten).should == n.to_i
|
20
|
+
end
|
21
|
+
@step_mother.Then(/^I should have (\d+) cucumbers in my belly$/) do |n|
|
22
|
+
@eaten.should == n.to_i
|
23
|
+
end
|
24
|
+
|
25
|
+
@scenario_outline = ScenarioOutline.new(
|
26
|
+
Comment.new(""),
|
27
|
+
Tags.new(18, []),
|
28
|
+
19,
|
29
|
+
"Scenario:", "My outline",
|
30
|
+
[
|
31
|
+
Step.new(20, 'Given', 'there are <start> cucumbers'),
|
32
|
+
Step.new(21, 'When', 'I eat <eat> cucumbers'),
|
33
|
+
Step.new(22, 'Then', 'I should have <left> cucumbers'),
|
34
|
+
Step.new(23, 'And', 'I should have <eat> cucumbers in my belly')
|
35
|
+
],
|
36
|
+
[
|
37
|
+
[
|
38
|
+
24,
|
39
|
+
'Examples:',
|
40
|
+
'First table',
|
41
|
+
[
|
42
|
+
%w{start eat left},
|
43
|
+
%w{12 5 7},
|
44
|
+
%w{20 6 14}
|
45
|
+
]
|
46
|
+
]
|
47
|
+
]
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
it "should replace all variables and call outline once for each table row" do
|
52
|
+
visitor = Visitor.new(@step_mother)
|
53
|
+
visitor.should_receive(:visit_table_row).exactly(3).times
|
54
|
+
visitor.visit_feature_element(@scenario_outline)
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should pretty print" do
|
58
|
+
require 'cucumber/formatter/pretty'
|
59
|
+
visitor = Formatter::Pretty.new(@step_mother, STDOUT, {:comment => true})
|
60
|
+
visitor.visit_feature_element(@scenario_outline)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|