diff --git a/History.txt b/History.txt
index 81b42a1fb56..5873292c3fb 100644
--- a/History.txt
+++ b/History.txt
@@ -4,6 +4,7 @@
* Table.map_headers! will fail with a decent error message when 0 or 2+ headers are matched. (Aslak Hellesøy)
=== New Features
+* The public API is documented and there is a new :sdoc task to generate nice searchable API docs.
* Add :default => :cucumber when setting up Rake tasks for Cucumber in Rails (Aslak Hellesøy)
* New When /^I fill in "([^\"]*)" for "([^\"]*)"$/ Webrat step for Rails (Aslak Hellesøy)
diff --git a/Manifest.txt b/Manifest.txt
index 289bc6d41cf..6b836a94539 100644
--- a/Manifest.txt
+++ b/Manifest.txt
@@ -289,7 +289,8 @@ gem_tasks/flog.rake
gem_tasks/gemspec.rake
gem_tasks/rspec.rake
gem_tasks/sass.rake
-gem_tasks/yard.rake
+gem_tasks/sdoc.rake
+lib/README.rdoc
lib/autotest/cucumber.rb
lib/autotest/cucumber_mixin.rb
lib/autotest/cucumber_rails.rb
@@ -396,7 +397,6 @@ spec/cucumber/ast/scenario_spec.rb
spec/cucumber/ast/step_collection_spec.rb
spec/cucumber/ast/step_spec.rb
spec/cucumber/ast/table_spec.rb
-spec/cucumber/ast/visitor_spec.rb
spec/cucumber/broadcaster_spec.rb
spec/cucumber/cli/configuration_spec.rb
spec/cucumber/cli/drb_client_spec.rb
diff --git a/gem_tasks/features.rake b/gem_tasks/features.rake
index 9eb0d87596f..40b80fa4d4d 100644
--- a/gem_tasks/features.rake
+++ b/gem_tasks/features.rake
@@ -3,6 +3,7 @@ require 'cucumber/rake/task'
Cucumber::Rake::Task.new do |t|
t.cucumber_opts = %w{--format progress}
+ t.rcov = ENV['RCOV']
end
Cucumber::Rake::Task.new('pretty') do |t|
diff --git a/gem_tasks/sdoc.rake b/gem_tasks/sdoc.rake
new file mode 100644
index 00000000000..3f63060134b
--- /dev/null
+++ b/gem_tasks/sdoc.rake
@@ -0,0 +1,7 @@
+require 'sdoc' # and use your RDoc task the same way you used it before
+
+Rake::RDocTask.new(:sdoc) do |rdoc|
+ rdoc.rdoc_dir = 'doc/sdoc'
+ rdoc.options += %w{--fmt shtml -N --webcvs=http://github.com/aslakhellesoy/cucumber/blob/v0.3.96/%s --title "Cucumber API" --threads 4 --main README --exclude cucumber/parser lib}
+ rdoc.template = 'direct' # lighter template used on railsapi.com
+end
diff --git a/gem_tasks/yard.rake b/gem_tasks/yard.rake
deleted file mode 100644
index cc3341b5ac2..00000000000
--- a/gem_tasks/yard.rake
+++ /dev/null
@@ -1,8 +0,0 @@
-begin
- require 'yard'
-
- YARD::Rake::YardocTask.new do |t|
- t.files = ['lib/**/*.rb']
- end
-rescue LoadError => ignore
-end
\ No newline at end of file
diff --git a/lib/README.rdoc b/lib/README.rdoc
new file mode 100644
index 00000000000..cae1a80ae18
--- /dev/null
+++ b/lib/README.rdoc
@@ -0,0 +1,12 @@
+= Cucumber API
+
+This is the public API of Cucumber. The public API includes the classes, modules
+and methods you can use if you are a user of Cucumber. It also applies to you if
+you're developing a 3rd party tool that integrates with Cucumber.
+
+== Internal API
+
+Cucumber has more classes, modules and methods than what you can see in the public
+API. If you decide to dive into the source code and make use of an API that isn't
+part of this documentation - beware that this API might change at any time. If you
+want a particular internal API to be promoted to the public API - let us know.
diff --git a/lib/cucumber/ast/background.rb b/lib/cucumber/ast/background.rb
index 2106675c3bb..022cb6072cf 100644
--- a/lib/cucumber/ast/background.rb
+++ b/lib/cucumber/ast/background.rb
@@ -2,7 +2,7 @@
module Cucumber
module Ast
- class Background
+ class Background #:nodoc:
include FeatureElement
attr_reader :feature_elements
diff --git a/lib/cucumber/ast/comment.rb b/lib/cucumber/ast/comment.rb
index ed1ff04570d..245cf0dfe2b 100644
--- a/lib/cucumber/ast/comment.rb
+++ b/lib/cucumber/ast/comment.rb
@@ -7,7 +7,7 @@ module Ast
#
# This gets parsed into a Comment with value "# Lorem ipsum\n# dolor sit amet\n"
#
- class Comment
+ class Comment #:nodoc:
def initialize(value)
@value = value
end
diff --git a/lib/cucumber/ast/examples.rb b/lib/cucumber/ast/examples.rb
index 25300d31035..9da5754854f 100644
--- a/lib/cucumber/ast/examples.rb
+++ b/lib/cucumber/ast/examples.rb
@@ -1,6 +1,6 @@
module Cucumber
module Ast
- class Examples
+ class Examples #:nodoc:
def initialize(line, keyword, name, outline_table)
@keyword, @name, @outline_table = keyword, name, outline_table
end
diff --git a/lib/cucumber/ast/feature.rb b/lib/cucumber/ast/feature.rb
index 96f665b41d0..cb52e44d389 100644
--- a/lib/cucumber/ast/feature.rb
+++ b/lib/cucumber/ast/feature.rb
@@ -1,7 +1,7 @@
module Cucumber
module Ast
# Represents the root node of a parsed feature.
- class Feature
+ class Feature #:nodoc:
attr_accessor :file, :language
attr_writer :features
attr_reader :name
diff --git a/lib/cucumber/ast/feature_element.rb b/lib/cucumber/ast/feature_element.rb
index 2b095a16eff..0240c0b6450 100644
--- a/lib/cucumber/ast/feature_element.rb
+++ b/lib/cucumber/ast/feature_element.rb
@@ -1,7 +1,7 @@
require 'enumerator'
module Cucumber
- module FeatureElement
+ module FeatureElement #:nodoc:
attr_writer :feature
def attach_steps(steps)
diff --git a/lib/cucumber/ast/features.rb b/lib/cucumber/ast/features.rb
index c110bc3f9d6..7460b46a098 100644
--- a/lib/cucumber/ast/features.rb
+++ b/lib/cucumber/ast/features.rb
@@ -1,6 +1,6 @@
module Cucumber
module Ast
- class Features
+ class Features #:nodoc:
include Enumerable
attr_reader :duration
diff --git a/lib/cucumber/ast/outline_table.rb b/lib/cucumber/ast/outline_table.rb
index e308261f345..59c53a1988a 100644
--- a/lib/cucumber/ast/outline_table.rb
+++ b/lib/cucumber/ast/outline_table.rb
@@ -1,6 +1,6 @@
module Cucumber
module Ast
- class OutlineTable < Table
+ class OutlineTable < Table #:nodoc:
def initialize(raw, scenario_outline)
super(raw)
@scenario_outline = scenario_outline
@@ -44,7 +44,7 @@ def visit_scenario_name(visitor, row)
@scenario_outline.visit_scenario_name(visitor, row)
end
- class ExampleRow < Cells
+ class ExampleRow < Cells #:nodoc:
attr_reader :scenario_outline # https://rspec.lighthouseapp.com/projects/16211/tickets/342
def create_step_invocations!(scenario_outline)
diff --git a/lib/cucumber/ast/py_string.rb b/lib/cucumber/ast/py_string.rb
index 7fd1ee246b1..f3888a673ac 100644
--- a/lib/cucumber/ast/py_string.rb
+++ b/lib/cucumber/ast/py_string.rb
@@ -16,7 +16,7 @@ module Ast
#
# Note how the indentation from the source is stripped away.
#
- class PyString
+ class PyString #:nodoc:
def self.default_arg_name
"string"
end
diff --git a/lib/cucumber/ast/scenario.rb b/lib/cucumber/ast/scenario.rb
index f386f645178..ce9292534da 100644
--- a/lib/cucumber/ast/scenario.rb
+++ b/lib/cucumber/ast/scenario.rb
@@ -2,7 +2,7 @@
module Cucumber
module Ast
- class Scenario
+ class Scenario #:nodoc:
include FeatureElement
attr_reader :name, :line
diff --git a/lib/cucumber/ast/scenario_outline.rb b/lib/cucumber/ast/scenario_outline.rb
index 04849378190..b4138e7793e 100644
--- a/lib/cucumber/ast/scenario_outline.rb
+++ b/lib/cucumber/ast/scenario_outline.rb
@@ -1,9 +1,9 @@
module Cucumber
module Ast
- class ScenarioOutline
+ class ScenarioOutline #:nodoc:
include FeatureElement
- module ExamplesArray
+ module ExamplesArray #:nodoc:
def accept(visitor)
return if $cucumber_interrupted
each do |examples|
diff --git a/lib/cucumber/ast/step.rb b/lib/cucumber/ast/step.rb
index 6259e6782ac..9c18394ef5f 100644
--- a/lib/cucumber/ast/step.rb
+++ b/lib/cucumber/ast/step.rb
@@ -3,7 +3,7 @@
module Cucumber
module Ast
- class Step
+ class Step #:nodoc:
attr_reader :line, :keyword, :name, :multiline_arg
attr_writer :step_collection, :options
attr_accessor :feature_element, :exception
diff --git a/lib/cucumber/ast/step_collection.rb b/lib/cucumber/ast/step_collection.rb
index 1f7ed0353db..d0b416ffa3c 100644
--- a/lib/cucumber/ast/step_collection.rb
+++ b/lib/cucumber/ast/step_collection.rb
@@ -1,7 +1,7 @@
module Cucumber
module Ast
# Holds an Array of Step or StepDefinition
- class StepCollection
+ class StepCollection #:nodoc:
include Enumerable
def initialize(steps)
diff --git a/lib/cucumber/ast/step_invocation.rb b/lib/cucumber/ast/step_invocation.rb
index da35deb8736..ff6434f9175 100644
--- a/lib/cucumber/ast/step_invocation.rb
+++ b/lib/cucumber/ast/step_invocation.rb
@@ -2,7 +2,7 @@
module Cucumber
module Ast
- class StepInvocation
+ class StepInvocation #:nodoc:
attr_writer :step_collection, :background
attr_reader :name, :matched_cells, :status, :reported_exception
attr_accessor :exception
diff --git a/lib/cucumber/ast/table.rb b/lib/cucumber/ast/table.rb
index d9fa28286d4..2796f450426 100644
--- a/lib/cucumber/ast/table.rb
+++ b/lib/cucumber/ast/table.rb
@@ -1,11 +1,23 @@
module Cucumber
module Ast
- # Holds the data of a table parsed from a feature file:
+ # Step Definitions that match a plain text Step with a multiline argument table
+ # will receive it as an instance of Table. A Table object holds the data of a
+ # table parsed from a feature file and lets you access and manipulate the data
+ # in different ways.
#
- # | a | b |
- # | c | d |
+ # For example:
#
- # This gets parsed into a Table holding the values [['a', 'b'], ['c', 'd']]
+ # Given I have:
+ # | a | b |
+ # | c | d |
+ #
+ # And a matching StepDefinition:
+ #
+ # Given /I have:/ do |table|
+ # data = table.raw
+ # end
+ #
+ # This will store [['a', 'b'], ['c', 'd']] in the data variable.
#
class Table
include Enumerable
@@ -14,10 +26,14 @@ class Table
attr_accessor :file
- def self.default_arg_name
+ def self.default_arg_name #:nodoc:
"table"
end
+ # Creates a new instance. +raw+ should be an Array of Array of String.
+ # You don't typically create your own Table objects - Cucumber will do
+ # it internally and pass them to your Step Definitions.
+ #
def initialize(raw, conversion_procs = NULL_CONVERSIONS.dup)
@cells_class = Cells
@cell_class = Cell
@@ -28,21 +44,23 @@ def initialize(raw, conversion_procs = NULL_CONVERSIONS.dup)
@conversion_procs = conversion_procs
end
- # Creates a copy of this table, inheriting the column mappings.
+ # Creates a copy of this table, inheriting any column mappings.
+ # registered with #map_headers!
+ #
def dup
self.class.new(raw.dup, @conversion_procs.dup)
end
# Returns a new, transposed table. Example:
#
- # | a | 7 | 4 |
- # | b | 9 | 2 |
+ # | a | 7 | 4 |
+ # | b | 9 | 2 |
#
# Gets converted into the following:
#
- # | a | b |
- # | 7 | 9 |
- # | 4 | 2 |
+ # | a | b |
+ # | 7 | 9 |
+ # | 4 | 2 |
#
def transpose
self.class.new(raw.transpose, @conversion_procs.dup)
@@ -109,11 +127,11 @@ def rows
raw[1..-1]
end
- def each_cells_row(&proc)
+ def each_cells_row(&proc) #:nodoc:
cells_rows.each(&proc)
end
- def accept(visitor)
+ def accept(visitor) #:nodoc:
return if $cucumber_interrupted
cells_rows.each do |row|
visitor.visit_table_row(row)
@@ -206,10 +224,10 @@ def map_column!(column_name, strict=true, &conversion_proc)
# Whether to raise or not raise can be changed by setting values in
# +options+ to true or false:
#
- # * missing_row: Raise on missing rows (defaults to true)
- # * surplus_row: Raise on surplus rows (defaults to true)
- # * missing_col: Raise on missing columns (defaults to true)
- # * surplus_col: Raise on surplus columns (defaults to false)
+ # * missing_row : Raise on missing rows (defaults to true)
+ # * surplus_row : Raise on surplus rows (defaults to true)
+ # * missing_col : Raise on missing columns (defaults to true)
+ # * surplus_col : Raise on surplus columns (defaults to false)
#
# The +other_table+ argument can be another Table, an Array of Array or
# an Array of Hash (similar to the structure returned by #hashes).
@@ -298,11 +316,11 @@ def index(cells) #:nodoc:
cells_rows.index(cells)
end
- def verify_column(column_name)
+ def verify_column(column_name) #:nodoc:
raise %{The column named "#{column_name}" does not exist} unless raw[0].include?(column_name)
end
- def verify_table_width(width)
+ def verify_table_width(width) #:nodoc:
raise %{The table must have exactly #{width} columns} unless raw[0].size == width
end
@@ -321,33 +339,33 @@ def arguments_replaced(arguments) #:nodoc:
Table.new(raw_with_replaced_args)
end
- def has_text?(text)
+ def has_text?(text) #:nodoc:
raw.flatten.compact.detect{|cell_value| cell_value.index(text)}
end
- def cells_rows
+ def cells_rows #:nodoc:
@rows ||= cell_matrix.map do |cell_row|
@cells_class.new(self, cell_row)
end
end
- def headers
+ def headers #:nodoc:
raw.first
end
- def header_cell(col)
+ def header_cell(col) #:nodoc:
cells_rows[0][col]
end
- def cell_matrix
+ def cell_matrix #:nodoc:
@cell_matrix
end
- def col_width(col)
+ def col_width(col) #:nodoc:
columns[col].__send__(:width)
end
- def to_s(options = {})
+ def to_s(options = {}) #:nodoc:
options = {:color => true, :indent => 2, :prefixes => TO_S_PREFIXES}.merge(options)
io = StringIO.new
@@ -371,7 +389,7 @@ def to_s(options = {})
protected
- def inspect_rows(missing_row, inserted_row)
+ def inspect_rows(missing_row, inserted_row) #:nodoc:
missing_row.each_with_index do |missing_cell, col|
inserted_cell = inserted_row[col]
if(missing_cell.value != inserted_cell.value && (missing_cell.value.to_s == inserted_cell.value.to_s))
@@ -381,7 +399,7 @@ def inspect_rows(missing_row, inserted_row)
end
end
- def create_cell_matrix(raw)
+ def create_cell_matrix(raw) #:nodoc:
@cell_matrix = raw.map do |raw_row|
line = raw_row.line rescue -1
raw_row.map do |raw_cell|
@@ -390,7 +408,7 @@ def create_cell_matrix(raw)
end
end
- def convert_columns!
+ def convert_columns! #:nodoc:
cell_matrix.transpose.each do |col|
conversion_proc = @conversion_procs[col[0].value]
col[1..-1].each do |cell|
@@ -399,7 +417,7 @@ def convert_columns!
end
end
- def require_diff_lcs
+ def require_diff_lcs #:nodoc:
begin
require 'diff/lcs'
rescue LoadError => e
@@ -408,23 +426,23 @@ def require_diff_lcs
end
end
- def clear_cache!
+ def clear_cache! #:nodoc:
@hashes = @rows_hash = @rows = @columns = nil
end
- def columns
+ def columns #:nodoc:
@columns ||= cell_matrix.transpose.map do |cell_row|
@cells_class.new(self, cell_row)
end.freeze
end
- def new_cell(raw_cell, line)
+ def new_cell(raw_cell, line) #:nodoc:
@cell_class.new(raw_cell, self, line)
end
# Pads our own cell_matrix and returns a cell matrix of same
# column width that can be used for diffing
- def pad!(other_cell_matrix)
+ def pad!(other_cell_matrix) #:nodoc:
clear_cache!
cols = cell_matrix.transpose
unmapped_cols = other_cell_matrix.transpose
@@ -462,38 +480,38 @@ def pad!(other_cell_matrix)
(mapped_cols + unmapped_cols).transpose
end
- def ensure_table(table_or_array)
+ def ensure_table(table_or_array) #:nodoc:
return table_or_array if Table === table_or_array
table_or_array = hashes_to_array(table_or_array) if Hash === table_or_array[0]
table_or_array = enumerable_to_array(table_or_array) unless Array == table_or_array[0]
Table.new(table_or_array)
end
- def hashes_to_array(hashes)
+ def hashes_to_array(hashes) #:nodoc:
header = hashes[0].keys
[header] + hashes.map{|hash| header.map{|key| hash[key]}}
end
- def enumerable_to_array(rows)
+ def enumerable_to_array(rows) #:nodoc:
rows.map{|row| row.map{|cell| cell}}
end
- def ensure_green!
+ def ensure_green! #:nodoc:
each_cell{|cell| cell.status = :passed}
end
- def each_cell(&proc)
+ def each_cell(&proc) #:nodoc:
cell_matrix.each{|row| row.each(&proc)}
end
- def mark_as_missing(col)
+ def mark_as_missing(col) #:nodoc:
col.each do |cell|
cell.status = :undefined
end
end
# Represents a row of cells or columns of cells
- class Cells
+ class Cells #:nodoc:
include Enumerable
attr_reader :exception
@@ -549,7 +567,7 @@ def each(&proc)
end
end
- class Cell
+ class Cell #:nodoc:
attr_reader :line, :table
attr_accessor :status, :value
@@ -576,7 +594,7 @@ def to_sexp #:nodoc:
end
end
- class SurplusCell < Cell
+ class SurplusCell < Cell #:nodoc:
def status
:comment
end
diff --git a/lib/cucumber/ast/tags.rb b/lib/cucumber/ast/tags.rb
index 140a9f538dc..132f05898ee 100644
--- a/lib/cucumber/ast/tags.rb
+++ b/lib/cucumber/ast/tags.rb
@@ -6,7 +6,7 @@ module Ast
#
# This gets stored internally as ["invoice", "release_2"]
#
- class Tags
+ class Tags #:nodoc:
def self.strip_prefix(tag_name)
tag_name =~ /^@(.*)/ ? $1 : tag_name
end
diff --git a/lib/cucumber/ast/visitor.rb b/lib/cucumber/ast/visitor.rb
index 4bc52060501..b13882a91df 100644
--- a/lib/cucumber/ast/visitor.rb
+++ b/lib/cucumber/ast/visitor.rb
@@ -1,20 +1,17 @@
module Cucumber
module Ast
- # A dumb visitor that implements the whole Visitor API and just walks the tree.
+ # Base class for formatters. This class just walks the tree depth first.
+ # Just override the methods you care about. Remember to call super if you
+ # override a method.
class Visitor
- attr_accessor :options
- attr_reader :step_mother
+ attr_accessor :options #:nodoc:
+ attr_reader :step_mother #:nodoc:
def initialize(step_mother)
@options = {}
@step_mother = step_mother
end
- def matches_scenario_names?(node)
- scenario_name_regexps = options[:name_regexps] || []
- scenario_name_regexps.empty? || node.matches_scenario_names?(scenario_name_regexps)
- end
-
def visit_features(features)
features.accept(self)
end
@@ -109,6 +106,7 @@ def visit_table_cell(table_cell)
def visit_table_cell_value(value, status)
end
+ # Print +announcement+. This method can be called from within StepDefinitions.
def announce(announcement)
end
diff --git a/lib/cucumber/broadcaster.rb b/lib/cucumber/broadcaster.rb
index 83bbda07208..639fc51b232 100644
--- a/lib/cucumber/broadcaster.rb
+++ b/lib/cucumber/broadcaster.rb
@@ -1,5 +1,5 @@
module Cucumber
- class Broadcaster
+ class Broadcaster #:nodoc:
def initialize(receivers = [])
@receivers = receivers
end
diff --git a/lib/cucumber/constantize.rb b/lib/cucumber/constantize.rb
index f2aede2024e..5472910718c 100644
--- a/lib/cucumber/constantize.rb
+++ b/lib/cucumber/constantize.rb
@@ -1,5 +1,5 @@
module Cucumber
- module Constantize
+ module Constantize #:nodoc:
def constantize(camel_cased_word)
begin
names = camel_cased_word.split('::')
diff --git a/lib/cucumber/core_ext/exception.rb b/lib/cucumber/core_ext/exception.rb
index 6a0204297c3..77e9a4b552b 100644
--- a/lib/cucumber/core_ext/exception.rb
+++ b/lib/cucumber/core_ext/exception.rb
@@ -18,7 +18,7 @@
#
# All backtrace munging can be turned off with the --backtrace switch
#
-class Exception
+class Exception #:nodoc:
CUCUMBER_FILTER_PATTERNS = [
/vendor\/rails|lib\/cucumber|bin\/cucumber:|lib\/rspec|gems\//
]
diff --git a/lib/cucumber/core_ext/instance_exec.rb b/lib/cucumber/core_ext/instance_exec.rb
index 86b6c4e6fe8..5046ce4a932 100644
--- a/lib/cucumber/core_ext/instance_exec.rb
+++ b/lib/cucumber/core_ext/instance_exec.rb
@@ -1,11 +1,13 @@
require 'cucumber/platform'
module Cucumber
+ # Raised if the number of a StepDefinition's Regexp match groups
+ # is different from the number of Proc arguments.
class ArityMismatchError < StandardError
end
end
-class Object
+class Object #:nodoc:
def cucumber_instance_exec(check_arity, pseudo_method, *args, &block)
cucumber_run_with_backtrace_filtering(pseudo_method) do
if check_arity && !cucumber_compatible_arity?(args, block)
@@ -23,7 +25,9 @@ def cucumber_instance_exec(check_arity, pseudo_method, *args, &block)
end
end
end
-
+
+ private
+
def cucumber_arity(block)
a = block.arity
Cucumber::RUBY_1_9 ? a : (a == -1 ? 0 : a)
@@ -48,7 +52,8 @@ def cucumber_run_with_backtrace_filtering(pseudo_method)
unless defined? instance_exec # 1.9
# http://eigenclass.org/hiki/bounded+space+instance_exec
- module InstanceExecHelper; end
+ module InstanceExecHelper #:nodoc:
+ end
include InstanceExecHelper
def instance_exec(*args, &block)
begin
diff --git a/lib/cucumber/core_ext/proc.rb b/lib/cucumber/core_ext/proc.rb
index da34afe2e62..e048bd27afa 100644
--- a/lib/cucumber/core_ext/proc.rb
+++ b/lib/cucumber/core_ext/proc.rb
@@ -1,5 +1,5 @@
# Proc extension to get more location info out of a proc
-class Proc
+class Proc #:nodoc:
PROC_PATTERN = /[\d\w]+@(.*):(.*)>/
def to_comment_line
diff --git a/lib/cucumber/core_ext/string.rb b/lib/cucumber/core_ext/string.rb
index 6931202d6b1..b3c40d63a1d 100644
--- a/lib/cucumber/core_ext/string.rb
+++ b/lib/cucumber/core_ext/string.rb
@@ -1,4 +1,4 @@
-class String
+class String #:nodoc:
def indent(n)
if n >= 0
gsub(/^/, ' ' * n)
diff --git a/lib/cucumber/feature_file.rb b/lib/cucumber/feature_file.rb
index b8a1477538d..a72944b0774 100644
--- a/lib/cucumber/feature_file.rb
+++ b/lib/cucumber/feature_file.rb
@@ -3,10 +3,11 @@
module Cucumber
class FeatureFile
- FILE_COLON_LINE_PATTERN = /^([\w\W]*?):([\d:]+)$/
- LANGUAGE_PATTERN = /language:\s*(.*)/
+ FILE_COLON_LINE_PATTERN = /^([\w\W]*?):([\d:]+)$/ #:nodoc:
+ LANGUAGE_PATTERN = /language:\s*(.*)/ #:nodoc:
- # The +uri+ argument can ba a path or a path:line1:line2 etc.
+ # The +uri+ argument is the location of the source. It can ba a path
+ # or a path:line1:line2 etc. If +source+ is passed, +uri+ is ignored.
def initialize(uri, source=nil)
@source = source
_, @path, @lines = *FILE_COLON_LINE_PATTERN.match(uri)
diff --git a/lib/cucumber/filter.rb b/lib/cucumber/filter.rb
index 11708f13a29..4bfd380fed8 100644
--- a/lib/cucumber/filter.rb
+++ b/lib/cucumber/filter.rb
@@ -1,5 +1,6 @@
module Cucumber
- class Filter
+ # Filters the AST based on --tags and --name
+ class Filter #:nodoc:
def initialize(lines, options)
@lines = lines
diff --git a/lib/cucumber/formatter/ansicolor.rb b/lib/cucumber/formatter/ansicolor.rb
index 1102a6096f7..6aa86db3486 100644
--- a/lib/cucumber/formatter/ansicolor.rb
+++ b/lib/cucumber/formatter/ansicolor.rb
@@ -23,8 +23,9 @@
module Cucumber
module Formatter
- # Defines aliases for coloured output. You can tweak the colours by defining
- # a CUCUMBER_COLORS variable in your shell, very much like you can
+ # Defines aliases for coloured output. You don't invoke any methods from this
+ # module directly, but you can change the output colours by defining
+ # a CUCUMBER_COLORS variable in your shell, very much like how you can
# tweak the familiar POSIX command ls with
# $LSCOLORS/$LS_COLORS
#
@@ -97,7 +98,7 @@ def #{method}_param(string=nil, &proc)
end
end
- def self.define_grey
+ def self.define_grey #:nodoc:
begin
gem 'genki-ruby-terminfo'
require 'terminfo'
@@ -125,8 +126,8 @@ def self.define_grey
end
end
- def self.define_real_grey
- def grey(m)
+ def self.define_real_grey #:nodoc:
+ def grey(m) #:nodoc:
if ::Term::ANSIColor.coloring?
"\e[90m#{m}\e[0m"
else
diff --git a/lib/cucumber/formatter/color_io.rb b/lib/cucumber/formatter/color_io.rb
index bc2f8558a9f..dbd3131efec 100644
--- a/lib/cucumber/formatter/color_io.rb
+++ b/lib/cucumber/formatter/color_io.rb
@@ -3,7 +3,7 @@
module Cucumber
module Formatter
# Adapter to make #puts/#print/#flush work with colours on Windows
- class ColorIO
+ class ColorIO #:nodoc:
extend Forwardable
def_delegators :@kernel, :puts, :print # win32console colours only work when sent to Kernel
def_delegators :@stdout, :flush, :tty?, :write
diff --git a/lib/cucumber/formatter/console.rb b/lib/cucumber/formatter/console.rb
index fb821cec057..828b6765642 100644
--- a/lib/cucumber/formatter/console.rb
+++ b/lib/cucumber/formatter/console.rb
@@ -3,6 +3,8 @@
module Cucumber
module Formatter
+ # This module contains helper methods that are used by formatters
+ # that print output to the terminal.
module Console
extend ANSIColor
include Duration
diff --git a/lib/cucumber/formatter/duration.rb b/lib/cucumber/formatter/duration.rb
index edca93450e9..19724900c9c 100644
--- a/lib/cucumber/formatter/duration.rb
+++ b/lib/cucumber/formatter/duration.rb
@@ -1,6 +1,9 @@
module Cucumber
module Formatter
module Duration
+ # Helper method for formatters that need to
+ # format a duration in seconds to the UNIX
+ # time format.
def format_duration(seconds)
m, s = seconds.divmod(60)
"#{m}m#{'%.3f' % s}s"
diff --git a/lib/cucumber/formatter/html.rb b/lib/cucumber/formatter/html.rb
index 6150356e055..c96491208e8 100644
--- a/lib/cucumber/formatter/html.rb
+++ b/lib/cucumber/formatter/html.rb
@@ -3,6 +3,7 @@
module Cucumber
module Formatter
+ # The formatter used for --format html
class Html < Ast::Visitor
include ERB::Util # for the #h method
include Duration
diff --git a/lib/cucumber/formatter/junit.rb b/lib/cucumber/formatter/junit.rb
index d7f3f03151e..f2fb519422a 100644
--- a/lib/cucumber/formatter/junit.rb
+++ b/lib/cucumber/formatter/junit.rb
@@ -2,6 +2,7 @@
module Cucumber
module Formatter
+ # The formatter used for --format junit
class Junit < Cucumber::Ast::Visitor
def initialize(step_mother, io, options)
diff --git a/lib/cucumber/formatter/ordered_xml_markup.rb b/lib/cucumber/formatter/ordered_xml_markup.rb
index bb44bc634fb..873a2d482f0 100644
--- a/lib/cucumber/formatter/ordered_xml_markup.rb
+++ b/lib/cucumber/formatter/ordered_xml_markup.rb
@@ -8,7 +8,7 @@
module Cucumber
module Formatter
# Emits attributes ordered alphabetically, so that we can predicatbly test output.
- class OrderedXmlMarkup < Builder::XmlMarkup
+ class OrderedXmlMarkup < Builder::XmlMarkup #:nodoc:
def _insert_attributes(attrs, order=[])
return if attrs.nil?
keys = attrs.keys.map{|k| k.to_s}
diff --git a/lib/cucumber/formatter/pretty.rb b/lib/cucumber/formatter/pretty.rb
index c7b86f3b7b1..34ef5b3a0c4 100644
--- a/lib/cucumber/formatter/pretty.rb
+++ b/lib/cucumber/formatter/pretty.rb
@@ -3,6 +3,8 @@
module Cucumber
module Formatter
+ # The formatter used for --format pretty (the default formatter).
+ #
# This formatter prints features to plain text - exactly how they were parsed,
# just prettier. That means with proper indentation and alignment of table columns.
#
diff --git a/lib/cucumber/formatter/profile.rb b/lib/cucumber/formatter/profile.rb
index c83471e2ed4..3317ffc2191 100644
--- a/lib/cucumber/formatter/profile.rb
+++ b/lib/cucumber/formatter/profile.rb
@@ -2,6 +2,7 @@
module Cucumber
module Formatter
+ # The formatter used for --format profile
class Profile < Progress
NUMBER_OF_STEP_DEFINITONS_TO_SHOW = 10
NUMBER_OF_STEP_INVOCATIONS_TO_SHOW = 5
diff --git a/lib/cucumber/formatter/progress.rb b/lib/cucumber/formatter/progress.rb
index 4fafbe7786c..b54824e9d3c 100644
--- a/lib/cucumber/formatter/progress.rb
+++ b/lib/cucumber/formatter/progress.rb
@@ -2,6 +2,7 @@
module Cucumber
module Formatter
+ # The formatter used for --format progress
class Progress < Ast::Visitor
include Console
diff --git a/lib/cucumber/formatter/rerun.rb b/lib/cucumber/formatter/rerun.rb
index 20b6957c3b8..09724b3b99b 100644
--- a/lib/cucumber/formatter/rerun.rb
+++ b/lib/cucumber/formatter/rerun.rb
@@ -1,5 +1,7 @@
module Cucumber
module Formatter
+ # The formatter used for --format rerun
+ #
# This formatter keeps track of all failing features and print out their location.
# Example:
#
diff --git a/lib/cucumber/formatter/steps.rb b/lib/cucumber/formatter/steps.rb
index 460ab51c670..8149ade1f7c 100644
--- a/lib/cucumber/formatter/steps.rb
+++ b/lib/cucumber/formatter/steps.rb
@@ -1,5 +1,6 @@
module Cucumber
module Formatter
+ # The formatter used for --format steps
class Steps < Ast::Visitor
def initialize(step_mother, io, options)
diff --git a/lib/cucumber/formatter/tag_cloud.rb b/lib/cucumber/formatter/tag_cloud.rb
index 20815426515..aa3aab8aa8a 100644
--- a/lib/cucumber/formatter/tag_cloud.rb
+++ b/lib/cucumber/formatter/tag_cloud.rb
@@ -1,6 +1,7 @@
module Cucumber
module Formatter
- # Custom formatter that prints a tag cloud
+ # The formatter used for --format tag_cloud
+ # Custom formatter that prints a tag cloud as a table.
class TagCloud < Cucumber::Ast::Visitor
def initialize(step_mother, io, options)
super(step_mother)
diff --git a/lib/cucumber/formatter/unicode.rb b/lib/cucumber/formatter/unicode.rb
index 7cf6423a082..f286406bb10 100644
--- a/lib/cucumber/formatter/unicode.rb
+++ b/lib/cucumber/formatter/unicode.rb
@@ -12,7 +12,7 @@
Cucumber::CODEPAGE = "cp#{codepage}"
require 'iconv'
- module Kernel
+ module Kernel #:nodoc:
alias cucumber_print print
def print(*a)
begin
diff --git a/lib/cucumber/formatter/usage.rb b/lib/cucumber/formatter/usage.rb
index 426305098aa..c9e2d664a0d 100644
--- a/lib/cucumber/formatter/usage.rb
+++ b/lib/cucumber/formatter/usage.rb
@@ -2,6 +2,7 @@
module Cucumber
module Formatter
+ # The formatter used for --format usage
class Usage < Ast::Visitor
include Console
diff --git a/lib/cucumber/parser/treetop_ext.rb b/lib/cucumber/parser/treetop_ext.rb
index 66322aafb56..e825928d2ee 100644
--- a/lib/cucumber/parser/treetop_ext.rb
+++ b/lib/cucumber/parser/treetop_ext.rb
@@ -12,6 +12,7 @@
module Cucumber
module Parser
+ # Raised if Cucumber fails to parse a feature file
class SyntaxError < StandardError
def initialize(parser, file, line_offset)
tf = parser.terminal_failures
@@ -22,7 +23,7 @@ def initialize(parser, file, line_offset)
end
end
- module TreetopExt
+ module TreetopExt #:nodoc:
def parse_or_fail(source, file=nil, filter=nil, line_offset=0)
parse_tree = parse(source)
if parse_tree.nil?
@@ -37,15 +38,15 @@ def parse_or_fail(source, file=nil, filter=nil, line_offset=0)
end
end
-module Treetop
- module Runtime
- class SyntaxNode
+module Treetop #:nodoc:
+ module Runtime #:nodoc:
+ class SyntaxNode #:nodoc:
def line
input.line_of(interval.first)
end
end
- class CompiledParser
+ class CompiledParser #:nodoc:
include Cucumber::Parser::TreetopExt
end
end
diff --git a/lib/cucumber/platform.rb b/lib/cucumber/platform.rb
index 5b22f8c52f7..712740010b2 100644
--- a/lib/cucumber/platform.rb
+++ b/lib/cucumber/platform.rb
@@ -4,7 +4,6 @@
require 'yaml'
module Cucumber
- # TODO: Move these constants and the file to Language. Update wiki
LANGUAGE_FILE = File.expand_path(File.dirname(__FILE__) + '/languages.yml')
LANGUAGES = YAML.load_file(LANGUAGE_FILE)
BINARY = File.expand_path(File.dirname(__FILE__) + '/../../bin/cucumber')
@@ -17,7 +16,7 @@ module Cucumber
RUBY_BINARY = File.join(Config::CONFIG['bindir'], Config::CONFIG['ruby_install_name'])
RUBY_1_9 = RUBY_VERSION =~ /^1\.9/
- def self.file_mode(m)
+ def self.file_mode(m) #:nodoc:
RUBY_1_9 ? "#{m}:UTF-8" : m
end
end
\ No newline at end of file
diff --git a/lib/cucumber/rails/world.rb b/lib/cucumber/rails/world.rb
index e3148f0765a..92a0d00e480 100644
--- a/lib/cucumber/rails/world.rb
+++ b/lib/cucumber/rails/world.rb
@@ -23,7 +23,8 @@
module Cucumber #:nodoc:
module Rails
- # All scenarios will execute in the context of a new instance of World.
+ # All scenarios will execute in the context of a new instance of Cucumber::Rails:World if this file
+ # is loaded. This gives Step Definitions access to all the methods from Rails' ActionController::IntegrationTest
class World < ActionController::IntegrationTest
if defined?(ActiveRecord::Base)
self.use_transactional_fixtures = false
diff --git a/lib/cucumber/rake/task.rb b/lib/cucumber/rake/task.rb
index 1b1137333bc..b98a7088d3b 100644
--- a/lib/cucumber/rake/task.rb
+++ b/lib/cucumber/rake/task.rb
@@ -8,7 +8,7 @@ module Rake
#
# Cucumber::Rake::Task.new
#
- # This will create a task named 'cucumber' described as 'Run Cucumber features'.
+ # This will define a task named cucumber described as 'Run Cucumber features'.
# It will use steps from 'features/**/*.rb' and features in 'features/**/*.feature'.
#
# To further configure the task, you can pass a block:
@@ -82,10 +82,10 @@ def initialize(libs, cucumber_bin, cucumber_opts, feature_files, rcov_opts)
end
end
- LIB = File.expand_path(File.dirname(__FILE__) + '/../..') # :nodoc:
+ LIB = File.expand_path(File.dirname(__FILE__) + '/../..') #:nodoc:
# TODO: remove depreated accessors for 0.4.0
- def self.deprecate_accessor(attribute) # :nodoc:
+ def self.deprecate_accessor(attribute) #:nodoc:
attr_reader attribute
class_eval <<-EOF, __FILE__, __LINE__ + 1
def #{attribute}=(value)
@@ -133,7 +133,9 @@ def rcov_opts=(opts) #:nodoc:
@rcov_opts = String === opts ? opts.split(' ') : opts
end
- # Whether or not to fork a new ruby interpreter. Defaults to true.
+ # Whether or not to fork a new ruby interpreter. Defaults to true. You may gain
+ # some startup speed if you set it to false, but this may also cause issues with
+ # your load path and gems.
attr_accessor :fork
# Define what profile to be used. When used with cucumber_opts it is simply appended to it. Will be ignored when CUCUMBER_OPTS is used.
@@ -165,14 +167,14 @@ def initialize(task_name = "cucumber", desc = "Run Cucumber features")
define_task
end
- def define_task # :nodoc:
+ def define_task #:nodoc:
desc @desc
task @task_name do
runner.run
end
end
- def runner(task_args = nil) # :nodoc:
+ def runner(task_args = nil) #:nodoc:
cucumber_opts = [(ENV['CUCUMBER_OPTS'] ? ENV['CUCUMBER_OPTS'].split(/\s+/) : nil) || cucumber_opts_with_profile]
if(@rcov)
RCovCucumberRunner.new(libs, binary, cucumber_opts, feature_files(task_args), rcov_opts)
@@ -183,11 +185,11 @@ def runner(task_args = nil) # :nodoc:
end
end
- def cucumber_opts_with_profile # :nodoc:
+ def cucumber_opts_with_profile #:nodoc:
@profile ? [cucumber_opts, '--profile', @profile] : cucumber_opts
end
- def feature_files(task_args = nil) # :nodoc:
+ def feature_files(task_args = nil) #:nodoc:
if ENV['FEATURE']
FileList[ ENV['FEATURE'] ]
else
@@ -199,7 +201,7 @@ def feature_files(task_args = nil) # :nodoc:
end
end
- def step_files(task_args = nil) # :nodoc:
+ def step_files(task_args = nil) #:nodoc:
if ENV['STEPS']
FileList[ ENV['STEPS'] ]
else
@@ -222,14 +224,14 @@ def initialize(task_name = "feature", desc = "Run a specified feature with Cucum
super(task_name, desc)
end
- def define_task # :nodoc:
+ def define_task #:nodoc:
desc @desc
task @task_name, :feature_name do |t, args|
runner(args).run
end
end
- def feature_files(task_arguments) # :nodoc:
+ def feature_files(task_arguments) #:nodoc:
FileList[File.join("features", "**", "#{task_arguments[:feature_name]}.feature")]
end
diff --git a/lib/cucumber/rb_support/rb_dsl.rb b/lib/cucumber/rb_support/rb_dsl.rb
index da565a51277..1f354f9d21f 100644
--- a/lib/cucumber/rb_support/rb_dsl.rb
+++ b/lib/cucumber/rb_support/rb_dsl.rb
@@ -36,31 +36,31 @@ def World(*world_modules, &proc)
RbDsl.rb_language.build_world_factory(*world_modules, &proc)
end
- # Registers a Before proc. You can call this method as many times as you
- # want (typically from ruby scripts under support).
+ # Registers a proc that will run before each Scenario. You can register as
+ # as you want (typically from ruby scripts under support/hooks.rb).
def Before(*tag_names, &proc)
RbDsl.step_mother.register_hook(:before, RbHook.new(RbDsl.rb_language, tag_names, proc))
end
+ # Registers a proc that will run after each Scenario. You can register as
+ # as you want (typically from ruby scripts under support/hooks.rb).
def After(*tag_names, &proc)
RbDsl.step_mother.register_hook(:after, RbHook.new(RbDsl.rb_language, tag_names, proc))
end
+ # Registers a proc that will run after each Step. You can register as
+ # as you want (typically from ruby scripts under support/hooks.rb).
def AfterStep(*tag_names, &proc)
RbDsl.step_mother.register_hook(:after_step, RbHook.new(RbDsl.rb_language, tag_names, proc))
end
- # Registers a new Ruby StepDefinition.
- # This method is aliased
+ # Registers a new Ruby StepDefinition. This method is aliased
# to Given, When and Then, and
# also to the i18n translations whenever a feature of a
# new language is loaded.
#
- # See Cucumber#alias_steps for details on how to
- # create your own aliases.
- #
- # The +&proc+ gets executed in the context of a world
- # object, which is defined by #World. A new world
+ # The +&proc+ gets executed in the context of a World
+ # object, which is defined by #World. A new World
# object is created for each scenario and is shared across
# step definitions within that scenario.
def register_rb_step_definition(regexp, &proc)
diff --git a/lib/cucumber/rb_support/rb_hook.rb b/lib/cucumber/rb_support/rb_hook.rb
index e504656dd81..5656101c1ad 100644
--- a/lib/cucumber/rb_support/rb_hook.rb
+++ b/lib/cucumber/rb_support/rb_hook.rb
@@ -1,5 +1,6 @@
module Cucumber
module RbSupport
+ # Wrapper for Before, After and AfterStep hooks
class RbHook
include LanguageSupport::HookMethods
diff --git a/lib/cucumber/rb_support/rb_language.rb b/lib/cucumber/rb_support/rb_language.rb
index 8cc36d0f01c..f7550880c51 100644
--- a/lib/cucumber/rb_support/rb_language.rb
+++ b/lib/cucumber/rb_support/rb_language.rb
@@ -3,12 +3,14 @@
module Cucumber
module RbSupport
+ # Raised if a World block returns Nil.
class NilWorld < StandardError
def initialize
super("World procs should never return nil")
end
end
+ # Raised if there are 2 or more World blocks.
class MultipleWorld < StandardError
def initialize(first_proc, second_proc)
message = "You can only pass a proc to #World once, but it's happening\n"
@@ -21,6 +23,7 @@ def initialize(first_proc, second_proc)
end
end
+ # The Ruby implementation of the programming language API.
class RbLanguage
include LanguageSupport::LanguageMethods
attr_reader :current_world, :step_mother
diff --git a/lib/cucumber/rb_support/rb_step_definition.rb b/lib/cucumber/rb_support/rb_step_definition.rb
index d8d9bf0fdb4..4617d86e097 100644
--- a/lib/cucumber/rb_support/rb_step_definition.rb
+++ b/lib/cucumber/rb_support/rb_step_definition.rb
@@ -3,9 +3,11 @@
require 'cucumber/core_ext/proc'
module Cucumber
- # A Step Definition holds a Regexp and a Proc, and is created
+ # A Ruby Step Definition holds a Regexp and a Proc, and is created
# by calling Given, When or Then
- # in the step_definitions ruby files - for example:
+ # in the step_definitions ruby files. See also RbDsl.
+ #
+ # Example:
#
# Given /I have (\d+) cucumbers in my belly/ do
# # some code here
diff --git a/lib/cucumber/rspec_neuter.rb b/lib/cucumber/rspec_neuter.rb
index cb497621ae1..820cf6df51d 100644
--- a/lib/cucumber/rspec_neuter.rb
+++ b/lib/cucumber/rspec_neuter.rb
@@ -1,11 +1,11 @@
require 'optparse'
-module Spec
- module Runner
+module Spec #:nodoc:
+ module Runner #:nodoc:
# Neuters RSpec's option parser.
# (RSpec's option parser tries to parse ARGV, which
# will fail when running cucumber)
- class OptionParser < ::OptionParser
+ class OptionParser < ::OptionParser #:nodoc:
NEUTERED_RSPEC = Object.new
def NEUTERED_RSPEC.method_missing(m, *args); self; end
diff --git a/lib/cucumber/step_match.rb b/lib/cucumber/step_match.rb
index 9d2077ae0a9..489db6ffcc4 100644
--- a/lib/cucumber/step_match.rb
+++ b/lib/cucumber/step_match.rb
@@ -1,5 +1,5 @@
module Cucumber
- class StepMatch
+ class StepMatch #:nodoc:
attr_reader :step_definition, :args
def initialize(step_definition, step_name, formatted_step_name, args)
@@ -33,7 +33,7 @@ def text_length
end
end
- class NoStepMatch
+ class NoStepMatch #:nodoc:
attr_reader :step_definition, :name
def initialize(step, name)
diff --git a/lib/cucumber/step_mother.rb b/lib/cucumber/step_mother.rb
index 6d2b8fbb7aa..e97e7b0e54a 100644
--- a/lib/cucumber/step_mother.rb
+++ b/lib/cucumber/step_mother.rb
@@ -7,6 +7,7 @@
require 'cucumber/language_support/step_definition_methods'
module Cucumber
+ # Raised when there is no matching StepDefinition for a step.
class Undefined < StandardError
attr_reader :step_name
@@ -28,7 +29,7 @@ def nested?
class Pending < StandardError
end
- # Raised when a step matches 2 or more StepDefinition
+ # Raised when a step matches 2 or more StepDefinitions
class Ambiguous < StandardError
def initialize(step_name, step_definitions, used_guess)
message = "Ambiguous match of \"#{step_name}\":\n\n"
@@ -49,10 +50,7 @@ def initialize(step_def_1, step_def_2)
end
end
- # This is the main interface for registering step definitions, which is done
- # from *_steps.rb files. This module is included right at the top-level
- # so #register_step_definition (and more interestingly - its aliases) are
- # available from the top-level.
+ # This is the meaty part of Cucumber that ties everything together.
class StepMother
include Constantize
@@ -68,8 +66,6 @@ def initialize
# Instances are cached, so calling with the same argument
# twice will return the same instance.
#
- # Raises an exception if the language can't be loaded.
- #
def load_programming_language(ext)
return @language_map[ext] if @language_map[ext]
programming_language_class = constantize("Cucumber::#{ext.capitalize}Support::#{ext.capitalize}Language")
@@ -99,15 +95,16 @@ def register_step_definition(step_definition)
step_definition
end
+ # Returns the options passed on the command line.
def options
@options ||= {}
end
- def step_visited(step)
+ def step_visited(step) #:nodoc:
steps << step unless steps.index(step)
end
-
- def steps(status = nil)
+
+ def steps(status = nil) #:nodoc:
@steps ||= []
if(status)
@steps.select{|step| step.status == status}
@@ -116,11 +113,11 @@ def steps(status = nil)
end
end
- def announce(msg)
+ def announce(msg) #:nodoc:
@visitor.announce(msg)
end
- def scenarios(status = nil)
+ def scenarios(status = nil) #:nodoc:
@scenarios ||= []
if(status)
@scenarios.select{|scenario| scenario.status == status}
@@ -129,20 +126,20 @@ def scenarios(status = nil)
end
end
- def register_hook(phase, hook)
+ def register_hook(phase, hook) #:nodoc:
hooks[phase.to_sym] << hook
hook
end
- def hooks
+ def hooks #:nodoc:
@hooks ||= Hash.new {|hash, phase| hash[phase] = []}
end
- def hooks_for(phase, scenario)
+ def hooks_for(phase, scenario) #:nodoc:
hooks[phase.to_sym].select{|hook| scenario.accept_hook?(hook)}
end
- def step_match(step_name, formatted_step_name=nil)
+ def step_match(step_name, formatted_step_name=nil) #:nodoc:
matches = step_definitions.map { |d| d.step_match(step_name, formatted_step_name) }.compact
raise Undefined.new(step_name) if matches.empty?
matches = best_matches(step_name, matches) if matches.size > 1 && options[:guess]
@@ -150,7 +147,7 @@ def step_match(step_name, formatted_step_name=nil)
matches[0]
end
- def best_matches(step_name, step_matches)
+ def best_matches(step_name, step_matches) #:nodoc:
no_groups = step_matches.select {|step_match| step_match.args.length == 0}
max_arg_length = step_matches.map {|step_match| step_match.args.length }.max
top_groups = step_matches.select {|step_match| step_match.args.length == max_arg_length }
@@ -166,31 +163,31 @@ def best_matches(step_name, step_matches)
end
end
- def clear!
+ def clear! #:nodoc:
step_definitions.clear
hooks.clear
steps.clear
scenarios.clear
end
- def step_definitions
+ def step_definitions #:nodoc:
@step_definitions ||= []
end
- def snippet_text(step_keyword, step_name, multiline_arg_class)
+ def snippet_text(step_keyword, step_name, multiline_arg_class) #:nodoc:
@programming_languages.map do |programming_language|
programming_language.snippet_text(step_keyword, step_name, multiline_arg_class)
end.join("\n")
end
- def before_and_after(scenario, skip_hooks=false)
+ def before_and_after(scenario, skip_hooks=false) #:nodoc:
before(scenario) unless skip_hooks
yield scenario
after(scenario) unless skip_hooks
scenario_visited(scenario)
end
- def register_adverbs(adverbs)
+ def register_adverbs(adverbs) #:nodoc:
@adverbs ||= []
@adverbs += adverbs
@adverbs.uniq!
@@ -199,21 +196,21 @@ def register_adverbs(adverbs)
end
end
- def begin_scenario
+ def begin_scenario #:nodoc:
return if options[:dry_run]
@programming_languages.each do |programming_language|
programming_language.begin_scenario
end
end
- def end_scenario
+ def end_scenario #:nodoc:
return if options[:dry_run]
@programming_languages.each do |programming_language|
programming_language.end_scenario
end
end
- def before(scenario)
+ def before(scenario) #:nodoc:
return if options[:dry_run] || @current_scenario
@current_scenario = scenario
@programming_languages.each do |programming_language|
@@ -221,7 +218,7 @@ def before(scenario)
end
end
- def after(scenario)
+ def after(scenario) #:nodoc:
@current_scenario = nil
return if options[:dry_run]
@programming_languages.each do |programming_language|
@@ -229,7 +226,7 @@ def after(scenario)
end
end
- def after_step
+ def after_step #:nodoc:
return if options[:dry_run]
@programming_languages.each do |programming_language|
programming_language.execute_after_step(@current_scenario)
@@ -238,11 +235,11 @@ def after_step
private
- def max_step_definition_length
+ def max_step_definition_length #:nodoc:
@max_step_definition_length ||= step_definitions.map{|step_definition| step_definition.text_length}.max
end
- def scenario_visited(scenario)
+ def scenario_visited(scenario) #:nodoc:
scenarios << scenario unless scenarios.index(scenario)
end
end
diff --git a/lib/cucumber/version.rb b/lib/cucumber/version.rb
index 0d32da1d5e0..3394afdc940 100644
--- a/lib/cucumber/version.rb
+++ b/lib/cucumber/version.rb
@@ -3,7 +3,7 @@ class VERSION #:nodoc:
MAJOR = 0
MINOR = 3
TINY = 96
- PATCH = nil # Set to nil for official release
+ PATCH = 1 # Set to nil for official release
STRING = [MAJOR, MINOR, TINY, PATCH].compact.join('.')
end
diff --git a/lib/cucumber/webrat/element_locator.rb b/lib/cucumber/webrat/element_locator.rb
index c3522257cad..247d6d54292 100644
--- a/lib/cucumber/webrat/element_locator.rb
+++ b/lib/cucumber/webrat/element_locator.rb
@@ -55,7 +55,7 @@ def table_from_list #:nodoc:
end
module Locators
- class ElementLocator < Locator
+ class ElementLocator < Locator #:nodoc:
def locate
Element.load(@session, table_element)
end
@@ -77,11 +77,11 @@ def element_at(css_selector)
alias table_at element_at # Backwards compatibility with Cucumber
end
- module Methods
+ module Methods #:nodoc:
delegate_to_session :element_at, :table_at
end
- class Session
+ class Session #:nodoc:
def_delegators :current_scope, :element_at, :table_at
end
end
diff --git a/lib/cucumber/world.rb b/lib/cucumber/world.rb
index 5f79db0a16b..0de6c816be8 100644
--- a/lib/cucumber/world.rb
+++ b/lib/cucumber/world.rb
@@ -1,5 +1,5 @@
module Cucumber
- # All steps are run in the context of an object that extends this module
+ # All steps are run in the context of an object that extends this module.
module World
class << self
def alias_adverb(adverb)
@@ -9,7 +9,8 @@ def alias_adverb(adverb)
attr_writer :__cucumber_step_mother
- # Call a step from within a step definition
+ # Call a step from within a step definition. This method is aliased to
+ # the same i18n as RbDsl.
def __cucumber_invoke(name, multiline_argument=nil) #:nodoc:
begin
step_match = @__cucumber_step_mother.step_match(name)
@@ -57,6 +58,7 @@ def announce(announcement)
@__cucumber_step_mother.announce(announcement)
end
+ # Mark the matched step as pending.
def pending(message = "TODO")
if block_given?
begin
@@ -82,7 +84,7 @@ def pending(message = "TODO")
# or frameworks (Rails), so to avoid long waiting times on
# such errors in World we define it to just return a simple String.
#
- def inspect
+ def inspect #:nodoc:
sprintf("#<%s:0x%x>", self.class, self.object_id)
end
end
diff --git a/spec/cucumber/ast/visitor_spec.rb b/spec/cucumber/ast/visitor_spec.rb
deleted file mode 100644
index 3bc6cef09a9..00000000000
--- a/spec/cucumber/ast/visitor_spec.rb
+++ /dev/null
@@ -1,27 +0,0 @@
-require File.dirname(__FILE__) + '/../../spec_helper'
-require 'cucumber/step_mother'
-require 'cucumber/ast'
-
-module Cucumber
- module Ast
- describe Visitor do
-
- it "should support checking scenario name matches regexps" do
- visitor = Visitor.new(mock("step mother"))
- scenario = Scenario.new(background=nil,
- comment=Comment.new(""),
- tags=Tags.new(0, []),
- line=99,
- keyword="",
- name="test name",
- steps=[])
-
- visitor.options = {:name_regexps => [/name/]}
-
- visitor.matches_scenario_names?(scenario).should be_true
- end
-
- end
- end
-end
-