aslakhellesoy-cucumber 0.1.16.4 → 0.1.16.5
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +75 -1
- data/Manifest.txt +58 -65
- data/examples/cs/features/step_definitons/calculator_steps.rb +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/step_definitons/calculador_steps.rb +1 -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/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/self_test/README.textile +4 -1
- 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 +8 -5
- data/examples/self_test/features/sample.feature +5 -3
- data/examples/self_test/features/step_definitions/sample_steps.rb +15 -3
- data/features/cucumber_cli.feature +199 -97
- data/features/cucumber_cli_outlines.feature +46 -38
- data/features/report_called_undefined_steps.feature +31 -0
- data/features/step_definitions/cucumber_steps.rb +7 -3
- data/features/step_definitions/extra_steps.rb +1 -1
- data/features/support/env.rb +1 -1
- data/gem_tasks/features.rake +1 -1
- data/gem_tasks/flog.rake +1 -1
- data/lib/autotest/cucumber_mixin.rb +16 -23
- data/lib/cucumber/ast/comment.rb +26 -0
- data/lib/cucumber/ast/examples.rb +22 -0
- data/lib/cucumber/ast/feature.rb +60 -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 +91 -0
- data/lib/cucumber/ast/scenario_outline.rb +83 -0
- data/lib/cucumber/ast/step.rb +130 -0
- data/lib/cucumber/ast/table.rb +214 -0
- data/lib/cucumber/ast/tags.rb +33 -0
- data/lib/cucumber/ast/visitor.rb +93 -0
- data/lib/cucumber/ast.rb +27 -0
- data/lib/cucumber/broadcaster.rb +1 -6
- data/lib/cucumber/cli.rb +178 -128
- 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/{formatters → formatter}/ansicolor.rb +11 -10
- data/lib/cucumber/formatter/console.rb +116 -0
- data/lib/cucumber/formatter/pretty.rb +158 -0
- data/lib/cucumber/formatter/profile.rb +77 -0
- data/lib/cucumber/formatter/progress.rb +68 -0
- data/lib/cucumber/formatter.rb +1 -0
- data/lib/cucumber/formatters/autotest_formatter.rb +0 -2
- data/lib/cucumber/formatters/html_formatter.rb +4 -3
- data/lib/cucumber/formatters/pretty_formatter.rb +1 -1
- data/lib/cucumber/formatters/unicode.rb +3 -3
- data/lib/cucumber/jbehave.rb +104 -0
- data/lib/cucumber/languages.yml +100 -73
- data/lib/cucumber/parser/basic.rb +0 -0
- data/lib/cucumber/parser/feature.rb +1694 -0
- data/lib/cucumber/parser/feature.tt +206 -0
- data/lib/cucumber/parser/file_parser.rb +50 -0
- data/lib/cucumber/parser/i18n.tt +26 -0
- data/lib/cucumber/parser/treetop_ext.rb +9 -0
- data/lib/cucumber/parser.rb +27 -0
- data/lib/cucumber/platform.rb +3 -17
- data/lib/cucumber/step_definition.rb +83 -0
- data/lib/cucumber/step_mother.rb +128 -72
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber.rb +56 -9
- 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/broadcaster_spec.rb +4 -17
- data/spec/cucumber/cli_spec.rb +43 -148
- 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 +11 -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/autotest_formatter_spec.rb +1 -0
- data/spec/cucumber/formatters/profile_formatter_spec.rb +17 -16
- data/spec/cucumber/parser/feature_parser_spec.rb +247 -0
- data/spec/cucumber/parser/table_parser_spec.rb +48 -0
- data/spec/cucumber/step_definition_spec.rb +62 -0
- data/spec/cucumber/step_mom_spec.rb +49 -0
- data/spec/cucumber/treetop_parser/empty_feature.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 +59 -67
- data/examples/calculator_ruby_features/Rakefile +0 -6
- 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/executor.rb +0 -205
- data/lib/cucumber/formatters/profile_formatter.rb +0 -92
- data/lib/cucumber/formatters/progress_formatter.rb +0 -61
- data/lib/cucumber/formatters.rb +0 -1
- data/lib/cucumber/model/table.rb +0 -32
- data/lib/cucumber/model.rb +0 -1
- data/lib/cucumber/step_methods.rb +0 -49
- 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/tree.rb +0 -16
- 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_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/pending.rb +0 -22
- data/lib/cucumber/world.rb +0 -1
- data/setup.rb +0 -1585
- data/spec/cucumber/executor_spec.rb +0 -382
- data/spec/cucumber/formatters/html_formatter_spec.rb +0 -104
- 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/step_mother_spec.rb +0 -74
- 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/executor.rb
DELETED
@@ -1,205 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
class Executor
|
3
|
-
attr_reader :failed
|
4
|
-
attr_accessor :formatters
|
5
|
-
attr_writer :scenario_names, :lines_for_features, :dry_run
|
6
|
-
|
7
|
-
def initialize(step_mother)
|
8
|
-
@world_procs = []
|
9
|
-
@before_scenario_procs = []
|
10
|
-
@after_scenario_procs = []
|
11
|
-
@after_step_procs = []
|
12
|
-
@step_mother = step_mother
|
13
|
-
|
14
|
-
@executed_scenarios = {}
|
15
|
-
@regular_scenario_cache = {}
|
16
|
-
end
|
17
|
-
|
18
|
-
def register_world_proc(&proc)
|
19
|
-
@world_procs << proc
|
20
|
-
end
|
21
|
-
|
22
|
-
def register_before_scenario_proc(&proc)
|
23
|
-
proc.extend(CoreExt::CallIn)
|
24
|
-
@before_scenario_procs << proc
|
25
|
-
end
|
26
|
-
|
27
|
-
def register_after_scenario_proc(&proc)
|
28
|
-
proc.extend(CoreExt::CallIn)
|
29
|
-
@after_scenario_procs << proc
|
30
|
-
end
|
31
|
-
|
32
|
-
def register_after_step_proc(&proc)
|
33
|
-
proc.extend(CoreExt::CallIn)
|
34
|
-
@after_step_procs << proc
|
35
|
-
end
|
36
|
-
|
37
|
-
def visit_features(features)
|
38
|
-
formatters.visit_features(features)
|
39
|
-
features.accept(self)
|
40
|
-
formatters.dump
|
41
|
-
end
|
42
|
-
|
43
|
-
def visit_feature(feature)
|
44
|
-
@feature_file = feature.file
|
45
|
-
|
46
|
-
if accept_feature?(feature)
|
47
|
-
formatters.feature_executing(feature)
|
48
|
-
feature.accept(self)
|
49
|
-
@executed_scenarios = {}
|
50
|
-
@regular_scenario_cache = {}
|
51
|
-
end
|
52
|
-
end
|
53
|
-
|
54
|
-
def visit_header(header)
|
55
|
-
formatters.header_executing(header)
|
56
|
-
end
|
57
|
-
|
58
|
-
def visit_row_scenario(scenario)
|
59
|
-
execute_scenario(@regular_scenario_cache[scenario.name]) if executing_unprepared_row_scenario?(scenario)
|
60
|
-
visit_scenario(scenario)
|
61
|
-
end
|
62
|
-
|
63
|
-
def visit_regular_scenario(scenario)
|
64
|
-
@regular_scenario_cache[scenario.name] = scenario
|
65
|
-
visit_scenario(scenario)
|
66
|
-
end
|
67
|
-
|
68
|
-
def visit_scenario_outline(scenario)
|
69
|
-
visit_regular_scenario(scenario)
|
70
|
-
end
|
71
|
-
|
72
|
-
def visit_scenario(scenario)
|
73
|
-
if accept_scenario?(scenario)
|
74
|
-
@executed_scenarios[scenario.name] = true
|
75
|
-
execute_scenario(scenario)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def execute_scenario(scenario)
|
80
|
-
@error = nil
|
81
|
-
@pending = nil
|
82
|
-
|
83
|
-
@world = create_world
|
84
|
-
|
85
|
-
formatters.scenario_executing(scenario)
|
86
|
-
@before_scenario_procs.each{|p| p.call_in(@world, *[])} unless @dry_run
|
87
|
-
scenario.accept(self)
|
88
|
-
@after_scenario_procs.each{|p| p.call_in(@world, *[])} unless @dry_run
|
89
|
-
formatters.scenario_executed(scenario)
|
90
|
-
end
|
91
|
-
|
92
|
-
def accept_scenario?(scenario)
|
93
|
-
scenario_at_specified_line?(scenario) &&
|
94
|
-
scenario_has_specified_name?(scenario)
|
95
|
-
end
|
96
|
-
|
97
|
-
def accept_feature?(feature)
|
98
|
-
feature.scenarios.any? { |s| accept_scenario?(s) }
|
99
|
-
end
|
100
|
-
|
101
|
-
def visit_row_step(step)
|
102
|
-
visit_step(step)
|
103
|
-
end
|
104
|
-
|
105
|
-
def visit_regular_step(step)
|
106
|
-
visit_step(step)
|
107
|
-
end
|
108
|
-
|
109
|
-
def visit_step_outline(step)
|
110
|
-
regexp, args, proc = step.regexp_args_proc(@step_mother)
|
111
|
-
formatters.step_traced(step, regexp, args)
|
112
|
-
end
|
113
|
-
|
114
|
-
def visit_step(step)
|
115
|
-
unless @pending || @error
|
116
|
-
begin
|
117
|
-
regexp, args, proc = step.regexp_args_proc(@step_mother)
|
118
|
-
formatters.step_executing(step, regexp, args)
|
119
|
-
step.execute_in(@world, regexp, args, proc) unless @dry_run
|
120
|
-
@after_step_procs.each{|p| p.call_in(@world, *[])}
|
121
|
-
formatters.step_passed(step, regexp, args)
|
122
|
-
rescue ForcedPending => e
|
123
|
-
step.error = e
|
124
|
-
record_pending_step(step, regexp, args)
|
125
|
-
rescue Pending
|
126
|
-
record_pending_step(step, regexp, args)
|
127
|
-
rescue => e
|
128
|
-
@failed = true
|
129
|
-
@error = step.error = e
|
130
|
-
formatters.step_failed(step, regexp, args)
|
131
|
-
end
|
132
|
-
else
|
133
|
-
begin
|
134
|
-
regexp, args, proc = step.regexp_args_proc(@step_mother)
|
135
|
-
step.execute_in(@world, regexp, args, proc)
|
136
|
-
formatters.step_skipped(step, regexp, args)
|
137
|
-
rescue ForcedPending => e
|
138
|
-
step.error = e
|
139
|
-
record_pending_step(step, regexp, args)
|
140
|
-
rescue Pending
|
141
|
-
record_pending_step(step, regexp, args)
|
142
|
-
rescue Exception
|
143
|
-
formatters.step_skipped(step, regexp, args)
|
144
|
-
end
|
145
|
-
end
|
146
|
-
end
|
147
|
-
|
148
|
-
def record_pending_step(step, regexp, args)
|
149
|
-
@pending = true
|
150
|
-
formatters.step_pending(step, regexp, args)
|
151
|
-
end
|
152
|
-
|
153
|
-
def executing_unprepared_row_scenario?(scenario)
|
154
|
-
accept_scenario?(scenario) && !@executed_scenarios[scenario.name]
|
155
|
-
end
|
156
|
-
|
157
|
-
def scenario_at_specified_line?(scenario)
|
158
|
-
if lines_defined_for_current_feature?
|
159
|
-
@lines_for_features[@feature_file].inject(false) { |at_line, line| at_line || scenario.at_line?(line) }
|
160
|
-
else
|
161
|
-
true
|
162
|
-
end
|
163
|
-
end
|
164
|
-
|
165
|
-
def scenario_has_specified_name?(scenario)
|
166
|
-
if @scenario_names && !@scenario_names.empty?
|
167
|
-
@scenario_names.include?(scenario.name)
|
168
|
-
else
|
169
|
-
true
|
170
|
-
end
|
171
|
-
end
|
172
|
-
|
173
|
-
def lines_defined_for_current_feature?
|
174
|
-
@lines_for_features && !@lines_for_features[@feature_file].nil? && !@lines_for_features[@feature_file].empty?
|
175
|
-
end
|
176
|
-
|
177
|
-
def create_world
|
178
|
-
world = Object.new
|
179
|
-
@world_procs.each do |world_proc|
|
180
|
-
world = world_proc.call(world)
|
181
|
-
end
|
182
|
-
|
183
|
-
world.extend(World::Pending)
|
184
|
-
world.extend(::Spec::Matchers) if defined?(::Spec::Matchers)
|
185
|
-
define_step_call_methods(world)
|
186
|
-
world
|
187
|
-
end
|
188
|
-
|
189
|
-
def define_step_call_methods(world)
|
190
|
-
world.instance_variable_set('@__executor', self)
|
191
|
-
world.instance_eval do
|
192
|
-
class << self
|
193
|
-
def run_step(name)
|
194
|
-
_, args, proc = @__executor.instance_variable_get(:@step_mother).regexp_args_proc(name)
|
195
|
-
proc.call_in(self, *args)
|
196
|
-
end
|
197
|
-
|
198
|
-
%w{given when then and but}.each do |keyword|
|
199
|
-
alias_method Cucumber.language[keyword], :run_step
|
200
|
-
end
|
201
|
-
end
|
202
|
-
end
|
203
|
-
end
|
204
|
-
end
|
205
|
-
end
|
@@ -1,92 +0,0 @@
|
|
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
|
@@ -1,61 +0,0 @@
|
|
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_scenarios = []
|
12
|
-
end
|
13
|
-
|
14
|
-
def scenario_executing(scenario)
|
15
|
-
if scenario.pending?
|
16
|
-
@pending_scenarios << scenario
|
17
|
-
@io.print pending("P")
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def step_passed(step, regexp, args)
|
22
|
-
@io.print passed('.')
|
23
|
-
end
|
24
|
-
|
25
|
-
def step_failed(step, regexp, args)
|
26
|
-
@errors << step.error
|
27
|
-
@io.print failed('F')
|
28
|
-
end
|
29
|
-
|
30
|
-
def step_pending(step, regexp, args)
|
31
|
-
@pending_scenarios << step.scenario
|
32
|
-
@io.print pending('P')
|
33
|
-
end
|
34
|
-
|
35
|
-
def step_skipped(step, regexp, args)
|
36
|
-
@io.print skipped('_')
|
37
|
-
end
|
38
|
-
|
39
|
-
def step_traced(step, regexp, args)
|
40
|
-
end
|
41
|
-
|
42
|
-
def dump
|
43
|
-
@io.puts pending
|
44
|
-
@io.puts "\nPending Scenarios:\n\n" if @pending_scenarios.any?
|
45
|
-
@pending_scenarios.uniq.each_with_index do |scenario, n|
|
46
|
-
@io.puts "#{n+1}) #{scenario.feature.header.split("\n").first.gsub(/^(Feature|Story):/, '')} (#{scenario.name})"
|
47
|
-
end
|
48
|
-
|
49
|
-
@io.puts failed
|
50
|
-
@io.puts "\nFailed:" if @errors.any?
|
51
|
-
@errors.each_with_index do |error,n|
|
52
|
-
@io.puts
|
53
|
-
@io.puts "#{n+1})"
|
54
|
-
@io.puts error.message
|
55
|
-
@io.puts error.backtrace.join("\n")
|
56
|
-
end
|
57
|
-
@io.print reset
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/lib/cucumber/formatters.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
%w{html pretty progress profile autotest}.each{|n| require "cucumber/formatters/#{n}_formatter"}
|
data/lib/cucumber/model/table.rb
DELETED
@@ -1,32 +0,0 @@
|
|
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
|
-
rows.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
|
-
|
27
|
-
def rows
|
28
|
-
@raw[1..-1]
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
data/lib/cucumber/model.rb
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
%w{table}.each{|f| require "cucumber/model/#{f}"}
|
@@ -1,49 +0,0 @@
|
|
1
|
-
require 'cucumber/step_mother'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
# Defines "global" methods that may be used in *_steps.rb files.
|
5
|
-
module StepMethods
|
6
|
-
# Each scenario will execute in the context of what the supplied block returns.
|
7
|
-
def World(&proc)
|
8
|
-
executor.register_world_proc(&proc)
|
9
|
-
end
|
10
|
-
|
11
|
-
def Before(&proc)
|
12
|
-
executor.register_before_scenario_proc(&proc)
|
13
|
-
end
|
14
|
-
|
15
|
-
def After(&proc)
|
16
|
-
executor.register_after_scenario_proc(&proc)
|
17
|
-
end
|
18
|
-
|
19
|
-
def AfterStep(&proc)
|
20
|
-
executor.register_after_step_proc(&proc)
|
21
|
-
end
|
22
|
-
|
23
|
-
def Given(key, &proc)
|
24
|
-
step_mother.register_step_proc(key, &proc)
|
25
|
-
end
|
26
|
-
|
27
|
-
def When(key, &proc)
|
28
|
-
step_mother.register_step_proc(key, &proc)
|
29
|
-
end
|
30
|
-
|
31
|
-
def Then(key, &proc)
|
32
|
-
step_mother.register_step_proc(key, &proc)
|
33
|
-
end
|
34
|
-
|
35
|
-
# Simple workaround for old skool steps
|
36
|
-
def steps_for(*_)
|
37
|
-
STDERR.puts "WARNING: In Cucumber the steps_for method is obsolete"
|
38
|
-
yield
|
39
|
-
end
|
40
|
-
|
41
|
-
def step_mother #:nodoc:
|
42
|
-
@step_mother ||= StepMother.new
|
43
|
-
end
|
44
|
-
|
45
|
-
def executor
|
46
|
-
@executor ||= Executor.new(step_mother)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
@@ -1,105 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Tree
|
3
|
-
class Feature
|
4
|
-
attr_reader :header
|
5
|
-
attr_reader :scenarios
|
6
|
-
MIN_PADDING = 2
|
7
|
-
|
8
|
-
attr_accessor :file
|
9
|
-
|
10
|
-
def initialize(header, &proc)
|
11
|
-
@header = header
|
12
|
-
@scenarios = []
|
13
|
-
instance_eval(&proc) if block_given?
|
14
|
-
end
|
15
|
-
|
16
|
-
def add_scenario(name, line, &proc)
|
17
|
-
scenario = Scenario.new(self, name, line, &proc)
|
18
|
-
@scenarios << scenario
|
19
|
-
scenario
|
20
|
-
end
|
21
|
-
|
22
|
-
def add_scenario_outline(name, line, &proc)
|
23
|
-
scenario = ScenarioOutline.new(self, name, line, &proc)
|
24
|
-
@scenarios << scenario
|
25
|
-
scenario
|
26
|
-
end
|
27
|
-
|
28
|
-
def add_row_scenario(template_scenario, values, line)
|
29
|
-
scenario = RowScenario.new(self, template_scenario, values, line)
|
30
|
-
@scenarios << scenario
|
31
|
-
scenario
|
32
|
-
end
|
33
|
-
|
34
|
-
def add_row_scenario_outline(template_scenario, values, line)
|
35
|
-
scenario = RowScenarioOutline.new(self, template_scenario, values, line)
|
36
|
-
@scenarios << scenario
|
37
|
-
scenario
|
38
|
-
end
|
39
|
-
|
40
|
-
def scenario_named(name)
|
41
|
-
@scenarios.find {|s| s.name == name}
|
42
|
-
end
|
43
|
-
|
44
|
-
def padding_length
|
45
|
-
MIN_PADDING
|
46
|
-
end
|
47
|
-
|
48
|
-
def Scenario(name, &proc)
|
49
|
-
line = caller[0] =~ /:(\d+)$/ ? $1 : nil
|
50
|
-
add_scenario(name, line, &proc)
|
51
|
-
end
|
52
|
-
|
53
|
-
def ScenarioOutline(name, &proc)
|
54
|
-
line = caller[0] =~ /:(\d+)$/ ? $1 : nil
|
55
|
-
add_scenario_outline(name, line, &proc)
|
56
|
-
end
|
57
|
-
|
58
|
-
def Table(matrix = [], &proc)
|
59
|
-
table = Table.new(matrix)
|
60
|
-
proc.call(table)
|
61
|
-
|
62
|
-
template_scenario = @scenarios.last
|
63
|
-
template_scenario.table_header = matrix[0]
|
64
|
-
|
65
|
-
matrix[1..-1].each do |row|
|
66
|
-
if template_scenario.outline?
|
67
|
-
add_row_scenario_outline(template_scenario, row, row.line)
|
68
|
-
else
|
69
|
-
add_row_scenario(template_scenario, row, row.line)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
def accept(visitor)
|
75
|
-
visitor.visit_header(@header)
|
76
|
-
@scenarios.each do |scenario|
|
77
|
-
if scenario.outline? && !scenario.row?
|
78
|
-
visitor.visit_scenario_outline(scenario)
|
79
|
-
elsif scenario.row?
|
80
|
-
visitor.visit_row_scenario(scenario)
|
81
|
-
else
|
82
|
-
visitor.visit_regular_scenario(scenario)
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
def last_line(scenario)
|
88
|
-
next_scenario = next_scenario(scenario)
|
89
|
-
next_scenario ? next_scenario.line - 1 : lines
|
90
|
-
end
|
91
|
-
|
92
|
-
protected
|
93
|
-
|
94
|
-
def next_scenario(scenario)
|
95
|
-
index = @scenarios.index(scenario)
|
96
|
-
@scenarios[index + 1]
|
97
|
-
end
|
98
|
-
|
99
|
-
def lines
|
100
|
-
@lines ||= File.readlines(file).size
|
101
|
-
end
|
102
|
-
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Tree
|
3
|
-
class Features
|
4
|
-
def initialize
|
5
|
-
@features = []
|
6
|
-
end
|
7
|
-
|
8
|
-
def length
|
9
|
-
@features.length
|
10
|
-
end
|
11
|
-
|
12
|
-
def <<(feature)
|
13
|
-
@features << feature
|
14
|
-
end
|
15
|
-
|
16
|
-
def accept(visitor)
|
17
|
-
@features.each{|feature| visitor.visit_feature(feature)}
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|