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
@@ -25,7 +25,7 @@ module Cucumber
|
|
25
25
|
@exceptions = []
|
26
26
|
@indent = 0
|
27
27
|
@prefixes = options[:prefixes] || {}
|
28
|
-
@
|
28
|
+
@delayed_messages = []
|
29
29
|
end
|
30
30
|
|
31
31
|
def after_features(features)
|
@@ -101,7 +101,7 @@ module Cucumber
|
|
101
101
|
end
|
102
102
|
|
103
103
|
def examples_name(keyword, name)
|
104
|
-
puts unless @visiting_first_example_name
|
104
|
+
@io.puts unless @visiting_first_example_name
|
105
105
|
@visiting_first_example_name = false
|
106
106
|
names = name.strip.empty? ? [name.strip] : name.split("\n")
|
107
107
|
@io.puts(" #{keyword}: #{names[0]}")
|
@@ -150,10 +150,10 @@ module Cucumber
|
|
150
150
|
source_indent = nil unless @options[:source]
|
151
151
|
name_to_report = format_step(keyword, step_match, status, source_indent)
|
152
152
|
@io.puts(name_to_report.indent(@scenario_indent + 2))
|
153
|
-
|
153
|
+
print_messages
|
154
154
|
end
|
155
155
|
|
156
|
-
def
|
156
|
+
def doc_string(string)
|
157
157
|
return if @hide_this_step
|
158
158
|
s = %{"""\n#{string}\n"""}.indent(@indent)
|
159
159
|
s = s.split("\n").map{|l| l =~ /^\s+$/ ? '' : l}.join("\n")
|
@@ -184,7 +184,7 @@ module Cucumber
|
|
184
184
|
|
185
185
|
def after_table_row(table_row)
|
186
186
|
return if !@table || @hide_this_step
|
187
|
-
|
187
|
+
print_table_row_messages
|
188
188
|
@io.puts
|
189
189
|
if table_row.exception && !@exceptions.include?(table_row.exception)
|
190
190
|
print_exception(table_row.exception, table_row.status, @indent)
|
@@ -21,17 +21,21 @@ module Cucumber
|
|
21
21
|
@file_names = []
|
22
22
|
@file_colon_lines = Hash.new{|h,k| h[k] = []}
|
23
23
|
end
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
24
|
+
|
25
|
+
def before_feature(*)
|
26
|
+
@lines = []
|
27
|
+
@file = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def after_feature(*)
|
31
|
+
after_first_time do
|
32
|
+
@io.print ' '
|
30
33
|
end
|
31
|
-
@io.
|
32
|
-
|
33
|
-
# Flusing output to rerun tempfile here...
|
34
|
+
@io.print "#{@file}:#{@lines.join(':')}"
|
34
35
|
@io.flush
|
36
|
+
end
|
37
|
+
|
38
|
+
def after_features(features)
|
35
39
|
@io.close
|
36
40
|
end
|
37
41
|
|
@@ -42,14 +46,21 @@ module Cucumber
|
|
42
46
|
def after_feature_element(feature_element)
|
43
47
|
if @rerun
|
44
48
|
file, line = *feature_element.file_colon_line.split(':')
|
45
|
-
@
|
46
|
-
@
|
49
|
+
@lines << line
|
50
|
+
@file = file
|
47
51
|
end
|
48
52
|
end
|
49
53
|
|
50
54
|
def step_name(keyword, step_match, status, source_indent, background)
|
51
55
|
@rerun = true if [:failed, :pending, :undefined].index(status)
|
52
56
|
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def after_first_time
|
61
|
+
yield if @not_first_time
|
62
|
+
@not_first_time = true
|
63
|
+
end
|
53
64
|
end
|
54
65
|
end
|
55
66
|
end
|
@@ -5,14 +5,17 @@ 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' unless Cucumber::RUBY_1_9
|
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()}"
|
14
12
|
elsif `cmd /c chcp` =~ /(\d+)/
|
15
|
-
|
13
|
+
if [65000, 65001].include? $1.to_i
|
14
|
+
Cucumber::CODEPAGE = 'UTF-8'
|
15
|
+
ENV['ANSICON_API'] = 'ruby'
|
16
|
+
else
|
17
|
+
Cucumber::CODEPAGE = "cp#{$1.to_i}"
|
18
|
+
end
|
16
19
|
else
|
17
20
|
Cucumber::CODEPAGE = "cp1252"
|
18
21
|
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.")
|
@@ -24,27 +27,45 @@ if Cucumber::WINDOWS
|
|
24
27
|
o.instance_eval do
|
25
28
|
alias cucumber_print print
|
26
29
|
def print(*a)
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
if Cucumber::RUBY_1_9
|
31
|
+
begin
|
32
|
+
cucumber_print(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})
|
33
|
+
rescue Encoding::UndefinedConversionError => e
|
34
|
+
STDERR.cucumber_puts("WARNING: #{e.message}")
|
35
|
+
cucumber_print(*a)
|
36
|
+
end
|
37
|
+
else
|
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
|
35
47
|
end
|
36
48
|
end
|
37
49
|
|
38
50
|
alias cucumber_puts puts
|
39
51
|
def puts(*a)
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
52
|
+
if Cucumber::RUBY_1_9
|
53
|
+
begin
|
54
|
+
cucumber_puts(*a.map{|arg| arg.to_s.encode(Encoding.default_external)})
|
55
|
+
rescue Encoding::UndefinedConversionError => e
|
56
|
+
STDERR.cucumber_puts("WARNING: #{e.message}")
|
57
|
+
cucumber_puts(*a)
|
58
|
+
end
|
59
|
+
else
|
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
|
48
69
|
end
|
49
70
|
end
|
50
71
|
end
|
@@ -1,15 +1,15 @@
|
|
1
1
|
var CucumberJsDsl = {
|
2
2
|
registerStepDefinition: function(regexp, func) {
|
3
3
|
if(func == null) {
|
4
|
-
jsLanguage.
|
4
|
+
jsLanguage.execute_step_definition(regexp);
|
5
5
|
}
|
6
6
|
else{
|
7
|
-
jsLanguage.
|
7
|
+
jsLanguage.add_step_definition(regexp, func);
|
8
8
|
}
|
9
9
|
},
|
10
10
|
|
11
11
|
registerTransform: function(regexp, func) {
|
12
|
-
jsLanguage.
|
12
|
+
jsLanguage.register_js_transform(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.register_js_hook(label, tag_expressions, hook_func);
|
44
44
|
}
|
45
45
|
}
|
46
46
|
|
@@ -39,6 +39,10 @@ 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
|
+
|
42
46
|
def arguments_from(step_name)
|
43
47
|
matches = eval_js "#{@regexp}.exec('#{step_name}')"
|
44
48
|
if matches
|
@@ -101,10 +105,10 @@ module Cucumber
|
|
101
105
|
include LanguageSupport::LanguageMethods
|
102
106
|
include JsSnippets
|
103
107
|
|
104
|
-
def initialize(
|
108
|
+
def initialize(runtime)
|
105
109
|
@step_definitions = []
|
106
110
|
@world = JsWorld.new
|
107
|
-
@
|
111
|
+
@runtime = runtime
|
108
112
|
|
109
113
|
@world["jsLanguage"] = self
|
110
114
|
@world.load(File.dirname(__FILE__) + '/js_dsl.js')
|
@@ -146,7 +150,7 @@ module Cucumber
|
|
146
150
|
|
147
151
|
#TODO: support multiline arguments when calling steps from within steps
|
148
152
|
def execute_step_definition(name, multiline_argument = nil)
|
149
|
-
@
|
153
|
+
@runtime.step_match(name).invoke(multiline_argument)
|
150
154
|
end
|
151
155
|
|
152
156
|
def register_js_hook(phase, tag_expressions, js_function)
|
@@ -162,12 +166,12 @@ module Cucumber
|
|
162
166
|
end
|
163
167
|
|
164
168
|
def steps(steps_text, file_colon_line)
|
165
|
-
@
|
169
|
+
@runtime.invoke_steps(steps_text, @language, file_colon_line)
|
166
170
|
end
|
167
171
|
|
168
172
|
private
|
169
173
|
def path_to_load_js_from
|
170
|
-
paths = @
|
174
|
+
paths = @runtime.features_paths
|
171
175
|
if paths.empty?
|
172
176
|
'' # Using rake
|
173
177
|
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(code_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
|
+
"#{code_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 language 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,28 +13,33 @@ module Cucumber
|
|
13
13
|
@feature || @multiline_arg
|
14
14
|
end
|
15
15
|
|
16
|
-
def feature(
|
16
|
+
def feature(feature)
|
17
17
|
@feature = Ast::Feature.new(
|
18
18
|
nil,
|
19
|
-
Ast::Comment.new(
|
20
|
-
Ast::Tags.new(nil,
|
21
|
-
|
22
|
-
|
19
|
+
Ast::Comment.new(feature.comments.map{|comment| comment.value}.join("\n")),
|
20
|
+
Ast::Tags.new(nil, feature.tags.map{|tag| tag.name}),
|
21
|
+
feature.keyword,
|
22
|
+
feature.name.lstrip,
|
23
|
+
feature.description.rstrip,
|
23
24
|
[]
|
24
25
|
)
|
26
|
+
@feature.gherkin_statement(feature)
|
27
|
+
@feature
|
25
28
|
end
|
26
29
|
|
27
|
-
def background(
|
30
|
+
def background(background)
|
28
31
|
@background = Ast::Background.new(
|
29
|
-
Ast::Comment.new(
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
Ast::Comment.new(background.comments.map{|comment| comment.value}.join("\n")),
|
33
|
+
background.line,
|
34
|
+
background.keyword,
|
35
|
+
background.name,
|
36
|
+
background.description,
|
33
37
|
steps=[]
|
34
38
|
)
|
35
39
|
@feature.background = @background
|
36
40
|
@background.feature = @feature
|
37
41
|
@step_container = @background
|
42
|
+
@background.gherkin_statement(background)
|
38
43
|
end
|
39
44
|
|
40
45
|
def scenario(statement)
|
@@ -44,12 +49,14 @@ module Cucumber
|
|
44
49
|
Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
|
45
50
|
statement.line,
|
46
51
|
statement.keyword,
|
47
|
-
|
52
|
+
statement.name,
|
53
|
+
statement.description,
|
48
54
|
steps=[]
|
49
55
|
)
|
50
56
|
@feature.add_feature_element(scenario)
|
51
57
|
@background.feature_elements << scenario if @background
|
52
58
|
@step_container = scenario
|
59
|
+
scenario.gherkin_statement(statement)
|
53
60
|
end
|
54
61
|
|
55
62
|
def scenario_outline(statement)
|
@@ -59,7 +66,8 @@ module Cucumber
|
|
59
66
|
Ast::Tags.new(nil, statement.tags.map{|tag| tag.name}),
|
60
67
|
statement.line,
|
61
68
|
statement.keyword,
|
62
|
-
|
69
|
+
statement.name,
|
70
|
+
statement.description,
|
63
71
|
steps=[],
|
64
72
|
example_sections=[]
|
65
73
|
)
|
@@ -69,25 +77,28 @@ module Cucumber
|
|
69
77
|
@background.feature_elements << scenario_outline
|
70
78
|
end
|
71
79
|
@step_container = scenario_outline
|
80
|
+
scenario_outline.gherkin_statement(statement)
|
72
81
|
end
|
73
82
|
|
74
|
-
def examples(
|
83
|
+
def examples(examples)
|
75
84
|
examples_fields = [
|
76
|
-
Ast::Comment.new(
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
85
|
+
Ast::Comment.new(examples.comments.map{|comment| comment.value}.join("\n")),
|
86
|
+
examples.line,
|
87
|
+
examples.keyword,
|
88
|
+
examples.name,
|
89
|
+
examples.description,
|
90
|
+
matrix(examples.rows)
|
81
91
|
]
|
82
|
-
@step_container.add_examples(examples_fields)
|
92
|
+
@step_container.add_examples(examples_fields, examples)
|
83
93
|
end
|
84
94
|
|
85
|
-
def step(
|
86
|
-
@table_owner = Ast::Step.new(
|
87
|
-
|
95
|
+
def step(step)
|
96
|
+
@table_owner = Ast::Step.new(step.line, step.keyword, step.name)
|
97
|
+
@table_owner.gherkin_statement(step)
|
98
|
+
multiline_arg = rubify(step.multiline_arg)
|
88
99
|
case(multiline_arg)
|
89
|
-
when Gherkin::Formatter::Model::
|
90
|
-
@table_owner.multiline_arg = Ast::
|
100
|
+
when Gherkin::Formatter::Model::DocString
|
101
|
+
@table_owner.multiline_arg = Ast::DocString.new(multiline_arg.value)
|
91
102
|
when Array
|
92
103
|
@table_owner.multiline_arg = Ast::Table.new(matrix(multiline_arg))
|
93
104
|
end
|
@@ -103,12 +114,6 @@ module Cucumber
|
|
103
114
|
|
104
115
|
private
|
105
116
|
|
106
|
-
def legacy_name_for(name, description)
|
107
|
-
s = name
|
108
|
-
s += "\n#{description}" if description != ""
|
109
|
-
s
|
110
|
-
end
|
111
|
-
|
112
117
|
def matrix(gherkin_table)
|
113
118
|
gherkin_table.map do |gherkin_row|
|
114
119
|
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'
|
5
4
|
|
6
5
|
module Cucumber
|
7
|
-
|
8
|
-
VERSION =
|
6
|
+
unless defined?(Cucumber::VERSION)
|
7
|
+
VERSION = '0.10.7'
|
9
8
|
BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
|
10
9
|
LIBDIR = File.expand_path(File.dirname(__FILE__) + '/../../lib')
|
11
10
|
JRUBY = defined?(JRUBY_VERSION)
|
12
11
|
IRONRUBY = defined?(RUBY_ENGINE) && RUBY_ENGINE == "ironruby"
|
13
|
-
WINDOWS =
|
14
|
-
OS_X =
|
12
|
+
WINDOWS = RbConfig::CONFIG['host_os'] =~ /mswin|mingw/
|
13
|
+
OS_X = RbConfig::CONFIG['host_os'] =~ /darwin/
|
15
14
|
WINDOWS_MRI = WINDOWS && !JRUBY && !IRONRUBY
|
16
15
|
RAILS = defined?(Rails)
|
17
|
-
RUBY_BINARY = File.join(
|
16
|
+
RUBY_BINARY = File.join(RbConfig::CONFIG['bindir'], RbConfig::CONFIG['ruby_install_name'])
|
18
17
|
RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
|
19
18
|
RUBY_1_8_7 = RUBY_VERSION =~ /^1\.8\.7/
|
20
19
|
|
21
20
|
class << self
|
22
21
|
attr_accessor :use_full_backtrace
|
23
22
|
|
24
|
-
def file_mode(m) #:nodoc:
|
25
|
-
RUBY_1_9 ? "#{m}
|
23
|
+
def file_mode(m, encoding="UTF-8") #:nodoc:
|
24
|
+
RUBY_1_9 ? "#{m}:#{encoding}" : m
|
26
25
|
end
|
27
26
|
end
|
28
27
|
self.use_full_backtrace = false
|
29
28
|
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(code_keyword, step_name, multiline_arg_class)
|
32
|
+
"python snippet: #{code_keyword}, #{step_name}"
|
33
33
|
end
|
34
34
|
|
35
35
|
def begin_scenario(scenario)
|