cucumber 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.rvmrc +1 -1
- data/.travis.yml +3 -2
- data/DEVELOPERS.md +48 -0
- data/History.md +22 -3
- data/README.md +13 -31
- data/Rakefile +1 -0
- data/cucumber.gemspec +18 -17
- data/cucumber.yml +3 -2
- data/examples/i18n/cs/Rakefile +6 -0
- data/examples/i18n/cs/features/addition.feature +17 -0
- data/examples/i18n/cs/features/division.feature +11 -0
- data/examples/i18n/cs/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/cs/lib/calculator.rb +14 -0
- data/examples/i18n/hi/Rakefile +6 -0
- data/examples/i18n/hi/features/addition.feature +16 -0
- data/examples/i18n/hi/features/division.feature +10 -0
- data/examples/i18n/hi/features/step_definitons/calculator_steps.rb +24 -0
- data/examples/i18n/hi/lib/calculator.rb +15 -0
- data/examples/python/README.textile +2 -1
- data/examples/ruby2python/README.textile +2 -1
- data/features/.cucumber/stepdefs.json +1688 -445
- data/features/assertions.feature +69 -0
- data/features/formatter_callbacks.feature +189 -0
- data/features/html_formatter.feature +19 -0
- data/features/json_formatter.feature +8 -4
- data/features/nested_steps_with_second_arg.feature +73 -0
- data/features/step_definitions.feature +65 -0
- data/features/step_definitions/cucumber_steps.rb +18 -3
- data/fixtures/self_test/features/support/env.rb +1 -1
- data/gem_tasks/cucumber.rake +5 -3
- data/gem_tasks/downloads.rb +3 -3
- data/gem_tasks/stats +4 -2
- data/gem_tasks/yard.rake +31 -13
- data/legacy_features/default_snippets.feature +3 -3
- data/legacy_features/language_help.feature +4 -0
- data/legacy_features/report_called_undefined_steps.feature +1 -1
- data/legacy_features/snippet.feature +3 -3
- data/legacy_features/snippets_when_using_star_keyword.feature +1 -1
- data/legacy_features/step_definitions/cucumber_steps.rb +4 -3
- data/legacy_features/support/env.rb +1 -1
- data/legacy_features/support/fake_wire_server.rb +9 -9
- data/lib/autotest/cucumber_mixin.rb +14 -14
- data/lib/autotest/discover.rb +2 -0
- data/lib/cucumber.rb +2 -2
- data/lib/cucumber/ast.rb +1 -1
- data/lib/cucumber/ast/background.rb +11 -7
- data/lib/cucumber/ast/comment.rb +2 -2
- data/lib/cucumber/ast/doc_string.rb +1 -1
- data/lib/cucumber/ast/examples.rb +1 -1
- data/lib/cucumber/ast/feature.rb +2 -2
- data/lib/cucumber/ast/feature_element.rb +1 -1
- data/lib/cucumber/ast/multiline_argument.rb +2 -2
- data/lib/cucumber/ast/names.rb +2 -2
- data/lib/cucumber/ast/outline_table.rb +4 -5
- data/lib/cucumber/ast/scenario.rb +14 -14
- data/lib/cucumber/ast/scenario_outline.rb +4 -4
- data/lib/cucumber/ast/step.rb +3 -3
- data/lib/cucumber/ast/step_collection.rb +5 -5
- data/lib/cucumber/ast/step_invocation.rb +8 -8
- data/lib/cucumber/ast/table.rb +40 -27
- data/lib/cucumber/ast/tree_walker.rb +9 -8
- data/lib/cucumber/ast/visitor.rb +1 -1
- data/lib/cucumber/cli/configuration.rb +10 -10
- data/lib/cucumber/cli/drb_client.rb +1 -1
- data/lib/cucumber/cli/main.rb +3 -3
- data/lib/cucumber/cli/options.rb +3 -2
- data/lib/cucumber/cli/profile_loader.rb +1 -1
- data/lib/cucumber/configuration.rb +12 -12
- data/lib/cucumber/constantize.rb +11 -2
- data/lib/cucumber/core_ext/disable_mini_and_test_unit_autorun.rb +1 -1
- data/lib/cucumber/core_ext/instance_exec.rb +4 -4
- data/lib/cucumber/core_ext/proc.rb +3 -3
- data/lib/cucumber/errors.rb +1 -1
- data/lib/cucumber/feature_file.rb +1 -1
- data/lib/cucumber/formatter/ansicolor.rb +36 -23
- data/lib/cucumber/formatter/console.rb +45 -25
- data/lib/cucumber/formatter/debug.rb +7 -7
- data/lib/cucumber/formatter/duration.rb +1 -1
- data/lib/cucumber/formatter/gherkin_formatter_adapter.rb +7 -0
- data/lib/cucumber/formatter/gpretty.rb +1 -1
- data/lib/cucumber/formatter/html.rb +52 -53
- data/lib/cucumber/formatter/interceptor.rb +2 -2
- data/lib/cucumber/formatter/json.rb +1 -1
- data/lib/cucumber/formatter/json_pretty.rb +2 -1
- data/lib/cucumber/formatter/junit.rb +1 -1
- data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
- data/lib/cucumber/formatter/pretty.rb +12 -12
- data/lib/cucumber/formatter/progress.rb +5 -5
- data/lib/cucumber/formatter/rerun.rb +5 -5
- data/lib/cucumber/formatter/stepdefs.rb +1 -1
- data/lib/cucumber/formatter/steps.rb +6 -6
- data/lib/cucumber/formatter/summary.rb +6 -6
- data/lib/cucumber/formatter/unicode.rb +18 -18
- data/lib/cucumber/formatter/usage.rb +7 -7
- data/lib/cucumber/js_support/js_dsl.js +1 -1
- data/lib/cucumber/language_support.rb +1 -1
- data/lib/cucumber/parser/gherkin_builder.rb +33 -33
- data/lib/cucumber/platform.rb +3 -2
- data/lib/cucumber/py_support/py_dsl.py +2 -2
- data/lib/cucumber/py_support/py_language.py +2 -2
- data/lib/cucumber/py_support/py_language.rb +2 -2
- data/lib/cucumber/rake/task.rb +4 -3
- data/lib/cucumber/rb_support/rb_dsl.rb +10 -10
- data/lib/cucumber/rb_support/rb_language.rb +27 -19
- data/lib/cucumber/rb_support/rb_step_definition.rb +39 -11
- data/lib/cucumber/rb_support/rb_transform.rb +3 -3
- data/lib/cucumber/rb_support/rb_world.rb +15 -15
- data/lib/cucumber/rb_support/regexp_argument_matcher.rb +1 -1
- data/lib/cucumber/rspec/disable_option_parser.rb +1 -1
- data/lib/cucumber/rspec/doubles.rb +1 -1
- data/lib/cucumber/runtime.rb +11 -10
- data/lib/cucumber/runtime/features_loader.rb +6 -6
- data/lib/cucumber/runtime/for_programming_languages.rb +8 -15
- data/lib/cucumber/runtime/results.rb +6 -6
- data/lib/cucumber/runtime/support_code.rb +37 -28
- data/lib/cucumber/runtime/user_interface.rb +4 -4
- data/lib/cucumber/step_definition_light.rb +4 -4
- data/lib/cucumber/step_definitions.rb +2 -3
- data/lib/cucumber/step_match.rb +6 -6
- data/lib/cucumber/step_mother.rb +1 -1
- data/lib/cucumber/term/ansicolor.rb +22 -22
- data/lib/cucumber/wire_support/configuration.rb +11 -14
- data/lib/cucumber/wire_support/connection.rb +10 -9
- data/lib/cucumber/wire_support/request_handler.rb +3 -3
- data/lib/cucumber/wire_support/wire_exception.rb +3 -3
- data/lib/cucumber/wire_support/wire_language.rb +11 -11
- data/lib/cucumber/wire_support/wire_packet.rb +7 -5
- data/lib/cucumber/wire_support/wire_protocol.rb +6 -6
- data/lib/cucumber/wire_support/wire_protocol/requests.rb +20 -20
- data/lib/cucumber/wire_support/wire_step_definition.rb +4 -4
- data/spec/cucumber/ast/background_spec.rb +4 -4
- data/spec/cucumber/ast/doc_string_spec.rb +8 -8
- data/spec/cucumber/ast/feature_factory.rb +4 -4
- data/spec/cucumber/ast/feature_spec.rb +18 -18
- data/spec/cucumber/ast/outline_table_spec.rb +3 -3
- data/spec/cucumber/ast/step_spec.rb +4 -4
- data/spec/cucumber/ast/table_spec.rb +50 -29
- data/spec/cucumber/ast/tree_walker_spec.rb +12 -4
- data/spec/cucumber/broadcaster_spec.rb +1 -1
- data/spec/cucumber/cli/configuration_spec.rb +10 -4
- data/spec/cucumber/cli/drb_client_spec.rb +1 -1
- data/spec/cucumber/cli/main_spec.rb +28 -7
- data/spec/cucumber/cli/options_spec.rb +3 -3
- data/spec/cucumber/configuration_spec.rb +4 -4
- data/spec/cucumber/constantize_spec.rb +2 -0
- data/spec/cucumber/core_ext/proc_spec.rb +7 -7
- data/spec/cucumber/formatter/ansicolor_spec.rb +2 -2
- data/spec/cucumber/formatter/duration_spec.rb +2 -2
- data/spec/cucumber/formatter/html_spec.rb +31 -31
- data/spec/cucumber/formatter/interceptor_spec.rb +10 -0
- data/spec/cucumber/formatter/progress_spec.rb +1 -1
- data/spec/cucumber/formatter/spec_helper.rb +7 -7
- data/spec/cucumber/rake/forked_spec.rb +15 -2
- data/spec/cucumber/rake/rcov_spec.rb +2 -2
- data/spec/cucumber/rb_support/rb_language_spec.rb +34 -17
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +45 -35
- data/spec/cucumber/rb_support/rb_transform_spec.rb +3 -3
- data/spec/cucumber/runtime/for_programming_languages_spec.rb +31 -0
- data/spec/cucumber/runtime/results_spec.rb +5 -5
- data/spec/cucumber/runtime/support_code_spec.rb +13 -2
- data/spec/cucumber/runtime_spec.rb +7 -7
- data/spec/cucumber/step_match_spec.rb +2 -2
- data/spec/cucumber/wire_support/configuration_spec.rb +16 -6
- data/spec/cucumber/wire_support/connection_spec.rb +25 -11
- data/spec/cucumber/wire_support/wire_exception_spec.rb +3 -3
- data/spec/cucumber/wire_support/wire_language_spec.rb +3 -3
- data/spec/cucumber/wire_support/wire_packet_spec.rb +4 -4
- data/spec/cucumber/wire_support/wire_step_definition_spec.rb +1 -1
- data/spec/spec_helper.rb +2 -2
- metadata +98 -128
- data/legacy_features/html_formatter.feature +0 -8
- data/legacy_features/html_formatter/a.html +0 -561
@@ -3,10 +3,10 @@ module Cucumber
|
|
3
3
|
# Walks the AST, executing steps and notifying listeners
|
4
4
|
class TreeWalker
|
5
5
|
attr_accessor :configuration #:nodoc:
|
6
|
-
attr_reader :
|
6
|
+
attr_reader :runtime #:nodoc:
|
7
7
|
|
8
|
-
def initialize(
|
9
|
-
@
|
8
|
+
def initialize(runtime, listeners = [], configuration = Cucumber::Configuration.default)
|
9
|
+
@runtime, @listeners, @configuration = runtime, listeners, configuration
|
10
10
|
end
|
11
11
|
|
12
12
|
def visit_features(features)
|
@@ -152,9 +152,9 @@ module Cucumber
|
|
152
152
|
def embed(file, mime_type, label)
|
153
153
|
broadcast(file, mime_type, label)
|
154
154
|
end
|
155
|
-
|
155
|
+
|
156
156
|
private
|
157
|
-
|
157
|
+
|
158
158
|
def broadcast(*args, &block)
|
159
159
|
message = extract_method_name_from(caller)
|
160
160
|
message.gsub!('visit_', '')
|
@@ -165,8 +165,9 @@ module Cucumber
|
|
165
165
|
else
|
166
166
|
send_to_all(message, *args)
|
167
167
|
end
|
168
|
+
self
|
168
169
|
end
|
169
|
-
|
170
|
+
|
170
171
|
def send_to_all(message, *args)
|
171
172
|
@listeners.each do |listener|
|
172
173
|
if listener.respond_to?(message)
|
@@ -177,7 +178,7 @@ module Cucumber
|
|
177
178
|
def extract_method_name_from(call_stack)
|
178
179
|
call_stack[0].match(/in `(.*)'/).captures[0]
|
179
180
|
end
|
180
|
-
|
181
|
+
|
181
182
|
end
|
182
183
|
end
|
183
|
-
end
|
184
|
+
end
|
data/lib/cucumber/ast/visitor.rb
CHANGED
@@ -68,8 +68,8 @@ module Cucumber
|
|
68
68
|
@options[:dotcucumber]
|
69
69
|
end
|
70
70
|
|
71
|
-
def build_tree_walker(
|
72
|
-
Ast::TreeWalker.new(
|
71
|
+
def build_tree_walker(runtime)
|
72
|
+
Ast::TreeWalker.new(runtime, formatters(runtime), self)
|
73
73
|
end
|
74
74
|
|
75
75
|
def formatter_class(format)
|
@@ -133,35 +133,35 @@ module Cucumber
|
|
133
133
|
logger.level = Logger::DEBUG if self.verbose?
|
134
134
|
logger
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
def tag_expression
|
138
138
|
Gherkin::TagExpression.new(@options[:tag_expressions])
|
139
139
|
end
|
140
|
-
|
140
|
+
|
141
141
|
def filters
|
142
142
|
@options.filters
|
143
143
|
end
|
144
|
-
|
144
|
+
|
145
145
|
def formats
|
146
146
|
@options[:formats]
|
147
147
|
end
|
148
|
-
|
148
|
+
|
149
149
|
def options
|
150
150
|
warn("Deprecated: Configuration#options will be removed from the next release of Cucumber. Please use the configuration object directly instead.")
|
151
151
|
@options
|
152
152
|
end
|
153
|
-
|
153
|
+
|
154
154
|
def paths
|
155
155
|
@options[:paths].empty? ? ['features'] : @options[:paths]
|
156
156
|
end
|
157
157
|
private
|
158
158
|
|
159
|
-
def formatters(
|
159
|
+
def formatters(runtime)
|
160
160
|
# TODO: We should remove the autoformat functionality. That
|
161
161
|
# can be done with the gherkin CLI.
|
162
162
|
if @options[:autoformat]
|
163
163
|
require 'cucumber/formatter/pretty'
|
164
|
-
return [Formatter::Pretty.new(
|
164
|
+
return [Formatter::Pretty.new(runtime, nil, @options)]
|
165
165
|
end
|
166
166
|
|
167
167
|
@options[:formats].map do |format_and_out|
|
@@ -169,7 +169,7 @@ module Cucumber
|
|
169
169
|
path_or_io = format_and_out[1]
|
170
170
|
begin
|
171
171
|
formatter_class = formatter_class(format)
|
172
|
-
formatter_class.new(
|
172
|
+
formatter_class.new(runtime, path_or_io, @options)
|
173
173
|
rescue Exception => e
|
174
174
|
e.message << "\nError creating formatter: #{format}"
|
175
175
|
raise e
|
@@ -20,7 +20,7 @@ module Cucumber
|
|
20
20
|
cloned_args = [] # I have no idea why this is needed, but if the regular args are sent then DRb magically transforms it into a DRb object - not an array
|
21
21
|
args.each { |arg| cloned_args << arg }
|
22
22
|
feature_server.run(cloned_args, error_stream, out_stream)
|
23
|
-
rescue DRb::DRbConnError
|
23
|
+
rescue DRb::DRbConnError
|
24
24
|
raise DRbClientError, "No DRb server is running."
|
25
25
|
end
|
26
26
|
|
data/lib/cucumber/cli/main.rb
CHANGED
@@ -32,7 +32,7 @@ module Cucumber
|
|
32
32
|
def execute!(existing_runtime = nil)
|
33
33
|
trap_interrupt
|
34
34
|
return @drb_output if run_drb_client
|
35
|
-
|
35
|
+
|
36
36
|
runtime = if existing_runtime
|
37
37
|
existing_runtime.configure(configuration)
|
38
38
|
existing_runtime
|
@@ -42,7 +42,7 @@ module Cucumber
|
|
42
42
|
|
43
43
|
runtime.run!
|
44
44
|
runtime.write_stepdefs_json
|
45
|
-
runtime.results.failure?
|
45
|
+
runtime.results.failure? || Cucumber.wants_to_quit
|
46
46
|
rescue ProfilesNotDefinedError, YmlLoadError, ProfileNotFound => e
|
47
47
|
@error_stream.puts e.message
|
48
48
|
true
|
@@ -58,7 +58,7 @@ module Cucumber
|
|
58
58
|
end
|
59
59
|
|
60
60
|
private
|
61
|
-
|
61
|
+
|
62
62
|
def run_drb_client
|
63
63
|
return false unless configuration.drb?
|
64
64
|
@drb_output = DRbClient.run(@args, @error_stream, @out_stream, configuration.drb_port)
|
data/lib/cucumber/cli/options.rb
CHANGED
@@ -61,7 +61,7 @@ module Cucumber
|
|
61
61
|
@profiles = []
|
62
62
|
@overridden_paths = []
|
63
63
|
@options = default_options
|
64
|
-
|
64
|
+
|
65
65
|
@quiet = @disable_profile_loading = nil
|
66
66
|
end
|
67
67
|
|
@@ -182,7 +182,7 @@ module Cucumber
|
|
182
182
|
"Beware that if you want to use several negative tags to exclude several tags",
|
183
183
|
"you have to use logical AND: --tags ~@fixme --tags ~@buggy.",
|
184
184
|
"\n",
|
185
|
-
"Positive tags can be given a threshold to limit the number of occurrences.",
|
185
|
+
"Positive tags can be given a threshold to limit the number of occurrences.",
|
186
186
|
"Example: --tags @qa:3 will fail if there are more than 3 occurrences of the @qa tag.",
|
187
187
|
"This can be practical if you are practicing Kanban or CONWIP.") do |v|
|
188
188
|
@options[:tag_expressions] << v
|
@@ -375,6 +375,7 @@ module Cucumber
|
|
375
375
|
@options[:source] &= other_options[:source]
|
376
376
|
@options[:snippets] &= other_options[:snippets]
|
377
377
|
@options[:strict] |= other_options[:strict]
|
378
|
+
@options[:dry_run] |= other_options[:dry_run]
|
378
379
|
|
379
380
|
@profiles += other_options.profiles
|
380
381
|
@expanded_args += other_options.expanded_args
|
@@ -4,46 +4,46 @@ module Cucumber
|
|
4
4
|
def self.default
|
5
5
|
new
|
6
6
|
end
|
7
|
-
|
7
|
+
|
8
8
|
def self.parse(argument)
|
9
9
|
return new(argument) if argument.is_a?(Hash)
|
10
10
|
argument
|
11
11
|
end
|
12
|
-
|
12
|
+
|
13
13
|
def initialize(user_options = {})
|
14
14
|
@options = default_options.merge(user_options)
|
15
15
|
end
|
16
|
-
|
16
|
+
|
17
17
|
def dry_run?
|
18
18
|
@options[:dry_run]
|
19
19
|
end
|
20
|
-
|
20
|
+
|
21
21
|
def guess?
|
22
22
|
@options[:guess]
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
def strict?
|
26
26
|
@options[:strict]
|
27
27
|
end
|
28
|
-
|
29
|
-
def expand?
|
28
|
+
|
29
|
+
def expand?
|
30
30
|
@options[:expand]
|
31
31
|
end
|
32
|
-
|
32
|
+
|
33
33
|
def paths
|
34
34
|
@options[:paths]
|
35
35
|
end
|
36
|
-
|
36
|
+
|
37
37
|
def autoload_code_paths
|
38
38
|
@options[:autoload_code_paths]
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
private
|
42
|
-
|
42
|
+
|
43
43
|
def default_options
|
44
44
|
{
|
45
45
|
:autoload_code_paths => ['features/support', 'features/step_definitions']
|
46
46
|
}
|
47
47
|
end
|
48
48
|
end
|
49
|
-
end
|
49
|
+
end
|
data/lib/cucumber/constantize.rb
CHANGED
@@ -9,7 +9,7 @@ module Cucumber
|
|
9
9
|
|
10
10
|
constant = ::Object
|
11
11
|
names.each do |name|
|
12
|
-
constant =
|
12
|
+
constant = constantize_name(constant, name)
|
13
13
|
end
|
14
14
|
constant
|
15
15
|
rescue NameError => e
|
@@ -30,5 +30,14 @@ module Cucumber
|
|
30
30
|
tr("-", "_").
|
31
31
|
downcase
|
32
32
|
end
|
33
|
+
|
34
|
+
private
|
35
|
+
def constantize_name(constant, name)
|
36
|
+
if Cucumber::RUBY_1_8_7
|
37
|
+
constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
38
|
+
else
|
39
|
+
constant.const_defined?(name, false) ? constant.const_get(name, false) : constant.const_missing(name)
|
40
|
+
end
|
41
|
+
end
|
33
42
|
end
|
34
|
-
end
|
43
|
+
end
|
@@ -54,16 +54,16 @@ class Object #:nodoc:
|
|
54
54
|
|
55
55
|
def cucumber_arity(block)
|
56
56
|
a = block.arity
|
57
|
-
Cucumber::
|
57
|
+
Cucumber::RUBY_1_8_7 ? (a == -1 ? 0 : a) : a
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
def cucumber_compatible_arity?(args, block)
|
61
61
|
ari = cucumber_arity(block)
|
62
62
|
len = args.length
|
63
63
|
return true if ari == len or ari < 0 && len >= ari.abs-1
|
64
64
|
false
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
def cucumber_run_with_backtrace_filtering(pseudo_method)
|
68
68
|
begin
|
69
69
|
yield
|
@@ -74,7 +74,7 @@ class Object #:nodoc:
|
|
74
74
|
end
|
75
75
|
end
|
76
76
|
|
77
|
-
INSTANCE_EXEC_OFFSET = (Cucumber::RUBY_1_9 || Cucumber::RUBY_1_8_7 || Cucumber::JRUBY) ? -3 : -4
|
77
|
+
INSTANCE_EXEC_OFFSET = (Cucumber::RUBY_2_0 || Cucumber::RUBY_1_9 || Cucumber::RUBY_1_8_7 || Cucumber::JRUBY) ? -3 : -4
|
78
78
|
|
79
79
|
def replace_instance_exec_invocation_line!(backtrace, instance_exec_invocation_line, pseudo_method)
|
80
80
|
return if Cucumber.use_full_backtrace
|
@@ -2,7 +2,7 @@
|
|
2
2
|
class Proc #:nodoc:
|
3
3
|
PROC_PATTERN = /[\d\w]+@(.+):(\d+).*>/
|
4
4
|
PWD = Dir.pwd
|
5
|
-
|
5
|
+
|
6
6
|
def to_comment_line
|
7
7
|
"# #{file_colon_line}"
|
8
8
|
end
|
@@ -26,9 +26,9 @@ class Proc #:nodoc:
|
|
26
26
|
else
|
27
27
|
# This Ruby implementation doesn't implement Proc#to_s correctly
|
28
28
|
STDERR.puts "*** THIS RUBY IMPLEMENTATION DOESN'T REPORT FILE AND LINE FOR PROCS ***"
|
29
|
-
|
29
|
+
|
30
30
|
def file_colon_line
|
31
31
|
"UNKNOWN:-1"
|
32
32
|
end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
data/lib/cucumber/errors.rb
CHANGED
@@ -2,16 +2,16 @@ require 'cucumber/platform'
|
|
2
2
|
require 'cucumber/term/ansicolor'
|
3
3
|
|
4
4
|
if Cucumber::IRONRUBY
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
5
|
+
begin
|
6
|
+
require 'iron-term-ansicolor'
|
7
|
+
rescue LoadError
|
8
|
+
STDERR.puts %{*** WARNING: You must "igem install iron-term-ansicolor" to get coloured ouput in on IronRuby}
|
9
|
+
end
|
10
10
|
end
|
11
11
|
|
12
12
|
if Cucumber::WINDOWS_MRI
|
13
13
|
unless ENV['ANSICON']
|
14
|
-
STDERR.puts %{*** WARNING: You must use ANSICON 1.31 or higher (
|
14
|
+
STDERR.puts %{*** WARNING: You must use ANSICON 1.31 or higher (https://github.com/adoxa/ansicon/) to get coloured output on Windows}
|
15
15
|
Cucumber::Term::ANSIColor.coloring = false
|
16
16
|
end
|
17
17
|
end
|
@@ -44,17 +44,19 @@ module Cucumber
|
|
44
44
|
#
|
45
45
|
# For instance, if your shell has a black background and a green font (like the
|
46
46
|
# "Homebrew" settings for OS X' Terminal.app), you may want to override passed
|
47
|
-
# steps to be white instead of green.
|
47
|
+
# steps to be white instead of green.
|
48
|
+
#
|
49
|
+
# Although not listed, you can also use <tt>grey</tt>.
|
50
|
+
#
|
51
|
+
# Examples: (On Windows, use SET instead of export.)
|
48
52
|
#
|
49
53
|
# export CUCUMBER_COLORS="passed=white"
|
50
54
|
# export CUCUMBER_COLORS="passed=white,bold:passed_param=white,bold,underline"
|
51
55
|
#
|
52
|
-
# (If you're on Windows, use SET instead of export).
|
53
56
|
# To see what colours and effects are available, just run this in your shell:
|
54
57
|
#
|
55
58
|
# ruby -e "require 'rubygems'; require 'term/ansicolor'; puts Cucumber::Term::ANSIColor.attributes"
|
56
59
|
#
|
57
|
-
# Although not listed, you can also use <tt>grey</tt>
|
58
60
|
module ANSIColor
|
59
61
|
include Cucumber::Term::ANSIColor
|
60
62
|
|
@@ -80,28 +82,39 @@ module Cucumber
|
|
80
82
|
end
|
81
83
|
end
|
82
84
|
|
83
|
-
|
84
|
-
|
85
|
+
# Eval to define the color-named methods required by Term::ANSIColor.
|
86
|
+
#
|
87
|
+
# Examples:
|
88
|
+
#
|
89
|
+
# def failed(string=nil, &proc)
|
90
|
+
# red(string, &proc)
|
91
|
+
# end
|
92
|
+
#
|
93
|
+
# def failed_param(string=nil, &proc)
|
94
|
+
# red(bold(string, &proc)) + red
|
95
|
+
# end
|
96
|
+
ALIASES.each_key do |method_name|
|
97
|
+
unless method_name =~ /.*_param/
|
85
98
|
code = <<-EOF
|
86
|
-
def #{
|
87
|
-
#{ALIASES[
|
99
|
+
def #{method_name}(string=nil, &proc)
|
100
|
+
#{ALIASES[method_name].split(",").join("(") + "(string, &proc" + ")" * ALIASES[method_name].split(",").length}
|
88
101
|
end
|
89
102
|
# This resets the colour to the non-param colour
|
90
|
-
def #{
|
91
|
-
#{ALIASES[
|
103
|
+
def #{method_name}_param(string=nil, &proc)
|
104
|
+
#{ALIASES[method_name+'_param'].split(",").join("(") + "(string, &proc" + ")" * ALIASES[method_name+'_param'].split(",").length} + #{ALIASES[method_name].split(",").join(' + ')}
|
92
105
|
end
|
93
106
|
EOF
|
94
107
|
eval(code)
|
95
108
|
end
|
96
109
|
end
|
97
|
-
|
110
|
+
|
98
111
|
def self.define_grey #:nodoc:
|
99
112
|
begin
|
100
113
|
gem 'genki-ruby-terminfo'
|
101
114
|
require 'terminfo'
|
102
115
|
case TermInfo.default_object.tigetnum("colors")
|
103
116
|
when 0
|
104
|
-
raise "Your terminal doesn't support colours"
|
117
|
+
raise "Your terminal doesn't support colours."
|
105
118
|
when 1
|
106
119
|
::Cucumber::Term::ANSIColor.coloring = false
|
107
120
|
alias grey white
|
@@ -114,7 +127,7 @@ module Cucumber
|
|
114
127
|
if e.class.name == 'TermInfo::TermInfoError'
|
115
128
|
STDERR.puts "*** WARNING ***"
|
116
129
|
STDERR.puts "You have the genki-ruby-terminfo gem installed, but you haven't set your TERM variable."
|
117
|
-
STDERR.puts "Try setting it to TERM=xterm-256color to get grey colour in output"
|
130
|
+
STDERR.puts "Try setting it to TERM=xterm-256color to get grey colour in output."
|
118
131
|
STDERR.puts "\n"
|
119
132
|
alias grey white
|
120
133
|
else
|
@@ -122,17 +135,17 @@ module Cucumber
|
|
122
135
|
end
|
123
136
|
end
|
124
137
|
end
|
125
|
-
|
138
|
+
|
126
139
|
def self.define_real_grey #:nodoc:
|
127
|
-
def grey(
|
140
|
+
def grey(string) #:nodoc:
|
128
141
|
if ::Cucumber::Term::ANSIColor.coloring?
|
129
|
-
"\e[90m#{
|
142
|
+
"\e[90m#{string}\e[0m"
|
130
143
|
else
|
131
|
-
|
144
|
+
string
|
132
145
|
end
|
133
146
|
end
|
134
147
|
end
|
135
|
-
|
148
|
+
|
136
149
|
define_grey
|
137
150
|
|
138
151
|
def cukes(n)
|