aslakhellesoy-cucumber 0.1.4 → 0.1.5
Sign up to get free protection for your applications and to get access to all the features.
- metadata +14 -2
- data/History.txt +0 -4
- data/License.txt +0 -20
- data/Manifest.txt +0 -98
- data/README.txt +0 -42
- data/Rakefile +0 -4
- data/TODO.txt +0 -30
- data/bin/cucumber +0 -3
- data/config/hoe.rb +0 -69
- data/config/requirements.rb +0 -15
- data/examples/calculator/Rakefile +0 -6
- data/examples/calculator/features/addition.feature +0 -16
- data/examples/calculator/features/division.feature +0 -11
- data/examples/calculator/features/steps/calculator_steps.rb +0 -30
- data/examples/calculator/lib/calculator.rb +0 -16
- data/examples/calculator_ruby_features/Rakefile +0 -6
- data/examples/calculator_ruby_features/features/addition.rb +0 -23
- data/examples/calculator_ruby_features/features/steps/calculator_steps.rb +0 -43
- data/examples/java/README.textile +0 -22
- data/examples/java/Rakefile +0 -12
- data/examples/java/features/hello.feature +0 -11
- data/examples/java/features/steps/hello_steps.rb +0 -25
- data/examples/java/features/steps/tree_steps.rb +0 -14
- data/examples/java/features/tree.feature +0 -9
- data/examples/java/src/cucumber/demo/Hello.java +0 -15
- data/examples/norwegian_calculator/Rakefile +0 -6
- data/examples/norwegian_calculator/features/kalkulator_steps.rb +0 -31
- data/examples/norwegian_calculator/features/summering.feature +0 -13
- data/examples/watir/Rakefile +0 -6
- data/examples/watir/features/search.feature +0 -9
- data/examples/watir/features/steps/stories_steps.rb +0 -51
- data/gem_tasks/deployment.rake +0 -34
- data/gem_tasks/environment.rake +0 -7
- data/gem_tasks/fix_cr_lf.rake +0 -10
- data/gem_tasks/gemspec.rake +0 -6
- data/gem_tasks/rspec.rake +0 -21
- data/gem_tasks/treetop.rake +0 -27
- data/gem_tasks/website.rake +0 -17
- data/generators/cucumber/cucumber_generator.rb +0 -20
- data/generators/cucumber/templates/common_webrat.rb +0 -30
- data/generators/cucumber/templates/cucumber.rake +0 -7
- data/generators/cucumber/templates/env.rb +0 -6
- data/generators/feature/feature_generator.rb +0 -17
- data/generators/feature/templates/feature.erb +0 -27
- data/generators/feature/templates/steps.erb +0 -22
- data/lib/cucumber/cli.rb +0 -133
- data/lib/cucumber/core_ext/proc.rb +0 -43
- data/lib/cucumber/core_ext/string.rb +0 -17
- data/lib/cucumber/executor.rb +0 -79
- data/lib/cucumber/formatters/ansicolor.rb +0 -89
- data/lib/cucumber/formatters/html_formatter.rb +0 -272
- data/lib/cucumber/formatters/pretty_formatter.rb +0 -129
- data/lib/cucumber/formatters/progress_formatter.rb +0 -41
- data/lib/cucumber/formatters.rb +0 -1
- data/lib/cucumber/languages.yml +0 -31
- data/lib/cucumber/rails/rspec.rb +0 -12
- data/lib/cucumber/rails/world.rb +0 -71
- data/lib/cucumber/rake/task.rb +0 -75
- data/lib/cucumber/step_methods.rb +0 -41
- data/lib/cucumber/step_mother.rb +0 -38
- data/lib/cucumber/tree/feature.rb +0 -45
- data/lib/cucumber/tree/features.rb +0 -21
- data/lib/cucumber/tree/scenario.rb +0 -85
- data/lib/cucumber/tree/step.rb +0 -141
- data/lib/cucumber/tree/table.rb +0 -26
- data/lib/cucumber/tree/top_down_visitor.rb +0 -23
- data/lib/cucumber/tree.rb +0 -18
- data/lib/cucumber/treetop_parser/feature.treetop.erb +0 -102
- data/lib/cucumber/treetop_parser/feature_en.rb +0 -974
- data/lib/cucumber/treetop_parser/feature_fr.rb +0 -974
- data/lib/cucumber/treetop_parser/feature_no.rb +0 -974
- data/lib/cucumber/treetop_parser/feature_parser.rb +0 -32
- data/lib/cucumber/treetop_parser/feature_pt.rb +0 -974
- data/lib/cucumber/version.rb +0 -9
- data/lib/cucumber.rb +0 -32
- data/script/console +0 -10
- data/script/console.cmd +0 -1
- data/script/destroy +0 -14
- data/script/destroy.cmd +0 -1
- data/script/generate +0 -14
- data/script/generate.cmd +0 -1
- data/script/txt2html +0 -74
- data/script/txt2html.cmd +0 -1
- data/setup.rb +0 -1585
- data/spec/cucumber/core_ext/string_spec.rb +0 -20
- data/spec/cucumber/executor_spec.rb +0 -55
- data/spec/cucumber/formatters/ansicolor_spec.rb +0 -18
- data/spec/cucumber/formatters/features.html +0 -274
- data/spec/cucumber/formatters/html_formatter_spec.rb +0 -59
- data/spec/cucumber/sell_cucumbers.feature +0 -9
- data/spec/cucumber/treetop_parser/feature_parser_spec.rb +0 -40
- data/spec/cucumber/treetop_parser/spaces.feature +0 -10
- data/spec/spec.opts +0 -2
- data/spec/spec_helper.rb +0 -14
- data/website/index.html +0 -11
- data/website/index.txt +0 -39
- data/website/javascripts/rounded_corners_lite.inc.js +0 -285
- data/website/stylesheets/screen.css +0 -138
- data/website/template.html.erb +0 -48
data/lib/cucumber/languages.yml
DELETED
@@ -1,31 +0,0 @@
|
|
1
|
-
# http://en.wikipedia.org/wiki/IETF_language_tag
|
2
|
-
# http://www.iana.org/assignments/language-subtag-registry
|
3
|
-
# http://ftp.ics.uci.edu/pub/ietf/http/related/iso639.txt (Use this I think)
|
4
|
-
"en":
|
5
|
-
scenario: Scenario
|
6
|
-
given_scenario: GivenScenario
|
7
|
-
given: Given
|
8
|
-
when: When
|
9
|
-
then: Then
|
10
|
-
and: And
|
11
|
-
"no":
|
12
|
-
scenario: Scenario
|
13
|
-
given_scenario: GittScenario
|
14
|
-
given: Gitt
|
15
|
-
when: Når
|
16
|
-
then: Så
|
17
|
-
and: Og
|
18
|
-
"fr":
|
19
|
-
scenario: Scenario
|
20
|
-
given_scenario: SoitScenario
|
21
|
-
given: Soit
|
22
|
-
when: Lorsque
|
23
|
-
then: Alors
|
24
|
-
and: Et
|
25
|
-
"pt":
|
26
|
-
scenario: Escenario
|
27
|
-
given_scenario: DadoElEscenario
|
28
|
-
given: Dado
|
29
|
-
when: Cuando
|
30
|
-
then: Entonces
|
31
|
-
and: Y
|
data/lib/cucumber/rails/rspec.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
require 'spec'
|
2
|
-
require 'spec/rails'
|
3
|
-
|
4
|
-
# Hack to stop RSpec from dumping the summary
|
5
|
-
Spec::Runner::Options.class_eval do
|
6
|
-
def examples_should_be_run?
|
7
|
-
false
|
8
|
-
end
|
9
|
-
end
|
10
|
-
|
11
|
-
ActionController::Integration::Session.send(:include, Spec::Matchers)
|
12
|
-
ActionController::Integration::Session.send(:include, Spec::Rails::Matchers)
|
data/lib/cucumber/rails/world.rb
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
# Based on code from Brian Takita, Yurii Rashkovskii and Ben Mabey
|
2
|
-
# Adapted by Aslak Hellesøy
|
3
|
-
|
4
|
-
if defined?(ActiveRecord::Base)
|
5
|
-
require 'test_help'
|
6
|
-
else
|
7
|
-
require 'action_controller/test_process'
|
8
|
-
require 'action_controller/integration'
|
9
|
-
end
|
10
|
-
require 'test/unit/testresult'
|
11
|
-
|
12
|
-
# These allow exceptions to come through as opposed to being caught and hvaing non-helpful responses returned.
|
13
|
-
ActionController::Base.class_eval do
|
14
|
-
def perform_action
|
15
|
-
perform_action_without_rescue
|
16
|
-
end
|
17
|
-
end
|
18
|
-
Dispatcher.class_eval do
|
19
|
-
def self.failsafe_response(output, status, exception = nil)
|
20
|
-
raise exception
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
# So that Test::Unit doesn't launch at the end - makes it think it has already been run.
|
25
|
-
Test::Unit.run = true
|
26
|
-
|
27
|
-
module Cucumber #:nodoc:
|
28
|
-
module Rails
|
29
|
-
# All scenarios will execute in the context of a new instance of World.
|
30
|
-
class World < ActionController::IntegrationTest
|
31
|
-
if defined?(ActiveRecord::Base)
|
32
|
-
self.use_transactional_fixtures = true
|
33
|
-
else
|
34
|
-
def self.fixture_table_names; []; end # Workaround for projects that don't use ActiveRecord
|
35
|
-
end
|
36
|
-
|
37
|
-
def initialize #:nodoc:
|
38
|
-
@_result = Test::Unit::TestResult.new
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
World do
|
45
|
-
Cucumber::Rails::World.new
|
46
|
-
end
|
47
|
-
|
48
|
-
if defined?(ActiveRecord::Base)
|
49
|
-
Before do
|
50
|
-
if defined?(ActiveRecord::Base)
|
51
|
-
if ActiveRecord::Base.connection.respond_to?(:increment_open_transactions)
|
52
|
-
ActiveRecord::Base.connection.increment_open_transactions
|
53
|
-
else
|
54
|
-
ActiveRecord::Base.send :increment_open_transactions
|
55
|
-
end
|
56
|
-
end
|
57
|
-
ActiveRecord::Base.connection.begin_db_transaction
|
58
|
-
ActionMailer::Base.deliveries = [] if defined?(ActionMailer::Base)
|
59
|
-
end
|
60
|
-
|
61
|
-
After do
|
62
|
-
if defined?(ActiveRecord::Base)
|
63
|
-
ActiveRecord::Base.connection.rollback_db_transaction
|
64
|
-
if ActiveRecord::Base.connection.respond_to?(:decrement_open_transactions)
|
65
|
-
ActiveRecord::Base.connection.decrement_open_transactions
|
66
|
-
else
|
67
|
-
ActiveRecord::Base.send :decrement_open_transactions
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
end
|
data/lib/cucumber/rake/task.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Rake
|
3
|
-
# Defines a task for running features.
|
4
|
-
class Task
|
5
|
-
LIB = File.expand_path(File.dirname(__FILE__) + '/../..')
|
6
|
-
BINARY = File.expand_path(File.dirname(__FILE__) + '/../../../bin/cucumber')
|
7
|
-
|
8
|
-
attr_accessor :libs
|
9
|
-
attr_accessor :step_list
|
10
|
-
attr_accessor :step_pattern
|
11
|
-
attr_accessor :feature_list
|
12
|
-
attr_accessor :feature_pattern
|
13
|
-
attr_accessor :cucumber_opts
|
14
|
-
attr_accessor :rcov
|
15
|
-
attr_accessor :rcov_opts
|
16
|
-
|
17
|
-
# Define a task
|
18
|
-
def initialize(task_name = "features", desc = "Run Features")
|
19
|
-
@task_name, @desc = task_name, desc
|
20
|
-
@libs = []
|
21
|
-
@rcov_opts = %w{--rails --exclude osx\/objc,gems\/}
|
22
|
-
|
23
|
-
yield self if block_given?
|
24
|
-
|
25
|
-
@feature_pattern = "features/**/*.feature" if feature_pattern.nil? && feature_list.nil?
|
26
|
-
@step_pattern = "features/**/*.rb" if step_pattern.nil? && step_list.nil?
|
27
|
-
define_tasks
|
28
|
-
end
|
29
|
-
|
30
|
-
def define_tasks
|
31
|
-
desc @desc
|
32
|
-
task @task_name do
|
33
|
-
lib_args = ['"%s"' % ([LIB] + libs).join(File::PATH_SEPARATOR)]
|
34
|
-
cucumber_bin = ['"%s"' % BINARY]
|
35
|
-
cuc_opts = [(ENV['CUCUMBER_OPTS'] || cucumber_opts)]
|
36
|
-
|
37
|
-
step_files.each do |step_file|
|
38
|
-
cuc_opts << '--require'
|
39
|
-
cuc_opts << step_file
|
40
|
-
end
|
41
|
-
|
42
|
-
if rcov
|
43
|
-
args = (['-I'] + lib_args + ['-S', 'rcov'] + rcov_opts + cucumber_bin + ['--'] + cuc_opts + feature_files).flatten
|
44
|
-
else
|
45
|
-
args = (['-I'] + lib_args + cucumber_bin + cuc_opts + feature_files).flatten
|
46
|
-
end
|
47
|
-
ruby(args.join(" ")) # ruby(*args) is broken on Windows
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
|
52
|
-
def feature_files # :nodoc:
|
53
|
-
if ENV['FEATURE']
|
54
|
-
FileList[ ENV['FEATURE'] ]
|
55
|
-
else
|
56
|
-
result = []
|
57
|
-
result += feature_list.to_a if feature_list
|
58
|
-
result += FileList[feature_pattern].to_a if feature_pattern
|
59
|
-
FileList[result]
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def step_files # :nodoc:
|
64
|
-
if ENV['STEPS']
|
65
|
-
FileList[ ENV['STEPS'] ]
|
66
|
-
else
|
67
|
-
result = []
|
68
|
-
result += step_list.to_a if step_list
|
69
|
-
result += FileList[step_pattern].to_a if step_pattern
|
70
|
-
FileList[result]
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'cucumber/step_mother'
|
2
|
-
|
3
|
-
module Cucumber
|
4
|
-
# Defines "global" methods that may be used in *_steps.rb files.
|
5
|
-
module StepMethods
|
6
|
-
# Each scenario will execute in the context of what the supplied block returns.
|
7
|
-
def World(&proc)
|
8
|
-
$executor.register_world_proc(&proc)
|
9
|
-
end
|
10
|
-
|
11
|
-
def Before(&proc)
|
12
|
-
$executor.register_before_proc(&proc)
|
13
|
-
end
|
14
|
-
|
15
|
-
def After(&proc)
|
16
|
-
$executor.register_after_proc(&proc)
|
17
|
-
end
|
18
|
-
|
19
|
-
def Given(key, &proc)
|
20
|
-
step_mother.register_step_proc(key, &proc)
|
21
|
-
end
|
22
|
-
|
23
|
-
def When(key, &proc)
|
24
|
-
step_mother.register_step_proc(key, &proc)
|
25
|
-
end
|
26
|
-
|
27
|
-
def Then(key, &proc)
|
28
|
-
step_mother.register_step_proc(key, &proc)
|
29
|
-
end
|
30
|
-
|
31
|
-
# Simple workaround for old skool steps
|
32
|
-
def steps_for(*_)
|
33
|
-
STDERR.puts "WARNING: In Cucumber the steps_for method is obsolete"
|
34
|
-
yield
|
35
|
-
end
|
36
|
-
|
37
|
-
def step_mother #:nodoc:
|
38
|
-
@step_mother ||= StepMother.new
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
data/lib/cucumber/step_mother.rb
DELETED
@@ -1,38 +0,0 @@
|
|
1
|
-
require 'cucumber/tree/top_down_visitor'
|
2
|
-
require 'cucumber/core_ext/proc'
|
3
|
-
|
4
|
-
module Cucumber
|
5
|
-
# A StepMother keeps track of step procs and assigns them
|
6
|
-
# to each step when visiting the tree.
|
7
|
-
class StepMother < Tree::TopDownVisitor
|
8
|
-
def initialize
|
9
|
-
@step_procs = {}
|
10
|
-
end
|
11
|
-
|
12
|
-
def register_step_proc(key, &proc)
|
13
|
-
regexp = case(key)
|
14
|
-
when String
|
15
|
-
Regexp.new("^#{key}$") # TODO: replace $variable with (.*)
|
16
|
-
when Regexp
|
17
|
-
key
|
18
|
-
else
|
19
|
-
raise "Step patterns must be Regexp or String, but was: #{key.inspect}"
|
20
|
-
end
|
21
|
-
proc.extend(CoreExt::CallIn)
|
22
|
-
proc.name = key.inspect
|
23
|
-
@step_procs[regexp] = proc
|
24
|
-
end
|
25
|
-
|
26
|
-
def visit_step(step)
|
27
|
-
# Maybe we shouldn't attach the regexp etc to
|
28
|
-
# the step? Maybe steps pull them out as needed?
|
29
|
-
# Do we then have to attach ourself to the step instead?
|
30
|
-
# What would we gain from a pull design?
|
31
|
-
@step_procs.each do |regexp, proc|
|
32
|
-
if step.respond_to?(:name) && step.name =~ regexp
|
33
|
-
step.attach(regexp, proc, $~.captures)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
@@ -1,45 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Tree
|
3
|
-
class Feature
|
4
|
-
attr_accessor :file
|
5
|
-
|
6
|
-
def initialize(header, &proc)
|
7
|
-
@header = header
|
8
|
-
@scenarios = []
|
9
|
-
instance_eval(&proc) if block_given?
|
10
|
-
end
|
11
|
-
|
12
|
-
def add_scenario(name, &proc)
|
13
|
-
scenario = Scenario.new(self, name, &proc)
|
14
|
-
@scenarios << scenario
|
15
|
-
scenario
|
16
|
-
end
|
17
|
-
|
18
|
-
def add_row_scenario(template_scenario, values, line)
|
19
|
-
scenario = RowScenario.new(self, template_scenario, values, line)
|
20
|
-
@scenarios << scenario
|
21
|
-
scenario
|
22
|
-
end
|
23
|
-
|
24
|
-
def Scenario(name, &proc)
|
25
|
-
add_scenario(name, &proc)
|
26
|
-
end
|
27
|
-
|
28
|
-
def Table(matrix = [], &proc)
|
29
|
-
table = Table.new(matrix)
|
30
|
-
proc.call(table)
|
31
|
-
template_scenario = @scenarios.last
|
32
|
-
matrix[1..-1].each do |row|
|
33
|
-
@scenarios << RowScenario.new(self, template_scenario, row, row.line)
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def accept(visitor)
|
38
|
-
visitor.visit_header(@header)
|
39
|
-
@scenarios.each do |scenario|
|
40
|
-
visitor.visit_scenario(scenario)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Tree
|
3
|
-
class Features
|
4
|
-
def initialize
|
5
|
-
@features = []
|
6
|
-
end
|
7
|
-
|
8
|
-
def length
|
9
|
-
@features.length
|
10
|
-
end
|
11
|
-
|
12
|
-
def <<(feature)
|
13
|
-
@features << feature
|
14
|
-
end
|
15
|
-
|
16
|
-
def accept(visitor)
|
17
|
-
@features.each{|feature| visitor.visit_feature(feature)}
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,85 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Tree
|
3
|
-
class BaseScenario
|
4
|
-
def file
|
5
|
-
@feature.file
|
6
|
-
end
|
7
|
-
|
8
|
-
def accept(visitor)
|
9
|
-
steps.each do |step|
|
10
|
-
visitor.visit_step(step)
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
def at_line?(l)
|
15
|
-
line == l || steps.map{|s| s.line}.index(l)
|
16
|
-
end
|
17
|
-
|
18
|
-
def previous_step(step)
|
19
|
-
i = steps.index(step)
|
20
|
-
raise "Couldn't find #{step} among #{steps}" if i.nil?
|
21
|
-
steps[i-1]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
class Scenario < BaseScenario
|
26
|
-
|
27
|
-
# If a table follows, the header will be stored here. Weird, but convenient.
|
28
|
-
attr_accessor :table_header
|
29
|
-
|
30
|
-
def initialize(feature, name, &proc)
|
31
|
-
@feature, @name = feature, name
|
32
|
-
@steps = []
|
33
|
-
instance_eval(&proc) if block_given?
|
34
|
-
end
|
35
|
-
|
36
|
-
def row?
|
37
|
-
false
|
38
|
-
end
|
39
|
-
|
40
|
-
def add_step(keyword, name, line)
|
41
|
-
@steps << Step.new(self, keyword, name, line)
|
42
|
-
end
|
43
|
-
|
44
|
-
def Given(name)
|
45
|
-
add_step('Given', name, *caller[0].split(':')[1].to_i)
|
46
|
-
end
|
47
|
-
|
48
|
-
def When(name)
|
49
|
-
add_step('When', name, *caller[0].split(':')[1].to_i)
|
50
|
-
end
|
51
|
-
|
52
|
-
def Then(name)
|
53
|
-
add_step('Then', name, *caller[0].split(':')[1].to_i)
|
54
|
-
end
|
55
|
-
|
56
|
-
def And(name)
|
57
|
-
add_step('And', name, *caller[0].split(':')[1].to_i)
|
58
|
-
end
|
59
|
-
|
60
|
-
attr_reader :name, :steps, :line
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
class RowScenario < BaseScenario
|
65
|
-
attr_reader :line
|
66
|
-
|
67
|
-
def initialize(feature, template_scenario, values, line)
|
68
|
-
@feature, @template_scenario, @values, @line = feature, template_scenario, values, line
|
69
|
-
end
|
70
|
-
|
71
|
-
def row?
|
72
|
-
true
|
73
|
-
end
|
74
|
-
|
75
|
-
def steps
|
76
|
-
@steps ||= @template_scenario.steps.map do |template_step|
|
77
|
-
args = template_step.args.map do
|
78
|
-
@values.shift
|
79
|
-
end
|
80
|
-
RowStep.new(self, template_step.keyword, template_step.proc, args)
|
81
|
-
end
|
82
|
-
end
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
data/lib/cucumber/tree/step.rb
DELETED
@@ -1,141 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Tree
|
3
|
-
class BaseStep
|
4
|
-
def self.new_id!
|
5
|
-
@next_id ||= -1
|
6
|
-
@next_id += 1
|
7
|
-
end
|
8
|
-
|
9
|
-
attr_reader :error
|
10
|
-
attr_accessor :args
|
11
|
-
|
12
|
-
def file
|
13
|
-
@scenario.file
|
14
|
-
end
|
15
|
-
|
16
|
-
def regexp
|
17
|
-
@regexp || //
|
18
|
-
end
|
19
|
-
|
20
|
-
PENDING = lambda do |*_|
|
21
|
-
raise Pending
|
22
|
-
end
|
23
|
-
PENDING.extend(CoreExt::CallIn)
|
24
|
-
PENDING.name = "PENDING"
|
25
|
-
|
26
|
-
def proc
|
27
|
-
@proc || PENDING
|
28
|
-
end
|
29
|
-
|
30
|
-
def attach(regexp, proc, args)
|
31
|
-
if @regexp
|
32
|
-
raise <<-EOM
|
33
|
-
"#{name}" matches several step definitions:
|
34
|
-
|
35
|
-
#{@proc.backtrace_line}
|
36
|
-
#{proc.backtrace_line}
|
37
|
-
|
38
|
-
Please give your steps unambiguous names
|
39
|
-
EOM
|
40
|
-
end
|
41
|
-
@regexp, @proc, @args = regexp, proc, args
|
42
|
-
end
|
43
|
-
|
44
|
-
if defined?(JRUBY_VERSION)
|
45
|
-
PENDING_ADJUSTMENT = 2
|
46
|
-
REGULAR_ADJUSTMENT = 1
|
47
|
-
else
|
48
|
-
PENDING_ADJUSTMENT = 3
|
49
|
-
REGULAR_ADJUSTMENT = 2
|
50
|
-
end
|
51
|
-
|
52
|
-
def execute_in(world)
|
53
|
-
strip_pos = nil
|
54
|
-
begin
|
55
|
-
proc.call_in(world, *@args)
|
56
|
-
rescue ArgCountError => e
|
57
|
-
e.backtrace[0] = @proc.backtrace_line
|
58
|
-
strip_pos = e.backtrace.index("#{__FILE__}:#{__LINE__ - 3}:in `execute_in'")
|
59
|
-
format_error(strip_pos, e)
|
60
|
-
rescue => e
|
61
|
-
method_line = "#{__FILE__}:#{__LINE__ - 6}:in `execute_in'"
|
62
|
-
method_line_pos = e.backtrace.index(method_line)
|
63
|
-
if method_line_pos
|
64
|
-
strip_pos = method_line_pos - (Pending === e ? PENDING_ADJUSTMENT : REGULAR_ADJUSTMENT)
|
65
|
-
else
|
66
|
-
# This happens with rails, because they screw up the backtrace
|
67
|
-
# before we get here (injecting erb stactrace and such)
|
68
|
-
end
|
69
|
-
format_error(strip_pos, e)
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
def format_error(strip_pos, e)
|
74
|
-
@error = e
|
75
|
-
# Remove lines underneath the plain text step
|
76
|
-
e.backtrace[strip_pos..-1] = nil unless strip_pos.nil?
|
77
|
-
e.backtrace.flatten
|
78
|
-
# Replace the step line with something more readable
|
79
|
-
e.backtrace.replace(e.backtrace.map{|l| l.gsub(/`#{proc.meth}'/, "`#{keyword} #{proc.name}'")})
|
80
|
-
if row?
|
81
|
-
e.backtrace << "#{file}:#{line}:in `#{proc.name}'"
|
82
|
-
else
|
83
|
-
e.backtrace << "#{file}:#{line}:in `#{keyword} #{name}'"
|
84
|
-
end
|
85
|
-
raise e
|
86
|
-
end
|
87
|
-
|
88
|
-
def id
|
89
|
-
@id ||= self.class.new_id!
|
90
|
-
end
|
91
|
-
|
92
|
-
def actual_keyword
|
93
|
-
keyword == Cucumber.language['and'] ? previous_step.actual_keyword : keyword
|
94
|
-
end
|
95
|
-
|
96
|
-
def previous_step
|
97
|
-
@scenario.previous_step(self)
|
98
|
-
end
|
99
|
-
end
|
100
|
-
|
101
|
-
class Step < BaseStep
|
102
|
-
attr_accessor :error
|
103
|
-
|
104
|
-
def row?
|
105
|
-
false
|
106
|
-
end
|
107
|
-
|
108
|
-
def initialize(scenario, keyword, name, line)
|
109
|
-
@scenario, @keyword, @name, @line = scenario, keyword, name, line
|
110
|
-
@args = []
|
111
|
-
end
|
112
|
-
|
113
|
-
def gzub(format=nil, &proc)
|
114
|
-
name.gzub(regexp, format, &proc)
|
115
|
-
end
|
116
|
-
|
117
|
-
attr_reader :keyword, :name, :line
|
118
|
-
end
|
119
|
-
|
120
|
-
class RowStep < BaseStep
|
121
|
-
attr_reader :keyword
|
122
|
-
|
123
|
-
def initialize(scenario, keyword, proc, args)
|
124
|
-
@scenario, @keyword, @proc, @args = scenario, keyword, proc, args
|
125
|
-
end
|
126
|
-
|
127
|
-
def gzub(format=nil, &proc)
|
128
|
-
raise "WWW"
|
129
|
-
end
|
130
|
-
|
131
|
-
def row?
|
132
|
-
true
|
133
|
-
end
|
134
|
-
|
135
|
-
def line
|
136
|
-
@scenario.line
|
137
|
-
end
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
end
|
data/lib/cucumber/tree/table.rb
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Tree
|
3
|
-
class Table
|
4
|
-
def initialize(rows)
|
5
|
-
@rows = rows
|
6
|
-
end
|
7
|
-
|
8
|
-
def |(cell)
|
9
|
-
@row ||= []
|
10
|
-
if cell == self
|
11
|
-
l = *caller[0].split(':')[1].to_i
|
12
|
-
@row.instance_eval %{
|
13
|
-
def line
|
14
|
-
#{l}
|
15
|
-
end
|
16
|
-
}
|
17
|
-
@rows << @row
|
18
|
-
@row = nil
|
19
|
-
else
|
20
|
-
@row << cell.to_s
|
21
|
-
end
|
22
|
-
self
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
module Cucumber
|
2
|
-
module Tree
|
3
|
-
class TopDownVisitor
|
4
|
-
def visit_features(features)
|
5
|
-
features.accept(self)
|
6
|
-
end
|
7
|
-
|
8
|
-
def visit_feature(feature)
|
9
|
-
feature.accept(self)
|
10
|
-
end
|
11
|
-
|
12
|
-
def visit_header(header)
|
13
|
-
end
|
14
|
-
|
15
|
-
def visit_scenario(scenario)
|
16
|
-
scenario.accept(self)
|
17
|
-
end
|
18
|
-
|
19
|
-
def visit_step(step)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
data/lib/cucumber/tree.rb
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
%w{features feature scenario step table top_down_visitor}.each{|f| require "cucumber/tree/#{f}"}
|
2
|
-
require 'cucumber/core_ext/proc'
|
3
|
-
require 'cucumber/core_ext/string'
|
4
|
-
|
5
|
-
module Cucumber
|
6
|
-
module Tree
|
7
|
-
def Feature(header, &proc)
|
8
|
-
feature = Feature.new("Feature: " + header, &proc)
|
9
|
-
feature.file, _, _ = *caller[0].split(':')
|
10
|
-
features << feature
|
11
|
-
feature
|
12
|
-
end
|
13
|
-
|
14
|
-
def features #:nodoc:
|
15
|
-
@features ||= Tree::Features.new
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|