cucumber 0.3.96 → 0.3.97
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +22 -3
- data/License.txt +2 -0
- data/Manifest.txt +9 -5
- data/config/hoe.rb +1 -0
- data/examples/i18n/Rakefile +5 -3
- data/examples/i18n/fi/features/yhteenlasku.feature +5 -4
- data/examples/python/features/step_definitions/fib_steps.py +3 -0
- data/examples/python/features/support/env.rb +21 -21
- data/gem_tasks/contributors.rake +8 -0
- data/gem_tasks/features.rake +1 -0
- data/gem_tasks/sdoc.rake +7 -0
- data/lib/README.rdoc +12 -0
- data/lib/cucumber/ast/background.rb +1 -1
- data/lib/cucumber/ast/comment.rb +1 -1
- data/lib/cucumber/ast/examples.rb +9 -4
- data/lib/cucumber/ast/feature.rb +1 -1
- data/lib/cucumber/ast/feature_element.rb +1 -1
- data/lib/cucumber/ast/features.rb +1 -1
- data/lib/cucumber/ast/outline_table.rb +2 -2
- data/lib/cucumber/ast/py_string.rb +1 -1
- data/lib/cucumber/ast/scenario.rb +1 -1
- data/lib/cucumber/ast/scenario_outline.rb +8 -7
- data/lib/cucumber/ast/step.rb +1 -1
- data/lib/cucumber/ast/step_collection.rb +1 -1
- data/lib/cucumber/ast/step_invocation.rb +1 -1
- data/lib/cucumber/ast/table.rb +65 -45
- data/lib/cucumber/ast/tags.rb +2 -2
- data/lib/cucumber/ast/visitor.rb +6 -8
- data/lib/cucumber/broadcaster.rb +1 -1
- data/lib/cucumber/cli/language_help_formatter.rb +1 -1
- data/lib/cucumber/cli/main.rb +15 -52
- data/lib/cucumber/constantize.rb +1 -1
- data/lib/cucumber/core_ext/exception.rb +1 -1
- data/lib/cucumber/core_ext/instance_exec.rb +8 -3
- data/lib/cucumber/core_ext/proc.rb +1 -1
- data/lib/cucumber/core_ext/string.rb +1 -1
- data/lib/cucumber/feature_file.rb +4 -3
- data/lib/cucumber/filter.rb +2 -1
- data/lib/cucumber/formatter/ansicolor.rb +6 -5
- data/lib/cucumber/formatter/color_io.rb +2 -2
- data/lib/cucumber/formatter/console.rb +2 -0
- data/lib/cucumber/formatter/duration.rb +3 -0
- data/lib/cucumber/formatter/html.rb +1 -0
- data/lib/cucumber/formatter/junit.rb +1 -0
- data/lib/cucumber/formatter/ordered_xml_markup.rb +1 -1
- data/lib/cucumber/formatter/pretty.rb +18 -4
- data/lib/cucumber/formatter/profile.rb +1 -0
- data/lib/cucumber/formatter/progress.rb +1 -0
- data/lib/cucumber/formatter/rerun.rb +2 -0
- data/lib/cucumber/formatter/steps.rb +1 -0
- data/lib/cucumber/formatter/tag_cloud.rb +2 -1
- data/lib/cucumber/formatter/unicode.rb +1 -1
- data/lib/cucumber/formatter/usage.rb +1 -0
- data/lib/cucumber/language_support.rb +30 -0
- data/lib/cucumber/language_support/language_methods.rb +34 -12
- data/lib/cucumber/parser/feature.rb +81 -57
- data/lib/cucumber/parser/feature.tt +3 -3
- data/lib/cucumber/parser/natural_language.rb +1 -1
- data/lib/cucumber/parser/table.rb +3 -0
- data/lib/cucumber/parser/treetop_ext.rb +6 -5
- data/lib/cucumber/platform.rb +1 -2
- data/lib/cucumber/py_support/py_dsl.py +8 -0
- data/lib/cucumber/py_support/py_language.py +2 -0
- data/lib/cucumber/py_support/py_language.rb +68 -0
- data/lib/cucumber/rails/world.rb +2 -1
- data/lib/cucumber/rake/task.rb +13 -11
- data/lib/cucumber/rb_support/rb_dsl.rb +27 -15
- data/lib/cucumber/rb_support/rb_hook.rb +1 -2
- data/lib/cucumber/rb_support/rb_language.rb +57 -33
- data/lib/cucumber/rb_support/rb_step_definition.rb +42 -38
- data/lib/cucumber/rb_support/rb_world.rb +93 -0
- data/lib/cucumber/rspec_neuter.rb +3 -3
- data/lib/cucumber/step_match.rb +2 -2
- data/lib/cucumber/step_mother.rb +91 -65
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber/webrat/element_locator.rb +3 -3
- data/rails_generators/cucumber/templates/cucumber.rake +2 -0
- data/rails_generators/cucumber/templates/webrat_steps.rb +4 -0
- data/spec/cucumber/ast/background_spec.rb +8 -1
- data/spec/cucumber/ast/scenario_outline_spec.rb +1 -0
- data/spec/cucumber/ast/table_spec.rb +10 -0
- data/spec/cucumber/cli/options_spec.rb +1 -1
- data/spec/cucumber/parser/feature_parser_spec.rb +4 -0
- data/spec/cucumber/rb_support/rb_step_definition_spec.rb +114 -0
- data/spec/cucumber/step_mother_spec.rb +29 -10
- data/spec/cucumber/treetop_parser/with_comments.feature +14 -1
- data/spec/cucumber/world/pending_spec.rb +1 -1
- metadata +21 -7
- data/gem_tasks/yard.rake +0 -8
- data/lib/cucumber/language_support/hook_methods.rb +0 -9
- data/lib/cucumber/world.rb +0 -89
- data/spec/cucumber/ast/visitor_spec.rb +0 -27
- data/spec/cucumber/step_definition_spec.rb +0 -102
data/lib/cucumber/ast/tags.rb
CHANGED
@@ -6,7 +6,7 @@ module Cucumber
|
|
6
6
|
#
|
7
7
|
# This gets stored internally as <tt>["invoice", "release_2"]</tt>
|
8
8
|
#
|
9
|
-
class Tags
|
9
|
+
class Tags #:nodoc:
|
10
10
|
def self.strip_prefix(tag_name)
|
11
11
|
tag_name =~ /^@(.*)/ ? $1 : tag_name
|
12
12
|
end
|
@@ -23,7 +23,7 @@ module Cucumber
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def accept_hook?(hook)
|
26
|
-
hook.
|
26
|
+
hook.tag_names.empty? || (hook.tag_names.map{|tag| Ast::Tags.strip_prefix(tag)} & @tag_names).any?
|
27
27
|
end
|
28
28
|
|
29
29
|
def count(tag)
|
data/lib/cucumber/ast/visitor.rb
CHANGED
@@ -1,20 +1,17 @@
|
|
1
1
|
module Cucumber
|
2
2
|
module Ast
|
3
|
-
#
|
3
|
+
# Base class for formatters. This class just walks the tree depth first.
|
4
|
+
# Just override the methods you care about. Remember to call super if you
|
5
|
+
# override a method.
|
4
6
|
class Visitor
|
5
|
-
attr_accessor :options
|
6
|
-
attr_reader :step_mother
|
7
|
+
attr_accessor :options #:nodoc:
|
8
|
+
attr_reader :step_mother #:nodoc:
|
7
9
|
|
8
10
|
def initialize(step_mother)
|
9
11
|
@options = {}
|
10
12
|
@step_mother = step_mother
|
11
13
|
end
|
12
14
|
|
13
|
-
def matches_scenario_names?(node)
|
14
|
-
scenario_name_regexps = options[:name_regexps] || []
|
15
|
-
scenario_name_regexps.empty? || node.matches_scenario_names?(scenario_name_regexps)
|
16
|
-
end
|
17
|
-
|
18
15
|
def visit_features(features)
|
19
16
|
features.accept(self)
|
20
17
|
end
|
@@ -109,6 +106,7 @@ module Cucumber
|
|
109
106
|
def visit_table_cell_value(value, status)
|
110
107
|
end
|
111
108
|
|
109
|
+
# Print +announcement+. This method can be called from within StepDefinitions.
|
112
110
|
def announce(announcement)
|
113
111
|
end
|
114
112
|
|
data/lib/cucumber/broadcaster.rb
CHANGED
@@ -23,7 +23,7 @@ http://wiki.github.com/aslakhellesoy/cucumber/spoken-languages
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def self.list_keywords(io, lang)
|
26
|
-
language = Parser::NaturalLanguage
|
26
|
+
language = Parser::NaturalLanguage.get(nil, lang)
|
27
27
|
raw = Parser::NaturalLanguage::KEYWORD_KEYS.map do |key|
|
28
28
|
[key, language.keywords(key)]
|
29
29
|
end
|
data/lib/cucumber/cli/main.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'optparse'
|
2
2
|
require 'cucumber'
|
3
3
|
require 'ostruct'
|
4
|
+
require 'logger'
|
4
5
|
require 'cucumber/parser'
|
5
6
|
require 'cucumber/feature_file'
|
6
7
|
require 'cucumber/formatter/color_io'
|
@@ -13,6 +14,12 @@ module Cucumber
|
|
13
14
|
class Main
|
14
15
|
FAILURE = 1
|
15
16
|
|
17
|
+
class LogFormatter < ::Logger::Formatter
|
18
|
+
def call(severity, time, progname, msg)
|
19
|
+
msg
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
16
23
|
class << self
|
17
24
|
def step_mother
|
18
25
|
@step_mother ||= StepMother.new
|
@@ -27,8 +34,6 @@ module Cucumber
|
|
27
34
|
@args = args
|
28
35
|
@out_stream = out_stream == STDOUT ? Formatter::ColorIO.new : out_stream
|
29
36
|
@error_stream = error_stream
|
30
|
-
$err = error_stream
|
31
|
-
@unsupported_programming_languages = []
|
32
37
|
end
|
33
38
|
|
34
39
|
def execute!(step_mother)
|
@@ -41,13 +46,19 @@ module Cucumber
|
|
41
46
|
end
|
42
47
|
end
|
43
48
|
step_mother.options = configuration.options
|
49
|
+
|
50
|
+
logger = Logger.new(@out_stream)
|
51
|
+
logger.formatter = LogFormatter.new
|
52
|
+
logger.level = Logger::INFO
|
53
|
+
logger.level = Logger::DEBUG if configuration.verbose?
|
54
|
+
step_mother.log = logger
|
44
55
|
|
45
56
|
# Feature files must be loaded before files are required.
|
46
57
|
# This is because i18n step methods are only aliased when
|
47
58
|
# features are loaded. If we swap the order, the requires
|
48
59
|
# will fail.
|
49
|
-
features = load_plain_text_features(
|
50
|
-
|
60
|
+
features = step_mother.load_plain_text_features(configuration.feature_files)
|
61
|
+
step_mother.load_code_files(configuration.step_defs_to_load)
|
51
62
|
enable_diffing
|
52
63
|
|
53
64
|
visitor = configuration.build_formatter_broadcaster(step_mother)
|
@@ -80,22 +91,6 @@ module Cucumber
|
|
80
91
|
exceeded
|
81
92
|
end
|
82
93
|
|
83
|
-
def load_plain_text_features(step_mother)
|
84
|
-
features = Ast::Features.new
|
85
|
-
|
86
|
-
verbose_log("Features:")
|
87
|
-
configuration.feature_files.each do |f|
|
88
|
-
feature_file = FeatureFile.new(f)
|
89
|
-
feature = feature_file.parse(step_mother, configuration.options)
|
90
|
-
if feature
|
91
|
-
features.add_feature(feature)
|
92
|
-
verbose_log(" * #{f}")
|
93
|
-
end
|
94
|
-
end
|
95
|
-
verbose_log("\n")
|
96
|
-
features
|
97
|
-
end
|
98
|
-
|
99
94
|
def configuration
|
100
95
|
return @configuration if @configuration
|
101
96
|
|
@@ -110,38 +105,6 @@ module Cucumber
|
|
110
105
|
|
111
106
|
private
|
112
107
|
|
113
|
-
def load_step_defs(step_mother)
|
114
|
-
step_def_files = configuration.step_defs_to_load
|
115
|
-
verbose_log("Step Definitions:")
|
116
|
-
step_def_files.each do |step_def_file|
|
117
|
-
load_step_def(step_mother, step_def_file)
|
118
|
-
end
|
119
|
-
verbose_log("\n")
|
120
|
-
end
|
121
|
-
|
122
|
-
def load_step_def(step_mother, step_def_file)
|
123
|
-
if programming_language = programming_language_for(step_mother, step_def_file)
|
124
|
-
verbose_log(" * #{step_def_file}")
|
125
|
-
programming_language.load_step_def_file(step_def_file)
|
126
|
-
else
|
127
|
-
verbose_log(" * #{step_def_file} [NOT SUPPORTED]")
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
|
-
def programming_language_for(step_mother, step_def_file) # :nodoc:
|
132
|
-
if ext = File.extname(step_def_file)[1..-1]
|
133
|
-
return nil if @unsupported_programming_languages.index(ext)
|
134
|
-
begin
|
135
|
-
step_mother.load_programming_language(ext)
|
136
|
-
rescue LoadError
|
137
|
-
@unsupported_programming_languages << ext
|
138
|
-
nil
|
139
|
-
end
|
140
|
-
else
|
141
|
-
nil
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
108
|
def enable_diffing
|
146
109
|
if configuration.diff_enabled?
|
147
110
|
begin
|
data/lib/cucumber/constantize.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require 'cucumber/platform'
|
2
2
|
|
3
3
|
module Cucumber
|
4
|
+
# Raised if the number of a StepDefinition's Regexp match groups
|
5
|
+
# is different from the number of Proc arguments.
|
4
6
|
class ArityMismatchError < StandardError
|
5
7
|
end
|
6
8
|
end
|
7
9
|
|
8
|
-
class Object
|
10
|
+
class Object #:nodoc:
|
9
11
|
def cucumber_instance_exec(check_arity, pseudo_method, *args, &block)
|
10
12
|
cucumber_run_with_backtrace_filtering(pseudo_method) do
|
11
13
|
if check_arity && !cucumber_compatible_arity?(args, block)
|
@@ -23,7 +25,9 @@ class Object
|
|
23
25
|
end
|
24
26
|
end
|
25
27
|
end
|
26
|
-
|
28
|
+
|
29
|
+
private
|
30
|
+
|
27
31
|
def cucumber_arity(block)
|
28
32
|
a = block.arity
|
29
33
|
Cucumber::RUBY_1_9 ? a : (a == -1 ? 0 : a)
|
@@ -48,7 +52,8 @@ class Object
|
|
48
52
|
|
49
53
|
unless defined? instance_exec # 1.9
|
50
54
|
# http://eigenclass.org/hiki/bounded+space+instance_exec
|
51
|
-
module InstanceExecHelper
|
55
|
+
module InstanceExecHelper #:nodoc:
|
56
|
+
end
|
52
57
|
include InstanceExecHelper
|
53
58
|
def instance_exec(*args, &block)
|
54
59
|
begin
|
@@ -3,10 +3,11 @@ require 'cucumber/filter'
|
|
3
3
|
|
4
4
|
module Cucumber
|
5
5
|
class FeatureFile
|
6
|
-
FILE_COLON_LINE_PATTERN = /^([\w\W]*?):([\d:]+)$/
|
7
|
-
LANGUAGE_PATTERN = /language:\s*(.*)/
|
6
|
+
FILE_COLON_LINE_PATTERN = /^([\w\W]*?):([\d:]+)$/ #:nodoc:
|
7
|
+
LANGUAGE_PATTERN = /language:\s*(.*)/ #:nodoc:
|
8
8
|
|
9
|
-
# The +uri+ argument
|
9
|
+
# The +uri+ argument is the location of the source. It can ba a path
|
10
|
+
# or a path:line1:line2 etc. If +source+ is passed, +uri+ is ignored.
|
10
11
|
def initialize(uri, source=nil)
|
11
12
|
@source = source
|
12
13
|
_, @path, @lines = *FILE_COLON_LINE_PATTERN.match(uri)
|
data/lib/cucumber/filter.rb
CHANGED
@@ -23,8 +23,9 @@ Term::ANSIColor.coloring = false if !STDOUT.tty? and not ENV.has_key?("AUTOTEST"
|
|
23
23
|
|
24
24
|
module Cucumber
|
25
25
|
module Formatter
|
26
|
-
# Defines aliases for coloured output. You
|
27
|
-
#
|
26
|
+
# Defines aliases for coloured output. You don't invoke any methods from this
|
27
|
+
# module directly, but you can change the output colours by defining
|
28
|
+
# a <tt>CUCUMBER_COLORS</tt> variable in your shell, very much like how you can
|
28
29
|
# tweak the familiar POSIX command <tt>ls</tt> with
|
29
30
|
# <a href="http://mipsisrisc.com/rambling/2008/06/27/lscolorsls_colors-now-with-linux-support/">$LSCOLORS/$LS_COLORS</a>
|
30
31
|
#
|
@@ -97,7 +98,7 @@ module Cucumber
|
|
97
98
|
end
|
98
99
|
end
|
99
100
|
|
100
|
-
def self.define_grey
|
101
|
+
def self.define_grey #:nodoc:
|
101
102
|
begin
|
102
103
|
gem 'genki-ruby-terminfo'
|
103
104
|
require 'terminfo'
|
@@ -125,8 +126,8 @@ module Cucumber
|
|
125
126
|
end
|
126
127
|
end
|
127
128
|
|
128
|
-
def self.define_real_grey
|
129
|
-
def grey(m)
|
129
|
+
def self.define_real_grey #:nodoc:
|
130
|
+
def grey(m) #:nodoc:
|
130
131
|
if ::Term::ANSIColor.coloring?
|
131
132
|
"\e[90m#{m}\e[0m"
|
132
133
|
else
|
@@ -3,10 +3,10 @@ require 'forwardable'
|
|
3
3
|
module Cucumber
|
4
4
|
module Formatter
|
5
5
|
# Adapter to make #puts/#print/#flush work with colours on Windows
|
6
|
-
class ColorIO
|
6
|
+
class ColorIO #:nodoc:
|
7
7
|
extend Forwardable
|
8
8
|
def_delegators :@kernel, :puts, :print # win32console colours only work when sent to Kernel
|
9
|
-
def_delegators :@stdout, :flush, :tty?, :write
|
9
|
+
def_delegators :@stdout, :flush, :tty?, :write, :close
|
10
10
|
|
11
11
|
def initialize
|
12
12
|
@kernel = Kernel
|
@@ -8,7 +8,7 @@ end
|
|
8
8
|
module Cucumber
|
9
9
|
module Formatter
|
10
10
|
# Emits attributes ordered alphabetically, so that we can predicatbly test output.
|
11
|
-
class OrderedXmlMarkup < Builder::XmlMarkup
|
11
|
+
class OrderedXmlMarkup < Builder::XmlMarkup #:nodoc:
|
12
12
|
def _insert_attributes(attrs, order=[])
|
13
13
|
return if attrs.nil?
|
14
14
|
keys = attrs.keys.map{|k| k.to_s}
|
@@ -3,6 +3,8 @@ require 'fileutils'
|
|
3
3
|
|
4
4
|
module Cucumber
|
5
5
|
module Formatter
|
6
|
+
# The formatter used for <tt>--format pretty</tt> (the default formatter).
|
7
|
+
#
|
6
8
|
# This formatter prints features to plain text - exactly how they were parsed,
|
7
9
|
# just prettier. That means with proper indentation and alignment of table columns.
|
8
10
|
#
|
@@ -96,15 +98,30 @@ module Cucumber
|
|
96
98
|
visit_feature_element_name(keyword, name, file_colon_line, source_indent)
|
97
99
|
end
|
98
100
|
|
101
|
+
def visit_examples_array(examples_array)
|
102
|
+
@indent = 4
|
103
|
+
@io.puts
|
104
|
+
examples_array[0..-2].each { |ea| super(ea) }
|
105
|
+
@last_example = true
|
106
|
+
super(examples_array.last)
|
107
|
+
@last_example = nil
|
108
|
+
end
|
109
|
+
|
99
110
|
def visit_examples_name(keyword, name)
|
100
111
|
names = name.strip.empty? ? [name.strip] : name.split("\n")
|
101
|
-
@io.puts("
|
112
|
+
@io.puts(" #{keyword} #{names[0]}")
|
102
113
|
names[1..-1].each {|s| @io.puts " #{s}" } unless names.empty?
|
103
114
|
@io.flush
|
104
115
|
@indent = 6
|
105
116
|
@scenario_indent = 6
|
106
117
|
end
|
107
118
|
|
119
|
+
def visit_outline_table(outline_table)
|
120
|
+
super
|
121
|
+
@indent = 4
|
122
|
+
@io.puts unless @last_example
|
123
|
+
end
|
124
|
+
|
108
125
|
def visit_scenario_name(keyword, name, file_colon_line, source_indent)
|
109
126
|
visit_feature_element_name(keyword, name, file_colon_line, source_indent)
|
110
127
|
end
|
@@ -188,9 +205,6 @@ module Cucumber
|
|
188
205
|
end
|
189
206
|
|
190
207
|
private
|
191
|
-
def cell_prefix(status)
|
192
|
-
@prefixes[status]
|
193
|
-
end
|
194
208
|
|
195
209
|
def cell_prefix(status)
|
196
210
|
@prefixes[status]
|