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.
- data/History.txt +150 -0
- data/License.txt +20 -0
- data/Manifest.txt +186 -0
- data/README.txt +41 -0
- data/Rakefile +5 -0
- data/TODO.txt +26 -0
- data/bin/cucumber +4 -0
- data/config/hoe.rb +69 -0
- data/config/requirements.rb +15 -0
- data/cucumber.yml +1 -0
- data/examples/calculator/README.txt +5 -0
- data/examples/calculator/Rakefile +5 -0
- data/examples/calculator/features/addition.feature +17 -0
- data/examples/calculator/features/division.feature +10 -0
- data/examples/calculator/features/steps/calculator_steps.rb +31 -0
- data/examples/calculator/lib/calculator.rb +16 -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/steps/calculator_steps.rb +43 -0
- data/examples/calculatrice_francaise_avec_soit_scenario/Rakefile +6 -0
- data/examples/calculatrice_francaise_avec_soit_scenario/features/addition.feature +13 -0
- data/examples/calculatrice_francaise_avec_soit_scenario/features/calculatrice_steps.rb +31 -0
- data/examples/chinese_simplified_calculator/Rakefile +6 -0
- data/examples/chinese_simplified_calculator/features/addition.feature +17 -0
- data/examples/chinese_simplified_calculator/features/steps/calculator_steps.rb +24 -0
- data/examples/chinese_simplified_calculator/lib/calculator.rb +10 -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/steps/hello_steps.rb +25 -0
- data/examples/cs/features/steps/tree_steps.rb +14 -0
- data/examples/cs/features/tree.feature +9 -0
- data/examples/cs/src/Hello.cs +18 -0
- data/examples/danish_calculator/Rakefile +6 -0
- data/examples/danish_calculator/features/steps/kalkulator_steps.rb +22 -0
- data/examples/danish_calculator/features/summering.feature +17 -0
- data/examples/danish_calculator/lib/kalkulator.rb +11 -0
- data/examples/dos_line_endings/Rakefile +6 -0
- data/examples/dos_line_endings/features/dos_line_endings.feature +9 -0
- data/examples/estonian_calculator/Rakefile +6 -0
- data/examples/estonian_calculator/features/kalkulaator_steps.rb +35 -0
- data/examples/estonian_calculator/features/liitmine.feature +16 -0
- data/examples/japanese_calculator/README.txt +5 -0
- data/examples/japanese_calculator/Rakefile +6 -0
- data/examples/japanese_calculator/features/addition.feature +17 -0
- data/examples/japanese_calculator/features/division.feature +10 -0
- data/examples/japanese_calculator/features/steps/calculator_steps.rb +30 -0
- data/examples/japanese_calculator/lib/calculator.rb +16 -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/steps/hello_steps.rb +25 -0
- data/examples/java/features/steps/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/norwegian_calculator/Rakefile +6 -0
- data/examples/norwegian_calculator/features/steps/kalkulator_steps.rb +22 -0
- data/examples/norwegian_calculator/features/summering.feature +17 -0
- data/examples/norwegian_calculator/lib/kalkulator.rb +11 -0
- data/examples/portuguese_calculator/Rakefile +6 -0
- data/examples/portuguese_calculator/features/adicao.feature +10 -0
- data/examples/portuguese_calculator/features/calculadora_steps.rb +31 -0
- data/examples/selenium/Rakefile +6 -0
- data/examples/selenium/features/search.feature +9 -0
- data/examples/selenium/features/steps/stories_steps.rb +41 -0
- data/examples/spanish_calculator/Rakefile +6 -0
- data/examples/spanish_calculator/features/adicion.feature +17 -0
- data/examples/spanish_calculator/features/steps/calculador_steps.rb +22 -0
- data/examples/swedish_calculator/Rakefile +5 -0
- data/examples/swedish_calculator/features/steps/kalkulator_steps.rb +22 -0
- data/examples/swedish_calculator/features/summering.feature +17 -0
- data/examples/swedish_calculator/lib/kalkulator.rb +11 -0
- data/examples/tickets/Rakefile +11 -0
- data/examples/tickets/cucumber.yml +2 -0
- data/examples/tickets/features/steps/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/steps/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 +49 -0
- data/lib/cucumber.rb +35 -0
- data/lib/cucumber/cli.rb +191 -0
- data/lib/cucumber/core_ext/proc.rb +55 -0
- data/lib/cucumber/core_ext/string.rb +22 -0
- data/lib/cucumber/executor.rb +143 -0
- data/lib/cucumber/formatters.rb +1 -0
- data/lib/cucumber/formatters/ansicolor.rb +112 -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 +211 -0
- data/lib/cucumber/formatters/profile_formatter.rb +92 -0
- data/lib/cucumber/formatters/progress_formatter.rb +51 -0
- data/lib/cucumber/languages.yml +142 -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 +75 -0
- data/lib/cucumber/step_methods.rb +49 -0
- data/lib/cucumber/step_mother.rb +83 -0
- data/lib/cucumber/tree.rb +18 -0
- data/lib/cucumber/tree/feature.rb +60 -0
- data/lib/cucumber/tree/features.rb +21 -0
- data/lib/cucumber/tree/given_scenario.rb +13 -0
- data/lib/cucumber/tree/scenario.rb +150 -0
- data/lib/cucumber/tree/step.rb +133 -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 +201 -0
- data/lib/cucumber/treetop_parser/feature_da.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_de.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_en-tx.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_en.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_es.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_et.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_fr.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_ja.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_nl.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_no.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_parser.rb +34 -0
- data/lib/cucumber/treetop_parser/feature_pt.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_ru.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_se.rb +1593 -0
- data/lib/cucumber/treetop_parser/feature_zh-CN.rb +1593 -0
- data/lib/cucumber/version.rb +9 -0
- data/rails_generators/cucumber/cucumber_generator.rb +29 -0
- data/rails_generators/cucumber/templates/common_webrat.rb +42 -0
- data/rails_generators/cucumber/templates/cucumber +2 -0
- data/rails_generators/cucumber/templates/cucumber.rake +12 -0
- data/rails_generators/cucumber/templates/cucumber.yml +1 -0
- data/rails_generators/cucumber/templates/env.rb +8 -0
- data/rails_generators/feature/feature_generator.rb +17 -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/cli_spec.rb +56 -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 +130 -0
- data/spec/cucumber/formatters/ansicolor_spec.rb +35 -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 +111 -0
- data/spec/cucumber/formatters/profile_formatter_spec.rb +193 -0
- data/spec/cucumber/formatters/progress_formatter_spec.rb +45 -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 +9 -0
- data/spec/cucumber/step_mother_spec.rb +53 -0
- data/spec/cucumber/tree/feature_spec.rb +12 -0
- data/spec/cucumber/tree/scenario_spec.rb +37 -0
- data/spec/cucumber/tree/step_spec.rb +31 -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 +96 -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 +13 -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 +288 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
module Cucumber
|
|
2
|
+
module Formatters
|
|
3
|
+
class ProfileFormatter < ProgressFormatter
|
|
4
|
+
NUMBER_OF_STEP_DEFINITONS_TO_SHOW = 10
|
|
5
|
+
NUMBER_OF_STEP_INVOCATIONS_TO_SHOW = 5
|
|
6
|
+
|
|
7
|
+
def initialize(io, step_mother)
|
|
8
|
+
super(io)
|
|
9
|
+
@step_mother = step_mother
|
|
10
|
+
@step_times = Hash.new { |k,v| k[v] = [] }
|
|
11
|
+
@step_keywords = {}
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def visit_features(features)
|
|
15
|
+
@io.puts "Profiling enabled.\n"
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def step_executing(step, regexp, args)
|
|
19
|
+
@step_time = Time.now
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def step_passed(step, regexp, args)
|
|
23
|
+
execution_time = Time.now - @step_time
|
|
24
|
+
super
|
|
25
|
+
@step_keywords[regexp] ||= step.actual_keyword unless step.row?
|
|
26
|
+
invocation_comment = ''
|
|
27
|
+
definition_comment = ''
|
|
28
|
+
|
|
29
|
+
if step.row?
|
|
30
|
+
description = ''
|
|
31
|
+
args.each do |arg|
|
|
32
|
+
description += %{|#{arg}|}
|
|
33
|
+
end
|
|
34
|
+
else
|
|
35
|
+
description = "#{step.keyword} #{step.format(regexp){|param| underline(param)}}"
|
|
36
|
+
definition_comment = source(step)
|
|
37
|
+
end
|
|
38
|
+
invocation_comment = "# #{step.file}:#{step.line}"
|
|
39
|
+
@step_times["#{@step_keywords[regexp]} #{regexp.inspect}"] << [description, invocation_comment, definition_comment, execution_time]
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def dump
|
|
43
|
+
super
|
|
44
|
+
@io.puts "\n\nTop #{NUMBER_OF_STEP_DEFINITONS_TO_SHOW} average slowest steps with #{NUMBER_OF_STEP_INVOCATIONS_TO_SHOW} slowest matches:\n"
|
|
45
|
+
|
|
46
|
+
mean_times = map_to_mean_times(@step_times)
|
|
47
|
+
mean_times = mean_times.sort_by { |step_profiles, keyword_regexp, mean_execution_time| mean_execution_time }.reverse
|
|
48
|
+
|
|
49
|
+
mean_times[0...NUMBER_OF_STEP_DEFINITONS_TO_SHOW].each do |step_profiles, keyword_regexp, mean_execution_time|
|
|
50
|
+
print_step_definition(step_profiles, keyword_regexp, mean_execution_time)
|
|
51
|
+
step_profiles = step_profiles.sort_by { |description, invocation_comment, definition_comment, execution_time| execution_time }.reverse
|
|
52
|
+
print_step_invocations(step_profiles, keyword_regexp)
|
|
53
|
+
end
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
private
|
|
57
|
+
def map_to_mean_times(step_times)
|
|
58
|
+
mean_times = []
|
|
59
|
+
step_times.each do |regexp, step_profiles|
|
|
60
|
+
mean_execution_time = (step_profiles.inject(0) { |sum, step_details| step_details[3] + sum } / step_profiles.length)
|
|
61
|
+
mean_times << [step_profiles, regexp, mean_execution_time]
|
|
62
|
+
end
|
|
63
|
+
mean_times
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def print_step_definition(step_profiles, keyword_regexp, mean_execution_time)
|
|
67
|
+
unless step_profiles.empty?
|
|
68
|
+
_, _, definition_comment, _ = step_profiles.first
|
|
69
|
+
@io.print red(sprintf("%.7f", mean_execution_time))
|
|
70
|
+
@io.print " #{keyword_regexp}"
|
|
71
|
+
@io.print " #{comment(definition_comment)}"
|
|
72
|
+
@io.puts
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
def print_step_invocations(step_profiles, keyword_regexp)
|
|
77
|
+
step_profiles[0...NUMBER_OF_STEP_INVOCATIONS_TO_SHOW].each do |description, invocation_comment, definition_comment, execution_time|
|
|
78
|
+
@io.print " #{yellow(sprintf("%.7f", execution_time))}"
|
|
79
|
+
@io.print " #{description}"
|
|
80
|
+
@io.print " #{comment(invocation_comment)}"
|
|
81
|
+
@io.puts
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def source(step)
|
|
86
|
+
_, _, proc = step.regexp_args_proc(@step_mother)
|
|
87
|
+
proc.to_comment_line
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
require 'cucumber/formatters/ansicolor'
|
|
2
|
+
|
|
3
|
+
module Cucumber
|
|
4
|
+
module Formatters
|
|
5
|
+
class ProgressFormatter
|
|
6
|
+
include ANSIColor
|
|
7
|
+
|
|
8
|
+
def initialize(io)
|
|
9
|
+
@io = (io == STDOUT) ? Kernel : io
|
|
10
|
+
@errors = []
|
|
11
|
+
@pending = []
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def step_passed(step, regexp, args)
|
|
15
|
+
@io.print passed('.')
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def step_failed(step, regexp, args)
|
|
19
|
+
@errors << step.error
|
|
20
|
+
@io.print failed('F')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def step_pending(step, regexp, args)
|
|
24
|
+
@pending << step.scenario
|
|
25
|
+
@io.print pending('P')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def step_skipped(step, regexp, args)
|
|
29
|
+
@io.print skipped('_')
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def dump
|
|
33
|
+
@io.puts pending
|
|
34
|
+
@io.puts "\nPending Scenarios:\n\n" if @pending.any?
|
|
35
|
+
@pending.uniq.each_with_index do |scenario, n|
|
|
36
|
+
@io.puts "#{n+1}) #{scenario.feature.header.split("\n").first.gsub(/^(Feature|Story):/, '')} (#{scenario.name})"
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
@io.puts failed
|
|
40
|
+
@io.puts "\nFailed:" if @errors.any?
|
|
41
|
+
@errors.each_with_index do |error,n|
|
|
42
|
+
@io.puts
|
|
43
|
+
@io.puts "#{n+1})"
|
|
44
|
+
@io.puts error.message
|
|
45
|
+
@io.puts error.backtrace.join("\n")
|
|
46
|
+
end
|
|
47
|
+
@io.print reset
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# http://en.wikipedia.org/wiki/IETF_language_tag
|
|
2
|
+
# http://www.iana.org/assignments/language-subtag-registry
|
|
3
|
+
# http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt (Use this I think)
|
|
4
|
+
"en":
|
|
5
|
+
feature: Feature
|
|
6
|
+
scenario: Scenario
|
|
7
|
+
more_examples: More Examples
|
|
8
|
+
given_scenario: GivenScenario
|
|
9
|
+
given: Given
|
|
10
|
+
when: When
|
|
11
|
+
then: Then
|
|
12
|
+
and: And
|
|
13
|
+
but: But
|
|
14
|
+
# Please help us keeping the languages below uptodate. The parsers for a language
|
|
15
|
+
# that is missing a keyword will expect the English word until the missing word(s)
|
|
16
|
+
# are added.
|
|
17
|
+
#
|
|
18
|
+
# Please keep the grammars in alphabetical order from here and down.
|
|
19
|
+
"da":
|
|
20
|
+
feature: Egenskab
|
|
21
|
+
scenario: Scenarie
|
|
22
|
+
given_scenario: GivetScenarie
|
|
23
|
+
given: Givet
|
|
24
|
+
when: Når
|
|
25
|
+
then: Så
|
|
26
|
+
and: Og
|
|
27
|
+
but: Men
|
|
28
|
+
"de":
|
|
29
|
+
feature: Funktionalität
|
|
30
|
+
scenario: Szenario
|
|
31
|
+
given_scenario: GegebenesSzenario
|
|
32
|
+
given: Gegeben sei
|
|
33
|
+
when: Wenn
|
|
34
|
+
then: Dann
|
|
35
|
+
and: Und
|
|
36
|
+
but: Aber
|
|
37
|
+
# Texan
|
|
38
|
+
"en-tx":
|
|
39
|
+
feature: Feature
|
|
40
|
+
scenario: Scenario
|
|
41
|
+
more_examples: More Examples
|
|
42
|
+
given_scenario: GivenScenario
|
|
43
|
+
given: Given y'all
|
|
44
|
+
when: When y'all
|
|
45
|
+
then: Then y'all
|
|
46
|
+
and: And y'all
|
|
47
|
+
but: But y'all
|
|
48
|
+
"es":
|
|
49
|
+
feature: Característica
|
|
50
|
+
scenario: Escenario
|
|
51
|
+
more_examples: Más ejemplos
|
|
52
|
+
given_scenario: DadoElEscenario
|
|
53
|
+
given: Dado
|
|
54
|
+
when: Cuando
|
|
55
|
+
then: Entonces
|
|
56
|
+
and: Y
|
|
57
|
+
but: Pero
|
|
58
|
+
"fr":
|
|
59
|
+
feature: Fonction
|
|
60
|
+
scenario: Scenario
|
|
61
|
+
more_examples: Plus d'exemples
|
|
62
|
+
given_scenario: SoitScenario
|
|
63
|
+
given: Soit
|
|
64
|
+
when: Lorsque
|
|
65
|
+
then: Alors
|
|
66
|
+
and: Et
|
|
67
|
+
but: Mais
|
|
68
|
+
"nl":
|
|
69
|
+
feature: Functionaliteit
|
|
70
|
+
scenario: Scenario
|
|
71
|
+
more_examples: Meer voorbeelden
|
|
72
|
+
given_scenario: GegevenScenario
|
|
73
|
+
given: Gegeven
|
|
74
|
+
when: Als
|
|
75
|
+
then: Dan
|
|
76
|
+
and: En
|
|
77
|
+
but: Maar
|
|
78
|
+
"no":
|
|
79
|
+
feature: Egenskap
|
|
80
|
+
scenario: Scenario
|
|
81
|
+
more_examples: Flere eksempler
|
|
82
|
+
given_scenario: GittScenario
|
|
83
|
+
given: Gitt
|
|
84
|
+
when: Når
|
|
85
|
+
then: Så
|
|
86
|
+
and: Og
|
|
87
|
+
but: Men
|
|
88
|
+
"pt":
|
|
89
|
+
feature: Característica
|
|
90
|
+
scenario: Cenário
|
|
91
|
+
given_scenario: DadoOCenário
|
|
92
|
+
given: Dado
|
|
93
|
+
when: Quando
|
|
94
|
+
then: Então
|
|
95
|
+
and: E
|
|
96
|
+
but: Mas
|
|
97
|
+
"ru":
|
|
98
|
+
feature: Функционал
|
|
99
|
+
scenario: Сценарий
|
|
100
|
+
given_scenario: ДанныйСценарий
|
|
101
|
+
given: Сначала
|
|
102
|
+
when: Если
|
|
103
|
+
then: То
|
|
104
|
+
and: И
|
|
105
|
+
but: Но
|
|
106
|
+
"se":
|
|
107
|
+
feature: Egenskap
|
|
108
|
+
scenario: Scenario
|
|
109
|
+
given_scenario: GivetScenario
|
|
110
|
+
given: Givet
|
|
111
|
+
when: När
|
|
112
|
+
then: Så
|
|
113
|
+
and: Och
|
|
114
|
+
but: Men
|
|
115
|
+
"et":
|
|
116
|
+
feature: Omadus
|
|
117
|
+
scenario: Stsenaarium
|
|
118
|
+
given_scenario: EeldadesStsenaariumit
|
|
119
|
+
given: Eeldades
|
|
120
|
+
when: Kui
|
|
121
|
+
then: Siis
|
|
122
|
+
and: Ja
|
|
123
|
+
but: Kuid
|
|
124
|
+
"zh-CN":
|
|
125
|
+
feature: 功能
|
|
126
|
+
scenario: 场景
|
|
127
|
+
given_scenario: 引用场景
|
|
128
|
+
given: 假如
|
|
129
|
+
when: 当
|
|
130
|
+
then: 那么
|
|
131
|
+
and: 而且
|
|
132
|
+
but: 但是
|
|
133
|
+
"ja":
|
|
134
|
+
feature: フィーチャ
|
|
135
|
+
scenario: シナリオ
|
|
136
|
+
more_examples: 他のサンプル
|
|
137
|
+
given_scenario: 前提シナリオ
|
|
138
|
+
given: 前提
|
|
139
|
+
when: もし
|
|
140
|
+
then: ならば
|
|
141
|
+
and: かつ
|
|
142
|
+
but: しかし
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
%w{table}.each{|f| require "cucumber/model/#{f}"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
module Cucumber
|
|
2
|
+
module Model
|
|
3
|
+
class Table
|
|
4
|
+
attr_accessor :raw
|
|
5
|
+
|
|
6
|
+
# Creates a new table. The +raw+ argument should be an array
|
|
7
|
+
# of arrays
|
|
8
|
+
def initialize(raw)
|
|
9
|
+
@raw = raw
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Turn the table into an array of Hash where each Hash
|
|
13
|
+
# has keys corresponding to the table header (first line)
|
|
14
|
+
# and the values are the individual row cells.
|
|
15
|
+
def hashes
|
|
16
|
+
header = @raw[0]
|
|
17
|
+
@raw[1..-1].map do |row|
|
|
18
|
+
h = {}
|
|
19
|
+
row.each_with_index do |v,n|
|
|
20
|
+
key = header[n]
|
|
21
|
+
h[key] = v
|
|
22
|
+
end
|
|
23
|
+
h
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require 'spec'
|
|
2
|
+
require 'spec/rails'
|
|
3
|
+
|
|
4
|
+
# Hack to stop RSpec from dumping the summary
|
|
5
|
+
Spec::Runner::Options.class_eval do
|
|
6
|
+
def examples_should_be_run?
|
|
7
|
+
false
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
ActionController::Integration::Session.send(:include, Spec::Matchers)
|
|
12
|
+
ActionController::Integration::Session.send(:include, Spec::Rails::Matchers)
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Based on code from Brian Takita, Yurii Rashkovskii and Ben Mabey
|
|
2
|
+
# Adapted by Aslak Hellesøy
|
|
3
|
+
|
|
4
|
+
if defined?(ActiveRecord::Base)
|
|
5
|
+
require 'test_help'
|
|
6
|
+
else
|
|
7
|
+
require 'action_controller/test_process'
|
|
8
|
+
require 'action_controller/integration'
|
|
9
|
+
end
|
|
10
|
+
require 'test/unit/testresult'
|
|
11
|
+
|
|
12
|
+
# These allow exceptions to come through as opposed to being caught and hvaing non-helpful responses returned.
|
|
13
|
+
ActionController::Base.class_eval do
|
|
14
|
+
def perform_action
|
|
15
|
+
perform_action_without_rescue
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
Dispatcher.class_eval do
|
|
19
|
+
def self.failsafe_response(output, status, exception = nil)
|
|
20
|
+
raise exception
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# So that Test::Unit doesn't launch at the end - makes it think it has already been run.
|
|
25
|
+
Test::Unit.run = true if Test::Unit.respond_to?(:run=)
|
|
26
|
+
|
|
27
|
+
$main = self
|
|
28
|
+
|
|
29
|
+
module Cucumber #:nodoc:
|
|
30
|
+
module Rails
|
|
31
|
+
# All scenarios will execute in the context of a new instance of World.
|
|
32
|
+
class World < ActionController::IntegrationTest
|
|
33
|
+
if defined?(ActiveRecord::Base)
|
|
34
|
+
self.use_transactional_fixtures = false
|
|
35
|
+
else
|
|
36
|
+
def self.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def initialize #:nodoc:
|
|
40
|
+
@_result = Test::Unit::TestResult.new
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def self.use_transactional_fixtures
|
|
45
|
+
World.use_transactional_fixtures = true
|
|
46
|
+
if defined?(ActiveRecord::Base)
|
|
47
|
+
$main.Before do
|
|
48
|
+
if ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
|
|
49
|
+
ActiveRecord::Base.connection.increment_open_transactions
|
|
50
|
+
else
|
|
51
|
+
ActiveRecord::Base.send :increment_open_transactions
|
|
52
|
+
end
|
|
53
|
+
ActiveRecord::Base.connection.begin_db_transaction
|
|
54
|
+
ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
$main.After do
|
|
58
|
+
ActiveRecord::Base.connection.rollback_db_transaction
|
|
59
|
+
if ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
|
|
60
|
+
ActiveRecord::Base.connection.decrement_open_transactions
|
|
61
|
+
else
|
|
62
|
+
ActiveRecord::Base.send :decrement_open_transactions
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
World do
|
|
72
|
+
Cucumber::Rails::World.new
|
|
73
|
+
end
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
module Cucumber
|
|
2
|
+
module Rake
|
|
3
|
+
# Defines a task for running features.
|
|
4
|
+
class Task
|
|
5
|
+
LIB = File.expand_path(File.dirname(__FILE__) + '/../..')
|
|
6
|
+
BINARY = File.expand_path(File.dirname(__FILE__) + '/../../../bin/cucumber')
|
|
7
|
+
|
|
8
|
+
attr_accessor :libs
|
|
9
|
+
attr_accessor :step_list
|
|
10
|
+
attr_accessor :step_pattern
|
|
11
|
+
attr_accessor :feature_list
|
|
12
|
+
attr_accessor :feature_pattern
|
|
13
|
+
attr_accessor :cucumber_opts
|
|
14
|
+
attr_accessor :rcov
|
|
15
|
+
attr_accessor :rcov_opts
|
|
16
|
+
|
|
17
|
+
# Define a task
|
|
18
|
+
def initialize(task_name = "features", desc = "Run Features with Cucumber")
|
|
19
|
+
@task_name, @desc = task_name, desc
|
|
20
|
+
@libs = []
|
|
21
|
+
@rcov_opts = %w{--rails --exclude osx\/objc,gems\/}
|
|
22
|
+
|
|
23
|
+
yield self if block_given?
|
|
24
|
+
|
|
25
|
+
@feature_pattern = "features/**/*.feature" if feature_pattern.nil? && feature_list.nil?
|
|
26
|
+
@step_pattern = "features/**/*.rb" if step_pattern.nil? && step_list.nil?
|
|
27
|
+
define_tasks
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def define_tasks
|
|
31
|
+
desc @desc
|
|
32
|
+
task @task_name do
|
|
33
|
+
lib_args = ['"%s"' % ([LIB] + libs).join(File::PATH_SEPARATOR)]
|
|
34
|
+
cucumber_bin = ['"%s"' % BINARY]
|
|
35
|
+
cuc_opts = [(ENV['CUCUMBER_OPTS'] || cucumber_opts)]
|
|
36
|
+
|
|
37
|
+
step_files.each do |step_file|
|
|
38
|
+
cuc_opts << '--require'
|
|
39
|
+
cuc_opts << step_file
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
if rcov
|
|
43
|
+
args = (['-I'] + lib_args + ['-S', 'rcov'] + rcov_opts + cucumber_bin + ['--'] + cuc_opts + feature_files).flatten
|
|
44
|
+
else
|
|
45
|
+
args = (['-I'] + lib_args + cucumber_bin + cuc_opts + feature_files).flatten
|
|
46
|
+
end
|
|
47
|
+
ruby(args.join(" ")) # ruby(*args) is broken on Windows
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
def feature_files # :nodoc:
|
|
53
|
+
if ENV['FEATURE']
|
|
54
|
+
FileList[ ENV['FEATURE'] ]
|
|
55
|
+
else
|
|
56
|
+
result = []
|
|
57
|
+
result += feature_list.to_a if feature_list
|
|
58
|
+
result += FileList[feature_pattern].to_a if feature_pattern
|
|
59
|
+
FileList[result]
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def step_files # :nodoc:
|
|
64
|
+
if ENV['STEPS']
|
|
65
|
+
FileList[ ENV['STEPS'] ]
|
|
66
|
+
else
|
|
67
|
+
result = []
|
|
68
|
+
result += step_list.to_a if step_list
|
|
69
|
+
result += FileList[step_pattern].to_a if step_pattern
|
|
70
|
+
FileList[result]
|
|
71
|
+
end
|
|
72
|
+
end
|
|
73
|
+
end
|
|
74
|
+
end
|
|
75
|
+
end
|