cucumber 0.8.6 → 0.8.7
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/.rspec +1 -1
- data/Caliper.yml +4 -0
- data/History.txt +1557 -0
- data/LICENSE +1 -1
- data/README.rdoc +26 -0
- data/Rakefile +51 -5
- data/VERSION.yml +5 -0
- data/bin/cucumber +1 -7
- data/cucumber.gemspec +77 -3
- 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 +7 -4
- data/examples/i18n/ro/features/suma.feature +11 -0
- 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 +5 -2
- data/examples/v8/features/fibonacci.feature +1 -1
- data/examples/watir/features/step_definitions/search_steps.rb +1 -1
- data/features/announce.feature +164 -0
- data/features/around_hooks.feature +232 -0
- data/features/background.feature +95 -284
- data/features/bug_371.feature +32 -0
- data/features/bug_464.feature +16 -0
- data/features/bug_475.feature +42 -0
- data/features/bug_585_tab_indentation.feature +22 -0
- data/features/bug_600.feature +67 -0
- data/features/call_steps_from_stepdefs.feature +154 -0
- data/features/cucumber_cli.feature +591 -0
- data/features/cucumber_cli_outlines.feature +117 -0
- data/features/custom_formatter.feature +73 -3
- data/features/default_snippets.feature +42 -0
- data/features/diffing.feature +25 -0
- data/features/drb_server_integration.feature +174 -0
- data/features/exception_in_after_block.feature +127 -0
- data/features/exception_in_after_step_block.feature +104 -0
- data/features/exception_in_before_block.feature +98 -0
- data/features/exclude_files.feature +20 -0
- data/features/expand.feature +60 -0
- data/features/html_formatter.feature +8 -0
- data/features/html_formatter/a.html +582 -0
- data/features/json_formatter.feature +245 -160
- data/features/junit_formatter.feature +88 -0
- data/features/language_from_header.feature +30 -0
- data/features/language_help.feature +78 -0
- data/features/listener_debugger_formatter.feature +42 -0
- data/features/multiline_names.feature +44 -0
- data/features/negative_tagged_hooks.feature +60 -0
- data/features/post_configuration_hook.feature +37 -0
- data/features/profiles.feature +126 -0
- data/features/rake_task.feature +152 -0
- data/features/report_called_undefined_steps.feature +34 -0
- data/features/rerun_formatter.feature +45 -0
- data/features/simplest.feature +11 -0
- data/features/snippet.feature +23 -0
- data/features/snippets_when_using_star_keyword.feature +36 -0
- data/features/step_definitions/cucumber_steps.rb +153 -7
- data/features/step_definitions/extra_steps.rb +2 -0
- data/features/step_definitions/simplest_steps.rb +3 -0
- data/features/step_definitions/wire_steps.rb +32 -0
- data/features/support/env.rb +140 -18
- data/features/support/env.rb.simplest +7 -0
- data/features/support/fake_wire_server.rb +77 -0
- data/features/table_diffing.feature +45 -0
- data/features/table_mapping.feature +34 -0
- data/features/tag_logic.feature +258 -0
- data/features/transform.feature +245 -0
- data/features/unicode_table.feature +35 -0
- data/features/usage_and_stepdefs_formatter.feature +169 -0
- data/features/wire_protocol.feature +332 -0
- data/features/wire_protocol_table_diffing.feature +119 -0
- data/features/wire_protocol_tags.feature +87 -0
- data/features/wire_protocol_timeouts.feature +63 -0
- data/features/work_in_progress.feature +156 -0
- data/fixtures/json/features/pystring.feature +8 -0
- data/fixtures/junit/features/pending.feature +1 -3
- data/fixtures/self_test/features/background/background_tagged_before_on_outline.feature +12 -0
- data/fixtures/self_test/features/background/background_with_name.feature +7 -0
- data/fixtures/self_test/features/background/failing_background.feature +12 -0
- data/fixtures/self_test/features/background/failing_background_after_success.feature +11 -0
- data/fixtures/self_test/features/background/multiline_args_background.feature +32 -0
- data/fixtures/self_test/features/background/passing_background.feature +10 -0
- data/fixtures/self_test/features/background/pending_background.feature +10 -0
- data/fixtures/self_test/features/background/scenario_outline_failing_background.feature +16 -0
- data/fixtures/self_test/features/background/scenario_outline_passing_background.feature +16 -0
- data/fixtures/self_test/features/support/env.rb +0 -8
- data/fixtures/tickets/features.html +1 -1
- data/gem_tasks/examples.rake +1 -1
- data/gem_tasks/features.rake +14 -0
- data/gem_tasks/sdoc.rake +12 -0
- data/lib/cucumber.rb +0 -12
- data/lib/cucumber/ast.rb +1 -1
- data/lib/cucumber/ast/background.rb +5 -21
- data/lib/cucumber/ast/examples.rb +4 -12
- data/lib/cucumber/ast/feature.rb +5 -13
- data/lib/cucumber/ast/feature_element.rb +4 -9
- data/lib/cucumber/ast/outline_table.rb +4 -4
- data/lib/cucumber/ast/py_string.rb +80 -0
- data/lib/cucumber/ast/scenario.rb +5 -7
- data/lib/cucumber/ast/scenario_outline.rb +15 -23
- data/lib/cucumber/ast/step.rb +0 -5
- data/lib/cucumber/ast/step_invocation.rb +15 -21
- data/lib/cucumber/ast/table.rb +8 -14
- data/lib/cucumber/ast/tree_walker.rb +48 -10
- data/lib/cucumber/cli/configuration.rb +8 -33
- data/lib/cucumber/cli/main.rb +35 -20
- data/lib/cucumber/cli/options.rb +7 -8
- data/lib/cucumber/cli/profile_loader.rb +0 -2
- data/lib/cucumber/core_ext/proc.rb +1 -2
- data/lib/cucumber/feature_file.rb +15 -47
- data/lib/cucumber/formatter/ansicolor.rb +5 -3
- data/lib/cucumber/formatter/color_io.rb +23 -0
- data/lib/cucumber/formatter/console.rb +23 -27
- data/lib/cucumber/formatter/cucumber.css +17 -34
- data/lib/cucumber/formatter/cucumber.sass +182 -173
- data/lib/cucumber/formatter/html.rb +11 -46
- data/lib/cucumber/formatter/io.rb +4 -2
- data/lib/cucumber/formatter/json.rb +152 -15
- data/lib/cucumber/formatter/json_pretty.rb +6 -5
- data/lib/cucumber/formatter/junit.rb +22 -28
- data/lib/cucumber/formatter/pdf.rb +6 -6
- data/lib/cucumber/formatter/pretty.rb +5 -5
- data/lib/cucumber/formatter/rerun.rb +11 -22
- data/lib/cucumber/formatter/tag_cloud.rb +35 -0
- data/lib/cucumber/formatter/unicode.rb +20 -41
- data/lib/cucumber/js_support/js_dsl.js +4 -4
- data/lib/cucumber/js_support/js_language.rb +5 -9
- 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 +30 -35
- data/lib/cucumber/platform.rb +8 -8
- data/lib/cucumber/py_support/py_language.rb +2 -2
- data/lib/cucumber/rake/task.rb +31 -74
- data/lib/cucumber/rb_support/rb_dsl.rb +0 -1
- data/lib/cucumber/rb_support/rb_language.rb +8 -10
- data/lib/cucumber/rb_support/rb_step_definition.rb +0 -8
- data/lib/cucumber/rb_support/rb_transform.rb +0 -17
- data/lib/cucumber/rb_support/rb_world.rb +18 -26
- data/lib/cucumber/rspec/doubles.rb +3 -3
- data/lib/cucumber/step_match.rb +2 -6
- data/lib/cucumber/step_mother.rb +427 -6
- data/lib/cucumber/wire_support/configuration.rb +1 -4
- data/lib/cucumber/wire_support/wire_language.rb +10 -3
- data/spec/cucumber/ast/background_spec.rb +6 -68
- data/spec/cucumber/ast/feature_factory.rb +4 -5
- data/spec/cucumber/ast/feature_spec.rb +4 -4
- data/spec/cucumber/ast/outline_table_spec.rb +1 -1
- data/spec/cucumber/ast/py_string_spec.rb +40 -0
- data/spec/cucumber/ast/scenario_outline_spec.rb +11 -15
- 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 +2 -38
- 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 +6 -32
- data/spec/cucumber/cli/drb_client_spec.rb +3 -2
- data/spec/cucumber/cli/main_spec.rb +43 -43
- data/spec/cucumber/cli/options_spec.rb +1 -28
- 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/color_io_spec.rb +29 -0
- data/spec/cucumber/formatter/duration_spec.rb +1 -1
- data/spec/cucumber/formatter/html_spec.rb +5 -3
- data/spec/cucumber/formatter/junit_spec.rb +2 -16
- data/spec/cucumber/formatter/progress_spec.rb +1 -1
- data/spec/cucumber/formatter/spec_helper.rb +12 -11
- data/spec/cucumber/rb_support/rb_language_spec.rb +28 -241
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +28 -33
- data/spec/cucumber/rb_support/regexp_argument_matcher_spec.rb +1 -1
- data/spec/cucumber/step_match_spec.rb +9 -11
- data/spec/cucumber/step_mother_spec.rb +302 -0
- 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 +20 -13
- metadata +78 -4
|
@@ -5,17 +5,14 @@ require 'cucumber/formatter/ansicolor'
|
|
|
5
5
|
$KCODE='u' unless Cucumber::RUBY_1_9
|
|
6
6
|
|
|
7
7
|
if Cucumber::WINDOWS
|
|
8
|
-
require 'iconv'
|
|
8
|
+
require 'iconv'
|
|
9
9
|
|
|
10
10
|
if ENV['CUCUMBER_OUTPUT_ENCODING']
|
|
11
11
|
Cucumber::CODEPAGE = ENV['CUCUMBER_OUTPUT_ENCODING']
|
|
12
|
+
elsif Cucumber::WINDOWS_MRI
|
|
13
|
+
Cucumber::CODEPAGE = "cp#{Win32::Console::OutputCP()}"
|
|
12
14
|
elsif `cmd /c chcp` =~ /(\d+)/
|
|
13
|
-
|
|
14
|
-
Cucumber::CODEPAGE = 'UTF-8'
|
|
15
|
-
ENV['ANSICON_API'] = 'ruby'
|
|
16
|
-
else
|
|
17
|
-
Cucumber::CODEPAGE = "cp#{$1.to_i}"
|
|
18
|
-
end
|
|
15
|
+
Cucumber::CODEPAGE = "cp#{$1.to_i}"
|
|
19
16
|
else
|
|
20
17
|
Cucumber::CODEPAGE = "cp1252"
|
|
21
18
|
STDERR.puts("WARNING: Couldn't detect your output codepage. Assuming it is 1252. You may have to chcp 1252 or SET CUCUMBER_OUTPUT_ENCODING=cp1252.")
|
|
@@ -27,45 +24,27 @@ if Cucumber::WINDOWS
|
|
|
27
24
|
o.instance_eval do
|
|
28
25
|
alias cucumber_print print
|
|
29
26
|
def print(*a)
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
begin
|
|
39
|
-
cucumber_print(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
|
|
40
|
-
rescue Iconv::InvalidEncoding => e
|
|
41
|
-
STDERR.cucumber_puts("WARNING: #{e.message}")
|
|
42
|
-
cucumber_print(*a)
|
|
43
|
-
rescue Iconv::IllegalSequence => e
|
|
44
|
-
STDERR.cucumber_puts("WARNING: #{e.message}")
|
|
45
|
-
cucumber_print(*a)
|
|
46
|
-
end
|
|
27
|
+
begin
|
|
28
|
+
cucumber_print(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
|
|
29
|
+
rescue Iconv::InvalidEncoding => e
|
|
30
|
+
STDERR.cucumber_puts("WARNING: #{e.message}")
|
|
31
|
+
cucumber_print(*a)
|
|
32
|
+
rescue Iconv::IllegalSequence => e
|
|
33
|
+
STDERR.cucumber_puts("WARNING: #{e.message}")
|
|
34
|
+
cucumber_print(*a)
|
|
47
35
|
end
|
|
48
36
|
end
|
|
49
37
|
|
|
50
38
|
alias cucumber_puts puts
|
|
51
39
|
def puts(*a)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
begin
|
|
61
|
-
cucumber_puts(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
|
|
62
|
-
rescue Iconv::InvalidEncoding => e
|
|
63
|
-
STDERR.cucumber_print("WARNING: #{e.message}")
|
|
64
|
-
cucumber_print(*a)
|
|
65
|
-
rescue Iconv::IllegalSequence => e
|
|
66
|
-
STDERR.cucumber_puts("WARNING: #{e.message}")
|
|
67
|
-
cucumber_puts(*a)
|
|
68
|
-
end
|
|
40
|
+
begin
|
|
41
|
+
cucumber_puts(*Iconv.iconv(Cucumber::CODEPAGE, "UTF-8", *a.map{|a|a.to_s}))
|
|
42
|
+
rescue Iconv::InvalidEncoding => e
|
|
43
|
+
STDERR.cucumber_print("WARNING: #{e.message}")
|
|
44
|
+
cucumber_print(*a)
|
|
45
|
+
rescue Iconv::IllegalSequence => e
|
|
46
|
+
STDERR.cucumber_puts("WARNING: #{e.message}")
|
|
47
|
+
cucumber_puts(*a)
|
|
69
48
|
end
|
|
70
49
|
end
|
|
71
50
|
end
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
var CucumberJsDsl = {
|
|
2
2
|
registerStepDefinition: function(regexp, func) {
|
|
3
3
|
if(func == null) {
|
|
4
|
-
jsLanguage.
|
|
4
|
+
jsLanguage.executeStepDefinition(regexp);
|
|
5
5
|
}
|
|
6
6
|
else{
|
|
7
|
-
jsLanguage.
|
|
7
|
+
jsLanguage.addStepDefinition(regexp, func);
|
|
8
8
|
}
|
|
9
9
|
},
|
|
10
10
|
|
|
11
11
|
registerTransform: function(regexp, func) {
|
|
12
|
-
jsLanguage.
|
|
12
|
+
jsLanguage.registerJsTransform(regexp, func);
|
|
13
13
|
},
|
|
14
14
|
|
|
15
15
|
beforeHook: function(tag_expressions_or_func, func) {
|
|
@@ -40,7 +40,7 @@ var CucumberJsDsl = {
|
|
|
40
40
|
var hook_func = tag_expressions_or_func;
|
|
41
41
|
var tag_expressions = [];
|
|
42
42
|
}
|
|
43
|
-
jsLanguage.
|
|
43
|
+
jsLanguage.registerJsHook(label, tag_expressions, hook_func);
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
46
|
|
|
@@ -39,10 +39,6 @@ module Cucumber
|
|
|
39
39
|
@js_language.current_world.execute(@js_function, args)
|
|
40
40
|
end
|
|
41
41
|
|
|
42
|
-
def regexp_source
|
|
43
|
-
@regexp.inspect
|
|
44
|
-
end
|
|
45
|
-
|
|
46
42
|
def arguments_from(step_name)
|
|
47
43
|
matches = eval_js "#{@regexp}.exec('#{step_name}')"
|
|
48
44
|
if matches
|
|
@@ -105,10 +101,10 @@ module Cucumber
|
|
|
105
101
|
include LanguageSupport::LanguageMethods
|
|
106
102
|
include JsSnippets
|
|
107
103
|
|
|
108
|
-
def initialize(
|
|
104
|
+
def initialize(step_mother)
|
|
109
105
|
@step_definitions = []
|
|
110
106
|
@world = JsWorld.new
|
|
111
|
-
@
|
|
107
|
+
@step_mother = step_mother
|
|
112
108
|
|
|
113
109
|
@world["jsLanguage"] = self
|
|
114
110
|
@world.load(File.dirname(__FILE__) + '/js_dsl.js')
|
|
@@ -150,7 +146,7 @@ module Cucumber
|
|
|
150
146
|
|
|
151
147
|
#TODO: support multiline arguments when calling steps from within steps
|
|
152
148
|
def execute_step_definition(name, multiline_argument = nil)
|
|
153
|
-
@
|
|
149
|
+
@step_mother.step_match(name).invoke(multiline_argument)
|
|
154
150
|
end
|
|
155
151
|
|
|
156
152
|
def register_js_hook(phase, tag_expressions, js_function)
|
|
@@ -166,12 +162,12 @@ module Cucumber
|
|
|
166
162
|
end
|
|
167
163
|
|
|
168
164
|
def steps(steps_text, file_colon_line)
|
|
169
|
-
@
|
|
165
|
+
@step_mother.invoke_steps(steps_text, @language, file_colon_line)
|
|
170
166
|
end
|
|
171
167
|
|
|
172
168
|
private
|
|
173
169
|
def path_to_load_js_from
|
|
174
|
-
paths = @
|
|
170
|
+
paths = @step_mother.options[:paths]
|
|
175
171
|
if paths.empty?
|
|
176
172
|
'' # Using rake
|
|
177
173
|
else
|
|
@@ -4,7 +4,7 @@ module Cucumber
|
|
|
4
4
|
PARAM_PATTERN = /"([^"]*)"/
|
|
5
5
|
ESCAPED_PARAM_PATTERN = '"([^\\"]*)"'
|
|
6
6
|
|
|
7
|
-
def snippet_text(
|
|
7
|
+
def snippet_text(step_keyword, step_name, multiline_arg_class)
|
|
8
8
|
escaped = Regexp.escape(step_name).gsub('\ ', ' ').gsub('/', '\/')
|
|
9
9
|
escaped = escaped.gsub(PARAM_PATTERN, ESCAPED_PARAM_PATTERN)
|
|
10
10
|
|
|
@@ -20,7 +20,7 @@ module Cucumber
|
|
|
20
20
|
multiline_class_comment = "//#{multiline_arg_class.default_arg_name} is a #{multiline_arg_class.to_s}\n"
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
"#{
|
|
23
|
+
"#{step_keyword}(/^#{escaped}$/, function(#{block_arg_string}){\n #{multiline_class_comment} //express the regexp above with the code you wish you had\n});"
|
|
24
24
|
end
|
|
25
25
|
end
|
|
26
26
|
end
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
module Cucumber
|
|
2
|
-
# This module defines the API for programming
|
|
2
|
+
# This module defines the API for programming panguage support in Cucumber.
|
|
3
3
|
# While Cucumber itself is written in Ruby, any programming language can
|
|
4
4
|
# be supported by implementing this API.
|
|
5
5
|
#
|
|
@@ -27,4 +27,4 @@ module Cucumber
|
|
|
27
27
|
#
|
|
28
28
|
module LanguageSupport
|
|
29
29
|
end
|
|
30
|
-
end
|
|
30
|
+
end
|
|
@@ -13,33 +13,28 @@ module Cucumber
|
|
|
13
13
|
@feature || @multiline_arg
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
def feature(
|
|
16
|
+
def feature(statement, uri)
|
|
17
17
|
@feature = Ast::Feature.new(
|
|
18
18
|
nil,
|
|
19
|
-
Ast::Comment.new(
|
|
20
|
-
Ast::Tags.new(nil,
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
feature.description.rstrip,
|
|
19
|
+
Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")),
|
|
20
|
+
Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
|
|
21
|
+
statement.keyword,
|
|
22
|
+
legacy_name_for(statement.name, statement.description),
|
|
24
23
|
[]
|
|
25
24
|
)
|
|
26
|
-
@feature.gherkin_statement(feature)
|
|
27
|
-
@feature
|
|
28
25
|
end
|
|
29
26
|
|
|
30
|
-
def background(
|
|
27
|
+
def background(statement)
|
|
31
28
|
@background = Ast::Background.new(
|
|
32
|
-
Ast::Comment.new(
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
background.description,
|
|
29
|
+
Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")),
|
|
30
|
+
statement.line,
|
|
31
|
+
statement.keyword,
|
|
32
|
+
legacy_name_for(statement.name, statement.description),
|
|
37
33
|
steps=[]
|
|
38
34
|
)
|
|
39
35
|
@feature.background = @background
|
|
40
36
|
@background.feature = @feature
|
|
41
37
|
@step_container = @background
|
|
42
|
-
@background.gherkin_statement(background)
|
|
43
38
|
end
|
|
44
39
|
|
|
45
40
|
def scenario(statement)
|
|
@@ -49,14 +44,12 @@ module Cucumber
|
|
|
49
44
|
Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
|
|
50
45
|
statement.line,
|
|
51
46
|
statement.keyword,
|
|
52
|
-
statement.name,
|
|
53
|
-
statement.description,
|
|
47
|
+
legacy_name_for(statement.name, statement.description),
|
|
54
48
|
steps=[]
|
|
55
49
|
)
|
|
56
50
|
@feature.add_feature_element(scenario)
|
|
57
51
|
@background.feature_elements << scenario if @background
|
|
58
52
|
@step_container = scenario
|
|
59
|
-
scenario.gherkin_statement(statement)
|
|
60
53
|
end
|
|
61
54
|
|
|
62
55
|
def scenario_outline(statement)
|
|
@@ -66,8 +59,7 @@ module Cucumber
|
|
|
66
59
|
Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
|
|
67
60
|
statement.line,
|
|
68
61
|
statement.keyword,
|
|
69
|
-
statement.name,
|
|
70
|
-
statement.description,
|
|
62
|
+
legacy_name_for(statement.name, statement.description),
|
|
71
63
|
steps=[],
|
|
72
64
|
example_sections=[]
|
|
73
65
|
)
|
|
@@ -77,28 +69,25 @@ module Cucumber
|
|
|
77
69
|
@background.feature_elements << scenario_outline
|
|
78
70
|
end
|
|
79
71
|
@step_container = scenario_outline
|
|
80
|
-
scenario_outline.gherkin_statement(statement)
|
|
81
72
|
end
|
|
82
73
|
|
|
83
|
-
def examples(
|
|
74
|
+
def examples(statement, examples_rows)
|
|
84
75
|
examples_fields = [
|
|
85
|
-
Ast::Comment.new(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
matrix(examples.rows)
|
|
76
|
+
Ast::Comment.new(statement.comments.map{|comment| comment.value}.join("\n")),
|
|
77
|
+
statement.line,
|
|
78
|
+
statement.keyword,
|
|
79
|
+
legacy_name_for(statement.name, statement.description),
|
|
80
|
+
matrix(examples_rows)
|
|
91
81
|
]
|
|
92
|
-
@step_container.add_examples(examples_fields
|
|
82
|
+
@step_container.add_examples(examples_fields)
|
|
93
83
|
end
|
|
94
84
|
|
|
95
|
-
def step(
|
|
96
|
-
@table_owner = Ast::Step.new(
|
|
97
|
-
|
|
98
|
-
multiline_arg = rubify(step.multiline_arg)
|
|
85
|
+
def step(statement, multiline_arg, result)
|
|
86
|
+
@table_owner = Ast::Step.new(statement.line, statement.keyword, statement.name)
|
|
87
|
+
multiline_arg = rubify(multiline_arg)
|
|
99
88
|
case(multiline_arg)
|
|
100
|
-
when Gherkin::Formatter::Model::
|
|
101
|
-
@table_owner.multiline_arg = Ast::
|
|
89
|
+
when Gherkin::Formatter::Model::PyString
|
|
90
|
+
@table_owner.multiline_arg = Ast::PyString.new(multiline_arg.value)
|
|
102
91
|
when Array
|
|
103
92
|
@table_owner.multiline_arg = Ast::Table.new(matrix(multiline_arg))
|
|
104
93
|
end
|
|
@@ -114,6 +103,12 @@ module Cucumber
|
|
|
114
103
|
|
|
115
104
|
private
|
|
116
105
|
|
|
106
|
+
def legacy_name_for(name, description)
|
|
107
|
+
s = name
|
|
108
|
+
s += "\n#{description}" if description != ""
|
|
109
|
+
s
|
|
110
|
+
end
|
|
111
|
+
|
|
117
112
|
def matrix(gherkin_table)
|
|
118
113
|
gherkin_table.map do |gherkin_row|
|
|
119
114
|
row = gherkin_row.cells
|
data/lib/cucumber/platform.rb
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
# Detect the platform we're running on so we can tweak behaviour
|
|
2
2
|
# in various places.
|
|
3
3
|
require 'rbconfig'
|
|
4
|
+
require 'yaml'
|
|
4
5
|
|
|
5
6
|
module Cucumber
|
|
6
|
-
|
|
7
|
-
VERSION =
|
|
7
|
+
version = YAML.load_file(File.dirname(__FILE__) + '/../../VERSION.yml')
|
|
8
|
+
VERSION = [version[:major], version[:minor], version[:patch], version[:build]].compact.join('.')
|
|
8
9
|
BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
|
|
9
10
|
LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
|
10
11
|
JRUBY = defined?(JRUBY_VERSION)
|
|
11
12
|
IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == "ironruby"
|
|
12
|
-
WINDOWS =
|
|
13
|
-
OS_X =
|
|
13
|
+
WINDOWS = Config::CONFIG['host_os'] =~ /mswin|mingw/
|
|
14
|
+
OS_X = Config::CONFIG['host_os'] =~ /darwin/
|
|
14
15
|
WINDOWS_MRI = WINDOWS && !JRUBY && !IRONRUBY
|
|
15
16
|
RAILS = defined?(Rails)
|
|
16
|
-
RUBY_BINARY = File.join(
|
|
17
|
+
RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
|
|
17
18
|
RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
|
|
18
19
|
RUBY_1_8_7 = RUBY_VERSION =~ /^1\.8\.7/
|
|
19
20
|
|
|
20
21
|
class << self
|
|
21
22
|
attr_accessor :use_full_backtrace
|
|
22
23
|
|
|
23
|
-
def file_mode(m
|
|
24
|
-
RUBY_1_9 ? "#{m}
|
|
24
|
+
def file_mode(m) #:nodoc:
|
|
25
|
+
RUBY_1_9 ? "#{m}:UTF-8" : m
|
|
25
26
|
end
|
|
26
27
|
end
|
|
27
28
|
self.use_full_backtrace = false
|
|
28
29
|
end
|
|
29
|
-
end
|
|
@@ -28,8 +28,8 @@ module Cucumber
|
|
|
28
28
|
mod = import(py_file)
|
|
29
29
|
end
|
|
30
30
|
|
|
31
|
-
def snippet_text(
|
|
32
|
-
"python snippet: #{
|
|
31
|
+
def snippet_text(step_keyword, step_name, multiline_arg_class)
|
|
32
|
+
"python snippet: #{step_keyword}, #{step_name}"
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def begin_scenario(scenario)
|
data/lib/cucumber/rake/task.rb
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
require 'cucumber/platform'
|
|
2
|
-
require 'gherkin/formatter/ansi_escapes'
|
|
3
2
|
|
|
4
3
|
begin
|
|
5
4
|
# Support Rake > 0.8.7
|
|
@@ -7,7 +6,6 @@ begin
|
|
|
7
6
|
include Rake::DSL
|
|
8
7
|
rescue LoadError
|
|
9
8
|
end
|
|
10
|
-
|
|
11
9
|
module Cucumber
|
|
12
10
|
module Rake
|
|
13
11
|
# Defines a Rake task for running features.
|
|
@@ -16,7 +14,7 @@ module Cucumber
|
|
|
16
14
|
#
|
|
17
15
|
# Cucumber::Rake::Task.new
|
|
18
16
|
#
|
|
19
|
-
# This will define a task named <tt>cucumber</tt> described as 'Run Cucumber features'.
|
|
17
|
+
# This will define a task named <tt>cucumber</tt> described as 'Run Cucumber features'.
|
|
20
18
|
# It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
|
|
21
19
|
#
|
|
22
20
|
# To further configure the task, you can pass a block:
|
|
@@ -30,96 +28,68 @@ module Cucumber
|
|
|
30
28
|
# Cucumber::Rake::Task.new do |t|
|
|
31
29
|
# t.rcov = true
|
|
32
30
|
# end
|
|
33
|
-
#
|
|
31
|
+
#
|
|
34
32
|
# See the attributes for additional configuration possibilities.
|
|
35
33
|
class Task
|
|
36
|
-
include Gherkin::Formatter::AnsiEscapes
|
|
37
|
-
|
|
38
34
|
class InProcessCucumberRunner #:nodoc:
|
|
39
35
|
attr_reader :args
|
|
40
|
-
|
|
36
|
+
|
|
41
37
|
def initialize(libs, cucumber_opts, feature_files)
|
|
42
38
|
raise "libs must be an Array when running in-process" unless Array === libs
|
|
43
39
|
libs.reverse.each{|lib| $LOAD_PATH.unshift(lib)}
|
|
44
40
|
@args = (
|
|
45
|
-
cucumber_opts +
|
|
41
|
+
cucumber_opts +
|
|
46
42
|
feature_files
|
|
47
43
|
).flatten.compact
|
|
48
44
|
end
|
|
49
|
-
|
|
45
|
+
|
|
50
46
|
def run
|
|
51
47
|
require 'cucumber/cli/main'
|
|
52
48
|
failure = Cucumber::Cli::Main.execute(args)
|
|
53
49
|
raise "Cucumber failed" if failure
|
|
54
50
|
end
|
|
55
51
|
end
|
|
56
|
-
|
|
52
|
+
|
|
57
53
|
class ForkedCucumberRunner #:nodoc:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
@
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
attr_reader :args
|
|
55
|
+
|
|
56
|
+
def initialize(libs, cucumber_bin, cucumber_opts, feature_files)
|
|
57
|
+
@args = (
|
|
58
|
+
['-I'] + load_path(libs) +
|
|
59
|
+
quoted_binary(cucumber_bin) +
|
|
60
|
+
cucumber_opts +
|
|
61
|
+
feature_files
|
|
62
|
+
).flatten
|
|
65
63
|
end
|
|
66
64
|
|
|
67
65
|
def load_path(libs)
|
|
68
|
-
['"%s"' %
|
|
66
|
+
['"%s"' % libs.join(File::PATH_SEPARATOR)]
|
|
69
67
|
end
|
|
70
68
|
|
|
71
69
|
def quoted_binary(cucumber_bin)
|
|
72
70
|
['"%s"' % cucumber_bin]
|
|
73
71
|
end
|
|
74
72
|
|
|
75
|
-
def
|
|
76
|
-
|
|
77
|
-
end
|
|
78
|
-
|
|
79
|
-
def gem_available?(gemname)
|
|
80
|
-
gem_available_new_rubygems?(gemname) || gem_available_old_rubygems?(gemname)
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
def gem_available_old_rubygems?(gemname)
|
|
84
|
-
Gem.available?(gemname)
|
|
85
|
-
end
|
|
86
|
-
|
|
87
|
-
def gem_available_new_rubygems?(gemname)
|
|
88
|
-
Gem::Specification.respond_to?(:find_all_by_name) && Gem::Specification.find_all_by_name(gemname).any?
|
|
89
|
-
end
|
|
90
|
-
|
|
91
|
-
def cmd
|
|
92
|
-
if use_bundler
|
|
93
|
-
[ Cucumber::RUBY_BINARY, '-S', 'bundle', 'exec', 'cucumber', @cucumber_opts,
|
|
94
|
-
@feature_files ].flatten
|
|
95
|
-
else
|
|
96
|
-
[ Cucumber::RUBY_BINARY, '-I', load_path(@libs), quoted_binary(@cucumber_bin),
|
|
97
|
-
@cucumber_opts, @feature_files ].flatten
|
|
98
|
-
end
|
|
73
|
+
def runner
|
|
74
|
+
File.exist?("./Gemfile") ? ["bundle", "exec", RUBY] : [RUBY]
|
|
99
75
|
end
|
|
100
76
|
|
|
101
77
|
def run
|
|
102
|
-
sh(
|
|
78
|
+
sh((runner + args).join(" "))
|
|
103
79
|
end
|
|
104
80
|
end
|
|
105
81
|
|
|
106
82
|
class RCovCucumberRunner < ForkedCucumberRunner #:nodoc:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
|
|
117
|
-
else
|
|
118
|
-
[Cucumber::RUBY_BINARY, '-I', load_path(@libs), '-S', 'rcov', @rcov_opts,
|
|
119
|
-
quoted_binary(@cucumber_bin), '--', @cucumber_opts, @feature_files].flatten
|
|
120
|
-
end
|
|
83
|
+
def initialize(libs, cucumber_bin, cucumber_opts, feature_files, rcov_opts)
|
|
84
|
+
@args = (
|
|
85
|
+
['-I'] + load_path(libs) +
|
|
86
|
+
['-S', 'rcov'] + rcov_opts +
|
|
87
|
+
quoted_binary(cucumber_bin) +
|
|
88
|
+
['--'] +
|
|
89
|
+
cucumber_opts +
|
|
90
|
+
feature_files
|
|
91
|
+
).flatten
|
|
121
92
|
end
|
|
122
|
-
|
|
123
93
|
end
|
|
124
94
|
|
|
125
95
|
LIB = File.expand_path(File.dirname(__FILE__) + '/../..') #:nodoc:
|
|
@@ -140,12 +110,6 @@ module Cucumber
|
|
|
140
110
|
# Run cucumber with RCov? Defaults to false. If you set this to
|
|
141
111
|
# true, +fork+ is implicit.
|
|
142
112
|
attr_accessor :rcov
|
|
143
|
-
def rcov=(flag)
|
|
144
|
-
if(flag && Cucumber::RUBY_1_9)
|
|
145
|
-
raise failed + "RCov only works on Ruby 1.8.x. You may want to use SimpleCov: https://github.com/colszowka/simplecov" + reset
|
|
146
|
-
end
|
|
147
|
-
@rcov = flag
|
|
148
|
-
end
|
|
149
113
|
|
|
150
114
|
# Extra options to pass to rcov.
|
|
151
115
|
# It's recommended to pass an Array, but if it's a String it will be #split by ' '.
|
|
@@ -159,17 +123,10 @@ module Cucumber
|
|
|
159
123
|
# your load path and gems.
|
|
160
124
|
attr_accessor :fork
|
|
161
125
|
|
|
162
|
-
# Define what profile to be used. When used with cucumber_opts it is simply appended
|
|
126
|
+
# Define what profile to be used. When used with cucumber_opts it is simply appended
|
|
163
127
|
# to it. Will be ignored when CUCUMBER_OPTS is used.
|
|
164
128
|
attr_accessor :profile
|
|
165
129
|
|
|
166
|
-
# Whether or not to run with bundler (bundle exec). Setting this to false may speed
|
|
167
|
-
# up the execution. The default value is true if Bundler is installed and you have
|
|
168
|
-
# a Gemfile, false otherwise.
|
|
169
|
-
#
|
|
170
|
-
# Note that this attribute has no effect if you don't run in forked mode.
|
|
171
|
-
attr_accessor :bundler
|
|
172
|
-
|
|
173
130
|
# Define Cucumber Rake task
|
|
174
131
|
def initialize(task_name = "cucumber", desc = "Run Cucumber features")
|
|
175
132
|
@task_name, @desc = task_name, desc
|
|
@@ -195,9 +152,9 @@ module Cucumber
|
|
|
195
152
|
def runner(task_args = nil) #:nodoc:
|
|
196
153
|
cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile]
|
|
197
154
|
if(@rcov)
|
|
198
|
-
RCovCucumberRunner.new(libs, binary, cucumber_opts,
|
|
155
|
+
RCovCucumberRunner.new(libs, binary, cucumber_opts, feature_files, rcov_opts)
|
|
199
156
|
elsif(@fork)
|
|
200
|
-
ForkedCucumberRunner.new(libs, binary, cucumber_opts,
|
|
157
|
+
ForkedCucumberRunner.new(libs, binary, cucumber_opts, feature_files)
|
|
201
158
|
else
|
|
202
159
|
InProcessCucumberRunner.new(libs, cucumber_opts, feature_files)
|
|
203
160
|
end
|