cucumber 0.8.5 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- data/.rspec +1 -1
- data/LICENSE +1 -1
- data/Rakefile +5 -51
- data/bin/cucumber +7 -1
- data/cucumber.gemspec +463 -679
- data/examples/i18n/ar/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/he/features/step_definitons/calculator_steps.rb +1 -1
- data/examples/i18n/ro/features/step_definitons/calculator_steps.rb +4 -7
- data/examples/i18n/ru/features/division.feature +2 -2
- data/examples/i18n/tr/features/step_definitons/hesap_makinesi_adimlari.rb +3 -3
- data/examples/sinatra/features/support/env.rb +2 -5
- data/examples/v8/features/fibonacci.feature +1 -1
- data/examples/watir/features/step_definitions/search_steps.rb +1 -1
- data/features/background.feature +284 -95
- data/features/custom_formatter.feature +3 -73
- data/features/json_formatter.feature +160 -245
- data/features/step_definitions/cucumber_steps.rb +7 -153
- data/features/support/env.rb +18 -140
- data/fixtures/junit/features/pending.feature +3 -1
- data/fixtures/self_test/features/support/env.rb +8 -0
- data/fixtures/tickets/features.html +1 -1
- data/gem_tasks/examples.rake +1 -1
- data/lib/cucumber.rb +12 -0
- data/lib/cucumber/ast.rb +1 -1
- data/lib/cucumber/ast/background.rb +21 -5
- data/lib/cucumber/ast/examples.rb +12 -4
- data/lib/cucumber/ast/feature.rb +13 -5
- data/lib/cucumber/ast/feature_element.rb +9 -4
- data/lib/cucumber/ast/outline_table.rb +4 -4
- data/lib/cucumber/ast/scenario.rb +7 -5
- data/lib/cucumber/ast/scenario_outline.rb +23 -15
- data/lib/cucumber/ast/step.rb +5 -0
- data/lib/cucumber/ast/step_invocation.rb +21 -15
- data/lib/cucumber/ast/table.rb +14 -8
- data/lib/cucumber/ast/tree_walker.rb +10 -48
- data/lib/cucumber/cli/configuration.rb +33 -8
- data/lib/cucumber/cli/main.rb +20 -35
- data/lib/cucumber/cli/options.rb +8 -7
- data/lib/cucumber/cli/profile_loader.rb +2 -0
- data/lib/cucumber/core_ext/proc.rb +2 -1
- data/lib/cucumber/feature_file.rb +47 -15
- data/lib/cucumber/formatter/ansicolor.rb +3 -5
- data/lib/cucumber/formatter/console.rb +27 -23
- data/lib/cucumber/formatter/cucumber.css +34 -17
- data/lib/cucumber/formatter/cucumber.sass +173 -182
- data/lib/cucumber/formatter/html.rb +46 -11
- data/lib/cucumber/formatter/io.rb +2 -4
- data/lib/cucumber/formatter/json.rb +15 -152
- data/lib/cucumber/formatter/json_pretty.rb +5 -6
- data/lib/cucumber/formatter/junit.rb +28 -22
- data/lib/cucumber/formatter/pdf.rb +6 -6
- data/lib/cucumber/formatter/pretty.rb +5 -5
- data/lib/cucumber/formatter/rerun.rb +22 -11
- data/lib/cucumber/formatter/unicode.rb +41 -20
- data/lib/cucumber/js_support/js_dsl.js +4 -4
- data/lib/cucumber/js_support/js_language.rb +9 -5
- data/lib/cucumber/js_support/js_snippets.rb +2 -2
- data/lib/cucumber/language_support.rb +2 -2
- data/lib/cucumber/parser/gherkin_builder.rb +35 -30
- data/lib/cucumber/platform.rb +8 -8
- data/lib/cucumber/py_support/py_language.rb +2 -2
- data/lib/cucumber/rake/task.rb +80 -31
- data/lib/cucumber/rb_support/rb_dsl.rb +1 -0
- data/lib/cucumber/rb_support/rb_language.rb +10 -8
- data/lib/cucumber/rb_support/rb_step_definition.rb +8 -0
- data/lib/cucumber/rb_support/rb_transform.rb +17 -0
- data/lib/cucumber/rb_support/rb_world.rb +26 -18
- data/lib/cucumber/rspec/doubles.rb +3 -3
- data/lib/cucumber/step_match.rb +6 -2
- data/lib/cucumber/step_mother.rb +6 -427
- data/lib/cucumber/wire_support/configuration.rb +4 -1
- data/lib/cucumber/wire_support/wire_language.rb +3 -10
- data/spec/cucumber/ast/background_spec.rb +68 -6
- data/spec/cucumber/ast/feature_factory.rb +5 -4
- data/spec/cucumber/ast/feature_spec.rb +4 -4
- data/spec/cucumber/ast/outline_table_spec.rb +1 -1
- data/spec/cucumber/ast/scenario_outline_spec.rb +15 -11
- data/spec/cucumber/ast/scenario_spec.rb +4 -4
- data/spec/cucumber/ast/step_spec.rb +3 -3
- data/spec/cucumber/ast/table_spec.rb +38 -2
- data/spec/cucumber/ast/tree_walker_spec.rb +2 -2
- data/spec/cucumber/broadcaster_spec.rb +1 -1
- data/spec/cucumber/cli/configuration_spec.rb +32 -6
- data/spec/cucumber/cli/drb_client_spec.rb +2 -3
- data/spec/cucumber/cli/main_spec.rb +43 -43
- data/spec/cucumber/cli/options_spec.rb +28 -1
- data/spec/cucumber/cli/profile_loader_spec.rb +1 -1
- data/spec/cucumber/core_ext/proc_spec.rb +1 -1
- data/spec/cucumber/formatter/ansicolor_spec.rb +1 -1
- data/spec/cucumber/formatter/duration_spec.rb +1 -1
- data/spec/cucumber/formatter/html_spec.rb +3 -5
- data/spec/cucumber/formatter/junit_spec.rb +16 -2
- data/spec/cucumber/formatter/progress_spec.rb +1 -1
- data/spec/cucumber/formatter/spec_helper.rb +11 -12
- data/spec/cucumber/rb_support/rb_language_spec.rb +241 -28
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +33 -28
- data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
- data/spec/cucumber/step_match_spec.rb +11 -9
- data/spec/cucumber/wire_support/configuration_spec.rb +1 -1
- data/spec/cucumber/wire_support/connection_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_exception_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_language_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_packet_spec.rb +1 -1
- data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
- data/spec/cucumber/world/pending_spec.rb +2 -2
- data/spec/spec_helper.rb +13 -20
- metadata +11 -222
- data/.gitignore +0 -20
- data/Caliper.yml +0 -4
- data/History.txt +0 -1552
- data/README.rdoc +0 -26
- data/VERSION.yml +0 -5
- data/examples/i18n/ro/features/suma.feature +0 -11
- data/features/announce.feature +0 -164
- data/features/around_hooks.feature +0 -232
- data/features/bug_371.feature +0 -32
- data/features/bug_464.feature +0 -16
- data/features/bug_475.feature +0 -42
- data/features/bug_585_tab_indentation.feature +0 -22
- data/features/bug_600.feature +0 -67
- data/features/call_steps_from_stepdefs.feature +0 -154
- data/features/cucumber_cli.feature +0 -591
- data/features/cucumber_cli_outlines.feature +0 -117
- data/features/default_snippets.feature +0 -42
- data/features/diffing.feature +0 -25
- data/features/drb_server_integration.feature +0 -174
- data/features/exception_in_after_block.feature +0 -127
- data/features/exception_in_after_step_block.feature +0 -104
- data/features/exception_in_before_block.feature +0 -98
- data/features/exclude_files.feature +0 -20
- data/features/expand.feature +0 -60
- data/features/html_formatter.feature +0 -8
- data/features/html_formatter/a.html +0 -582
- data/features/junit_formatter.feature +0 -88
- data/features/language_from_header.feature +0 -30
- data/features/language_help.feature +0 -78
- data/features/listener_debugger_formatter.feature +0 -42
- data/features/multiline_names.feature +0 -44
- data/features/negative_tagged_hooks.feature +0 -60
- data/features/post_configuration_hook.feature +0 -37
- data/features/profiles.feature +0 -126
- data/features/rake_task.feature +0 -152
- data/features/report_called_undefined_steps.feature +0 -34
- data/features/rerun_formatter.feature +0 -45
- data/features/simplest.feature +0 -11
- data/features/snippet.feature +0 -23
- data/features/snippets_when_using_star_keyword.feature +0 -36
- data/features/step_definitions/extra_steps.rb +0 -2
- data/features/step_definitions/simplest_steps.rb +0 -3
- data/features/step_definitions/wire_steps.rb +0 -32
- data/features/support/env.rb.simplest +0 -7
- data/features/support/fake_wire_server.rb +0 -77
- data/features/table_diffing.feature +0 -45
- data/features/table_mapping.feature +0 -34
- data/features/tag_logic.feature +0 -258
- data/features/transform.feature +0 -245
- data/features/unicode_table.feature +0 -35
- data/features/usage_and_stepdefs_formatter.feature +0 -169
- data/features/wire_protocol.feature +0 -332
- data/features/wire_protocol_table_diffing.feature +0 -119
- data/features/wire_protocol_tags.feature +0 -87
- data/features/wire_protocol_timeouts.feature +0 -63
- data/features/work_in_progress.feature +0 -156
- data/fixtures/json/features/pystring.feature +0 -8
- data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +0 -12
- data/fixtures/self_test/features/background/background_with_name.feature +0 -7
- data/fixtures/self_test/features/background/failing_background.feature +0 -12
- data/fixtures/self_test/features/background/failing_background_after_success.feature +0 -11
- data/fixtures/self_test/features/background/multiline_args_background.feature +0 -32
- data/fixtures/self_test/features/background/passing_background.feature +0 -10
- data/fixtures/self_test/features/background/pending_background.feature +0 -10
- data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +0 -16
- data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +0 -16
- data/gem_tasks/features.rake +0 -14
- data/gem_tasks/sdoc.rake +0 -12
- data/lib/cucumber/ast/py_string.rb +0 -80
- data/lib/cucumber/formatter/color_io.rb +0 -23
- data/lib/cucumber/formatter/tag_cloud.rb +0 -35
- data/spec/cucumber/ast/py_string_spec.rb +0 -40
- data/spec/cucumber/formatter/color_io_spec.rb +0 -29
- data/spec/cucumber/step_mother_spec.rb +0 -302
@@ -1,16 +1,24 @@
|
|
1
|
+
require 'cucumber/ast/names'
|
2
|
+
|
1
3
|
module Cucumber
|
2
4
|
module Ast
|
3
5
|
class Examples #:nodoc:
|
6
|
+
include Names
|
4
7
|
attr_writer :outline_table
|
5
8
|
|
6
|
-
def initialize(comment, line, keyword,
|
7
|
-
@comment, @keyword, @
|
9
|
+
def initialize(comment, line, keyword, title, description, outline_table)
|
10
|
+
@comment, @keyword, @title, @description, @outline_table = comment, keyword, title, description, outline_table
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :gherkin_statement
|
14
|
+
def gherkin_statement(statement=nil)
|
15
|
+
@gherkin_statement ||= statement
|
8
16
|
end
|
9
17
|
|
10
18
|
def accept(visitor)
|
11
19
|
return if Cucumber.wants_to_quit
|
12
20
|
visitor.visit_comment(@comment) unless @comment.empty?
|
13
|
-
visitor.visit_examples_name(@keyword,
|
21
|
+
visitor.visit_examples_name(@keyword, name)
|
14
22
|
visitor.visit_outline_table(@outline_table)
|
15
23
|
end
|
16
24
|
|
@@ -27,7 +35,7 @@ module Cucumber
|
|
27
35
|
end
|
28
36
|
|
29
37
|
def to_sexp
|
30
|
-
sexp = [:examples, @keyword,
|
38
|
+
sexp = [:examples, @keyword, name]
|
31
39
|
comment = @comment.to_sexp
|
32
40
|
sexp += [comment] if comment
|
33
41
|
sexp += [@outline_table.to_sexp]
|
data/lib/cucumber/ast/feature.rb
CHANGED
@@ -1,14 +1,22 @@
|
|
1
|
+
require 'cucumber/ast/names'
|
2
|
+
|
1
3
|
module Cucumber
|
2
4
|
module Ast
|
3
5
|
# Represents the root node of a parsed feature.
|
4
6
|
class Feature #:nodoc:
|
7
|
+
include Names
|
8
|
+
|
5
9
|
attr_accessor :language
|
6
10
|
attr_writer :features, :background
|
7
11
|
attr_reader :file
|
8
|
-
attr_reader :name
|
9
12
|
|
10
|
-
def initialize(background, comment, tags, keyword,
|
11
|
-
@background, @comment, @tags, @keyword, @
|
13
|
+
def initialize(background, comment, tags, keyword, title, description, feature_elements)
|
14
|
+
@background, @comment, @tags, @keyword, @title, @description, @feature_elements = background, comment, tags, keyword, title, description, feature_elements
|
15
|
+
end
|
16
|
+
|
17
|
+
attr_reader :gherkin_statement
|
18
|
+
def gherkin_statement(statement=nil)
|
19
|
+
@gherkin_statement ||= statement
|
12
20
|
end
|
13
21
|
|
14
22
|
def init
|
@@ -38,7 +46,7 @@ module Cucumber
|
|
38
46
|
|
39
47
|
def indented_name
|
40
48
|
indent = ""
|
41
|
-
|
49
|
+
name.split("\n").map do |l|
|
42
50
|
s = "#{indent}#{l}"
|
43
51
|
indent = " "
|
44
52
|
s
|
@@ -84,7 +92,7 @@ module Cucumber
|
|
84
92
|
|
85
93
|
def to_sexp
|
86
94
|
init
|
87
|
-
sexp = [:feature, @file,
|
95
|
+
sexp = [:feature, @file, name]
|
88
96
|
comment = @comment.to_sexp
|
89
97
|
sexp += [comment] if comment
|
90
98
|
tags = @tags.to_sexp
|
@@ -6,6 +6,11 @@ module Cucumber
|
|
6
6
|
module FeatureElement #:nodoc:
|
7
7
|
attr_accessor :feature
|
8
8
|
|
9
|
+
attr_reader :gherkin_statement, :raw_steps, :title, :description
|
10
|
+
def gherkin_statement(statement=nil)
|
11
|
+
@gherkin_statement ||= statement
|
12
|
+
end
|
13
|
+
|
9
14
|
def add_step(step)
|
10
15
|
@raw_steps << step
|
11
16
|
end
|
@@ -27,10 +32,10 @@ module Cucumber
|
|
27
32
|
end
|
28
33
|
|
29
34
|
def name_line_lengths
|
30
|
-
if
|
35
|
+
if name.strip.empty?
|
31
36
|
[Ast::Step::INDENT + @keyword.unpack('U*').length + ': '.length]
|
32
37
|
else
|
33
|
-
|
38
|
+
name.split("\n").enum_for(:each_with_index).map do |line, line_number|
|
34
39
|
if line_number == 0
|
35
40
|
Ast::Step::INDENT + @keyword.unpack('U*').length + ': '.length + line.unpack('U*').length
|
36
41
|
else
|
@@ -41,10 +46,10 @@ module Cucumber
|
|
41
46
|
end
|
42
47
|
|
43
48
|
def matches_scenario_names?(scenario_name_regexps)
|
44
|
-
scenario_name_regexps.detect{|
|
49
|
+
scenario_name_regexps.detect{|n| n =~ name}
|
45
50
|
end
|
46
51
|
|
47
|
-
def backtrace_line(name = "#{@keyword}: #{
|
52
|
+
def backtrace_line(name = "#{@keyword}: #{name}", line = @line)
|
48
53
|
@feature.backtrace_line(name, line) if @feature
|
49
54
|
end
|
50
55
|
|
@@ -21,7 +21,7 @@ module Cucumber
|
|
21
21
|
return if Cucumber.wants_to_quit
|
22
22
|
init
|
23
23
|
cells_rows.each_with_index do |row, n|
|
24
|
-
if(visitor.
|
24
|
+
if(visitor.configuration.expand?)
|
25
25
|
row.accept(visitor)
|
26
26
|
else
|
27
27
|
visitor.visit_table_row(row)
|
@@ -96,7 +96,7 @@ module Cucumber
|
|
96
96
|
|
97
97
|
def accept(visitor)
|
98
98
|
return if Cucumber.wants_to_quit
|
99
|
-
visitor.
|
99
|
+
visitor.configuration.expand? ? accept_expand(visitor) : accept_plain(visitor)
|
100
100
|
end
|
101
101
|
|
102
102
|
def accept_plain(visitor)
|
@@ -108,7 +108,7 @@ module Cucumber
|
|
108
108
|
else
|
109
109
|
visitor.step_mother.with_hooks(self) do
|
110
110
|
@step_invocations.each do |step_invocation|
|
111
|
-
step_invocation.invoke(visitor.step_mother, visitor.
|
111
|
+
step_invocation.invoke(visitor.step_mother, visitor.configuration)
|
112
112
|
@exception ||= step_invocation.reported_exception
|
113
113
|
end
|
114
114
|
|
@@ -127,7 +127,7 @@ module Cucumber
|
|
127
127
|
visitor.step_mother.with_hooks(self) do
|
128
128
|
@table.visit_scenario_name(visitor, self)
|
129
129
|
@step_invocations.each do |step_invocation|
|
130
|
-
step_invocation.invoke(visitor.step_mother, visitor.
|
130
|
+
step_invocation.invoke(visitor.step_mother, visitor.configuration)
|
131
131
|
@exception ||= step_invocation.reported_exception
|
132
132
|
step_invocation.visit_step_result(visitor)
|
133
133
|
end
|
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'cucumber/ast/feature_element'
|
2
|
+
require 'cucumber/ast/names'
|
2
3
|
|
3
4
|
module Cucumber
|
4
5
|
module Ast
|
5
6
|
class Scenario #:nodoc:
|
6
7
|
include FeatureElement
|
8
|
+
include Names
|
7
9
|
|
8
|
-
attr_reader :
|
10
|
+
attr_reader :line
|
9
11
|
|
10
12
|
class EmptyBackground
|
11
13
|
def failed?
|
@@ -24,9 +26,9 @@ module Cucumber
|
|
24
26
|
end
|
25
27
|
end
|
26
28
|
|
27
|
-
def initialize(background, comment, tags, line, keyword,
|
29
|
+
def initialize(background, comment, tags, line, keyword, title, description, raw_steps)
|
28
30
|
@background = background || EmptyBackground.new
|
29
|
-
@comment, @tags, @line, @keyword, @
|
31
|
+
@comment, @tags, @line, @keyword, @title, @description, @raw_steps = comment, tags, line, keyword, title, description, raw_steps
|
30
32
|
@exception = @executed = nil
|
31
33
|
end
|
32
34
|
|
@@ -45,7 +47,7 @@ module Cucumber
|
|
45
47
|
with_visitor(visitor) do
|
46
48
|
visitor.visit_comment(@comment) unless @comment.empty?
|
47
49
|
visitor.visit_tags(@tags)
|
48
|
-
visitor.visit_scenario_name(@keyword,
|
50
|
+
visitor.visit_scenario_name(@keyword, name, file_colon_line(@line), source_indent(first_line_length))
|
49
51
|
|
50
52
|
skip_invoke! if @background.failed?
|
51
53
|
visitor.step_mother.with_hooks(self, skip_hooks?) do
|
@@ -90,7 +92,7 @@ module Cucumber
|
|
90
92
|
end
|
91
93
|
|
92
94
|
def to_sexp
|
93
|
-
sexp = [:scenario, @line, @keyword,
|
95
|
+
sexp = [:scenario, @line, @keyword, name]
|
94
96
|
comment = @comment.to_sexp
|
95
97
|
sexp += [comment] if comment
|
96
98
|
tags = @tags.to_sexp
|
@@ -1,10 +1,12 @@
|
|
1
|
+
require 'cucumber/ast/feature_element'
|
2
|
+
require 'cucumber/ast/names'
|
3
|
+
|
1
4
|
module Cucumber
|
2
5
|
module Ast
|
3
6
|
class ScenarioOutline #:nodoc:
|
4
7
|
include FeatureElement
|
8
|
+
include Names
|
5
9
|
|
6
|
-
attr_reader :name
|
7
|
-
|
8
10
|
module ExamplesArray #:nodoc:
|
9
11
|
def accept(visitor)
|
10
12
|
return if Cucumber.wants_to_quit
|
@@ -20,12 +22,12 @@ module Cucumber
|
|
20
22
|
# * Examples keyword
|
21
23
|
# * Examples section name
|
22
24
|
# * Raw matrix
|
23
|
-
def initialize(background, comment, tags, line, keyword,
|
24
|
-
@background, @comment, @tags, @line, @keyword, @
|
25
|
+
def initialize(background, comment, tags, line, keyword, title, description, raw_steps, example_sections)
|
26
|
+
@background, @comment, @tags, @line, @keyword, @title, @description, @raw_steps, @example_sections = background, comment, tags, line, keyword, title, description, raw_steps, example_sections
|
25
27
|
end
|
26
28
|
|
27
|
-
def add_examples(example_section)
|
28
|
-
@example_sections << example_section
|
29
|
+
def add_examples(example_section, gherkin_examples)
|
30
|
+
@example_sections << [example_section, gherkin_examples]
|
29
31
|
end
|
30
32
|
|
31
33
|
def init
|
@@ -33,15 +35,21 @@ module Cucumber
|
|
33
35
|
attach_steps(@raw_steps)
|
34
36
|
@steps = StepCollection.new(@raw_steps)
|
35
37
|
|
36
|
-
@examples_array = @example_sections.map do |
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
38
|
+
@examples_array = @example_sections.map do |example_section_and_gherkin_examples|
|
39
|
+
example_section = example_section_and_gherkin_examples[0]
|
40
|
+
gherkin_examples = example_section_and_gherkin_examples[1]
|
41
|
+
|
42
|
+
examples_comment = example_section[0]
|
43
|
+
examples_line = example_section[1]
|
44
|
+
examples_keyword = example_section[2]
|
45
|
+
examples_title = example_section[3]
|
46
|
+
examples_description = example_section[4]
|
47
|
+
examples_matrix = example_section[5]
|
42
48
|
|
43
49
|
examples_table = OutlineTable.new(examples_matrix, self)
|
44
|
-
Examples.new(examples_comment, examples_line, examples_keyword,
|
50
|
+
ex = Examples.new(examples_comment, examples_line, examples_keyword, examples_title, examples_description, examples_table)
|
51
|
+
ex.gherkin_statement(gherkin_examples)
|
52
|
+
ex
|
45
53
|
end
|
46
54
|
|
47
55
|
@examples_array.extend(ExamplesArray)
|
@@ -53,7 +61,7 @@ module Cucumber
|
|
53
61
|
return if Cucumber.wants_to_quit
|
54
62
|
visitor.visit_comment(@comment) unless @comment.empty?
|
55
63
|
visitor.visit_tags(@tags)
|
56
|
-
visitor.visit_scenario_name(@keyword,
|
64
|
+
visitor.visit_scenario_name(@keyword, name, file_colon_line(@line), source_indent(first_line_length))
|
57
65
|
visitor.visit_steps(@steps)
|
58
66
|
|
59
67
|
skip_invoke! if @background && @background.failed?
|
@@ -102,7 +110,7 @@ module Cucumber
|
|
102
110
|
|
103
111
|
def to_sexp
|
104
112
|
init
|
105
|
-
sexp = [:scenario_outline, @keyword,
|
113
|
+
sexp = [:scenario_outline, @keyword, name]
|
106
114
|
comment = @comment.to_sexp
|
107
115
|
sexp += [comment] if comment
|
108
116
|
tags = @tags.to_sexp
|
data/lib/cucumber/ast/step.rb
CHANGED
@@ -14,6 +14,11 @@ module Cucumber
|
|
14
14
|
@line, @keyword, @name, @multiline_arg = line, keyword, name, multiline_arg
|
15
15
|
end
|
16
16
|
|
17
|
+
attr_reader :gherkin_statement
|
18
|
+
def gherkin_statement(statement=nil)
|
19
|
+
@gherkin_statement ||= statement
|
20
|
+
end
|
21
|
+
|
17
22
|
def background?
|
18
23
|
false
|
19
24
|
end
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require 'cucumber/errors'
|
1
2
|
require 'cucumber/step_match'
|
2
3
|
require 'cucumber/ast/table'
|
3
4
|
require 'gherkin/rubify'
|
@@ -38,7 +39,7 @@ module Cucumber
|
|
38
39
|
|
39
40
|
def accept(visitor)
|
40
41
|
return if Cucumber.wants_to_quit
|
41
|
-
invoke(visitor.step_mother, visitor.
|
42
|
+
invoke(visitor.step_mother, visitor.configuration)
|
42
43
|
visit_step_result(visitor)
|
43
44
|
end
|
44
45
|
|
@@ -54,63 +55,64 @@ module Cucumber
|
|
54
55
|
)
|
55
56
|
end
|
56
57
|
|
57
|
-
def invoke(step_mother,
|
58
|
-
find_step_match!(step_mother)
|
59
|
-
unless @skip_invoke ||
|
58
|
+
def invoke(step_mother, configuration)
|
59
|
+
find_step_match!(step_mother, configuration)
|
60
|
+
unless @skip_invoke || configuration.dry_run? || @exception || @step_collection.exception
|
60
61
|
@skip_invoke = true
|
61
62
|
begin
|
62
63
|
@step_match.invoke(@multiline_arg)
|
63
64
|
step_mother.after_step
|
64
65
|
status!(:passed)
|
65
66
|
rescue Pending => e
|
66
|
-
failed(
|
67
|
+
failed(configuration, e, false)
|
67
68
|
status!(:pending)
|
68
69
|
rescue Undefined => e
|
69
|
-
failed(
|
70
|
+
failed(configuration, e, false)
|
70
71
|
status!(:undefined)
|
71
72
|
rescue Cucumber::Ast::Table::Different => e
|
72
73
|
@different_table = e.table
|
73
|
-
failed(
|
74
|
+
failed(configuration, e, false)
|
74
75
|
status!(:failed)
|
75
76
|
rescue Exception => e
|
76
|
-
failed(
|
77
|
+
failed(configuration, e, false)
|
77
78
|
status!(:failed)
|
78
79
|
end
|
79
80
|
end
|
80
81
|
end
|
81
82
|
|
82
|
-
def find_step_match!(step_mother)
|
83
|
+
def find_step_match!(step_mother, configuration)
|
83
84
|
return if @step_match
|
84
85
|
begin
|
85
86
|
@step_match = step_mother.step_match(@name)
|
86
87
|
rescue Undefined => e
|
87
|
-
failed(
|
88
|
+
failed(configuration, e, true)
|
88
89
|
status!(:undefined)
|
89
90
|
@step_match = NoStepMatch.new(@step, @name)
|
90
91
|
rescue Ambiguous => e
|
91
|
-
failed(
|
92
|
+
failed(configuration, e, false)
|
92
93
|
status!(:failed)
|
93
94
|
@step_match = NoStepMatch.new(@step, @name)
|
94
95
|
end
|
95
96
|
step_mother.step_visited(self)
|
96
97
|
end
|
97
98
|
|
98
|
-
def failed(
|
99
|
+
def failed(configuration, e, clear_backtrace)
|
99
100
|
e = filter_backtrace(e)
|
100
101
|
e.set_backtrace([]) if clear_backtrace
|
101
102
|
e.backtrace << @step.backtrace_line unless @step.backtrace_line.nil?
|
102
103
|
@exception = e
|
103
|
-
if(
|
104
|
+
if(configuration.strict? || !(Undefined === e) || e.nested?)
|
104
105
|
@reported_exception = e
|
105
106
|
else
|
106
107
|
@reported_exception = nil
|
107
108
|
end
|
108
109
|
end
|
109
110
|
|
111
|
+
PWD_PATTERN = /#{Regexp.escape(Dir.pwd)}\//m
|
112
|
+
|
110
113
|
def filter_backtrace(e)
|
111
114
|
return e if Cucumber.use_full_backtrace
|
112
|
-
|
113
|
-
(e.backtrace || []).each{|line| line.gsub!(pwd, "./")}
|
115
|
+
(e.backtrace || []).each{|line| line.gsub!(PWD_PATTERN, "./")}
|
114
116
|
|
115
117
|
filtered = (e.backtrace || []).reject do |line|
|
116
118
|
BACKTRACE_FILTER_PATTERNS.detect { |p| line =~ p }
|
@@ -185,6 +187,10 @@ module Cucumber
|
|
185
187
|
@step.language
|
186
188
|
end
|
187
189
|
|
190
|
+
def gherkin_statement
|
191
|
+
@step.gherkin_statement
|
192
|
+
end
|
193
|
+
|
188
194
|
def to_sexp
|
189
195
|
[:step_invocation, @step.line, @step.keyword, @name, (@multiline_arg.nil? ? nil : @multiline_arg.to_sexp)].compact
|
190
196
|
end
|
data/lib/cucumber/ast/table.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'gherkin/rubify'
|
2
|
+
require 'gherkin/lexer/i18n_lexer'
|
2
3
|
require 'gherkin/formatter/escaping'
|
3
4
|
|
4
5
|
module Cucumber
|
@@ -60,7 +61,7 @@ module Cucumber
|
|
60
61
|
|
61
62
|
def self.parse(text, uri, offset)
|
62
63
|
builder = Builder.new
|
63
|
-
lexer = Gherkin::I18nLexer.new(builder)
|
64
|
+
lexer = Gherkin::Lexer::I18nLexer.new(builder)
|
64
65
|
lexer.scan(text)
|
65
66
|
new(builder.rows)
|
66
67
|
end
|
@@ -73,7 +74,6 @@ module Cucumber
|
|
73
74
|
def initialize(raw, conversion_procs = NULL_CONVERSIONS.dup)
|
74
75
|
@cells_class = Cells
|
75
76
|
@cell_class = Cell
|
76
|
-
|
77
77
|
raw = ensure_array_of_array(rubify(raw))
|
78
78
|
# Verify that it's square
|
79
79
|
transposed = raw.transpose
|
@@ -153,7 +153,7 @@ module Cucumber
|
|
153
153
|
#
|
154
154
|
# gets converted into the following:
|
155
155
|
#
|
156
|
-
# [['a', 'b], ['c', 'd']]
|
156
|
+
# [['a', 'b'], ['c', 'd']]
|
157
157
|
#
|
158
158
|
def raw
|
159
159
|
cell_matrix.map do |row|
|
@@ -163,9 +163,14 @@ module Cucumber
|
|
163
163
|
end
|
164
164
|
end
|
165
165
|
|
166
|
-
|
166
|
+
def column_names #:nodoc:
|
167
|
+
@col_names ||= cell_matrix[0].map { |cell| cell.value }
|
168
|
+
end
|
169
|
+
|
167
170
|
def rows
|
168
|
-
|
171
|
+
hashes.map do |hash|
|
172
|
+
hash.values_at *headers
|
173
|
+
end
|
169
174
|
end
|
170
175
|
|
171
176
|
def each_cells_row(&proc) #:nodoc:
|
@@ -271,8 +276,9 @@ module Cucumber
|
|
271
276
|
# end
|
272
277
|
#
|
273
278
|
def map_column!(column_name, strict=true, &conversion_proc)
|
274
|
-
verify_column(column_name) if strict
|
275
|
-
@conversion_procs[column_name] = conversion_proc
|
279
|
+
verify_column(column_name.to_s) if strict
|
280
|
+
@conversion_procs[column_name.to_s] = conversion_proc
|
281
|
+
self
|
276
282
|
end
|
277
283
|
|
278
284
|
# Compares +other_table+ to self. If +other_table+ contains columns
|
@@ -379,7 +385,7 @@ module Cucumber
|
|
379
385
|
hash = Hash.new do |hash, key|
|
380
386
|
hash[key.to_s] if key.is_a?(Symbol)
|
381
387
|
end
|
382
|
-
|
388
|
+
column_names.each_with_index do |column_name, column_index|
|
383
389
|
value = @conversion_procs[column_name].call(cells.value(column_index))
|
384
390
|
hash[column_name] = value
|
385
391
|
end
|