cucumber 0.3.95 → 0.3.96
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +21 -0
- data/Manifest.txt +9 -3
- data/examples/sinatra/features/support/env.rb +1 -3
- data/features/cucumber_cli.feature +1 -0
- data/features/drb_server_integration.feature +56 -3
- data/features/junit_formatter.feature +23 -12
- data/features/step_definitions/cucumber_steps.rb +13 -2
- data/features/support/env.rb +19 -3
- data/lib/cucumber/ast/feature_element.rb +1 -1
- data/lib/cucumber/ast/step.rb +1 -1
- data/lib/cucumber/ast/step_invocation.rb +3 -2
- data/lib/cucumber/cli/configuration.rb +9 -25
- data/lib/cucumber/cli/drb_client.rb +7 -3
- data/lib/cucumber/cli/language_help_formatter.rb +4 -4
- data/lib/cucumber/cli/main.rb +26 -46
- data/lib/cucumber/cli/options.rb +3 -0
- data/lib/cucumber/constantize.rb +28 -0
- data/lib/cucumber/feature_file.rb +3 -3
- data/lib/cucumber/formatter/junit.rb +13 -9
- data/lib/cucumber/formatter/pretty.rb +2 -2
- data/lib/cucumber/language_support/hook_methods.rb +9 -0
- data/lib/cucumber/language_support/language_methods.rb +47 -0
- data/lib/cucumber/language_support/step_definition_methods.rb +44 -0
- data/lib/cucumber/parser/natural_language.rb +72 -0
- data/lib/cucumber/rb_support/rb_dsl.rb +73 -0
- data/lib/cucumber/rb_support/rb_hook.rb +19 -0
- data/lib/cucumber/rb_support/rb_language.rb +129 -0
- data/lib/cucumber/rb_support/rb_step_definition.rb +56 -0
- data/lib/cucumber/step_match.rb +2 -2
- data/lib/cucumber/step_mother.rb +87 -206
- data/lib/cucumber/version.rb +1 -1
- data/lib/cucumber/webrat/element_locator.rb +7 -7
- data/lib/cucumber/world.rb +28 -8
- data/rails_generators/cucumber/templates/cucumber_environment.rb +2 -2
- data/rails_generators/cucumber/templates/spork_env.rb +0 -2
- data/rails_generators/cucumber/templates/webrat_steps.rb +17 -0
- data/spec/cucumber/ast/background_spec.rb +8 -5
- data/spec/cucumber/ast/feature_factory.rb +4 -5
- data/spec/cucumber/ast/feature_spec.rb +7 -1
- data/spec/cucumber/ast/scenario_outline_spec.rb +10 -6
- data/spec/cucumber/ast/scenario_spec.rb +8 -3
- data/spec/cucumber/ast/step_collection_spec.rb +2 -2
- data/spec/cucumber/cli/configuration_spec.rb +15 -0
- data/spec/cucumber/cli/drb_client_spec.rb +35 -1
- data/spec/cucumber/cli/main_spec.rb +5 -4
- data/spec/cucumber/cli/options_spec.rb +6 -0
- data/spec/cucumber/parser/feature_parser_spec.rb +6 -5
- data/spec/cucumber/parser/table_parser_spec.rb +1 -1
- data/spec/cucumber/step_definition_spec.rb +26 -25
- data/spec/cucumber/step_mother_spec.rb +46 -41
- data/spec/cucumber/world/pending_spec.rb +4 -5
- metadata +11 -5
- data/lib/cucumber/cli/rb_step_def_loader.rb +0 -14
- data/lib/cucumber/parser/i18n/language.rb +0 -87
- data/lib/cucumber/step_definition.rb +0 -122
data/History.txt
CHANGED
@@ -1,3 +1,22 @@
|
|
1
|
+
== 0.3.96 2009-08-15
|
2
|
+
|
3
|
+
This release doesn't have any directly visible new features or bug fixes. But there are big
|
4
|
+
internal changes. This release has a new API for plugging in other programming languages.
|
5
|
+
You can read more about that here: http://groups.google.com/group/cukes/browse_thread/thread/b9db8bf1f3ec9708
|
6
|
+
|
7
|
+
This might break other tools that are using Cucumber's internal APIs. For example Spork broke and had to
|
8
|
+
be patched. Please upgrade to Spork 0.5.9 if you are using Spork.
|
9
|
+
|
10
|
+
=== New Features
|
11
|
+
* Ability to preload natural language in Spork's prefork. Rerun script/generate cucumber --spork to see how. (Aslak Hellesøy)
|
12
|
+
* Ability to control which DRb port is used via the --port flag or by setting CUCUMBER_DRB environment variable. (Chris Flipse)
|
13
|
+
* Upgrade Rails generator to use webrat 0.5.0. (Aslak Hellesøy)
|
14
|
+
* Upgrade Sinatra example to work with rack-test 0.4.1 and webrat 0.5.0. (Aslak Hellesøy)
|
15
|
+
|
16
|
+
=== Changed Features
|
17
|
+
* --strict will cause an exit code 1 for missing and pending (used to be for missing only). (Mads Buus)
|
18
|
+
* junit formatter doesn't report pending steps unless --strict is used. (Mads Buus)
|
19
|
+
|
1
20
|
== 0.3.95 2009-08-13
|
2
21
|
|
3
22
|
This release improves Webrat support for table-like HTML markup. Now you can easily turn the HTML
|
@@ -15,6 +34,8 @@ This release also fixes several bugs related to --drb (Spork) and profiles (cucu
|
|
15
34
|
* Resolved infinite loop problem when --drb was defined in a profile. (#408 Ben Mabey)
|
16
35
|
|
17
36
|
=== New Features
|
37
|
+
* Cucumber::World#table has been overloaded to work with 2D Array in addition to a table String to be parsed.
|
38
|
+
* New When /^I fill in the following:$/ step definition for Webrat. Useful for filling out a form with a Table. (Aslak Hellesøy)
|
18
39
|
* The object returned by element_at (Webrat::Element) has a #to_table that works for table, dl, ol and ul. (Aslak Hellesøy)
|
19
40
|
* An explanation of why failures are ok is printed when --wip is used. (Aslak Hellesøy)
|
20
41
|
* Added cucumber alias for cucumber:ok in Rails Rake tasks. (Aslak Hellesøy)
|
data/Manifest.txt
CHANGED
@@ -321,7 +321,7 @@ lib/cucumber/cli/language_help_formatter.rb
|
|
321
321
|
lib/cucumber/cli/main.rb
|
322
322
|
lib/cucumber/cli/options.rb
|
323
323
|
lib/cucumber/cli/profile_loader.rb
|
324
|
-
lib/cucumber/
|
324
|
+
lib/cucumber/constantize.rb
|
325
325
|
lib/cucumber/core_ext/exception.rb
|
326
326
|
lib/cucumber/core_ext/instance_exec.rb
|
327
327
|
lib/cucumber/core_ext/proc.rb
|
@@ -346,12 +346,15 @@ lib/cucumber/formatter/tag_cloud.rb
|
|
346
346
|
lib/cucumber/formatter/unicode.rb
|
347
347
|
lib/cucumber/formatter/usage.rb
|
348
348
|
lib/cucumber/formatters/unicode.rb
|
349
|
+
lib/cucumber/language_support/hook_methods.rb
|
350
|
+
lib/cucumber/language_support/language_methods.rb
|
351
|
+
lib/cucumber/language_support/step_definition_methods.rb
|
349
352
|
lib/cucumber/languages.yml
|
350
353
|
lib/cucumber/parser.rb
|
351
354
|
lib/cucumber/parser/feature.rb
|
352
355
|
lib/cucumber/parser/feature.tt
|
353
356
|
lib/cucumber/parser/i18n.tt
|
354
|
-
lib/cucumber/parser/
|
357
|
+
lib/cucumber/parser/natural_language.rb
|
355
358
|
lib/cucumber/parser/table.rb
|
356
359
|
lib/cucumber/parser/table.tt
|
357
360
|
lib/cucumber/parser/treetop_ext.rb
|
@@ -359,8 +362,11 @@ lib/cucumber/platform.rb
|
|
359
362
|
lib/cucumber/rails/rspec.rb
|
360
363
|
lib/cucumber/rails/world.rb
|
361
364
|
lib/cucumber/rake/task.rb
|
365
|
+
lib/cucumber/rb_support/rb_dsl.rb
|
366
|
+
lib/cucumber/rb_support/rb_hook.rb
|
367
|
+
lib/cucumber/rb_support/rb_language.rb
|
368
|
+
lib/cucumber/rb_support/rb_step_definition.rb
|
362
369
|
lib/cucumber/rspec_neuter.rb
|
363
|
-
lib/cucumber/step_definition.rb
|
364
370
|
lib/cucumber/step_match.rb
|
365
371
|
lib/cucumber/step_mother.rb
|
366
372
|
lib/cucumber/version.rb
|
@@ -1,11 +1,9 @@
|
|
1
1
|
# See http://wiki.github.com/aslakhellesoy/cucumber/sinatra
|
2
2
|
# for more details about Sinatra with Cucumber
|
3
3
|
|
4
|
-
gem 'rack-test', '=0.
|
5
|
-
gem 'aslakhellesoy-webrat', '=0.4.4.1'
|
4
|
+
gem 'rack-test', '=0.4.1'
|
6
5
|
gem 'sinatra', '=0.9.4'
|
7
6
|
|
8
|
-
# Sinatra
|
9
7
|
app_file = File.join(File.dirname(__FILE__), *%w[.. .. app.rb])
|
10
8
|
require app_file
|
11
9
|
# Force the application name because polyglot breaks the auto-detection logic.
|
@@ -23,21 +23,33 @@ Feature: DRb Server Integration
|
|
23
23
|
"""
|
24
24
|
And a file named "features/sample.feature" with:
|
25
25
|
"""
|
26
|
+
# language: en
|
26
27
|
Feature: Sample
|
27
28
|
Scenario: this is a test
|
28
29
|
Given I am just testing stuff
|
29
30
|
"""
|
31
|
+
And a file named "features/essai.feature" with:
|
32
|
+
"""
|
33
|
+
# language: fr
|
34
|
+
Fonction: Essai
|
35
|
+
Scenario: ceci est un test
|
36
|
+
Soit je teste
|
37
|
+
"""
|
30
38
|
And a file named "features/step_definitions/all_your_steps_are_belong_to_us.rb" with:
|
31
39
|
"""
|
32
40
|
Given /^I am just testing stuff$/ do
|
33
41
|
# no-op
|
34
42
|
end
|
43
|
+
|
44
|
+
Soit /^je teste$/ do
|
45
|
+
# no-op
|
46
|
+
end
|
35
47
|
"""
|
36
48
|
|
37
49
|
Scenario: Feature Passing with --drb flag
|
38
50
|
Given I am running spork in the background
|
39
51
|
|
40
|
-
When I run cucumber features
|
52
|
+
When I run cucumber features --drb
|
41
53
|
Then it should pass
|
42
54
|
And STDERR should be empty
|
43
55
|
And the output should contain
|
@@ -62,7 +74,7 @@ Feature: DRb Server Integration
|
|
62
74
|
"""
|
63
75
|
And I am running spork in the background
|
64
76
|
|
65
|
-
When I run cucumber features
|
77
|
+
When I run cucumber features --drb
|
66
78
|
Then it should fail
|
67
79
|
And the output should contain
|
68
80
|
"""
|
@@ -82,7 +94,7 @@ Feature: DRb Server Integration
|
|
82
94
|
|
83
95
|
Given I am not running a DRb server in the background
|
84
96
|
|
85
|
-
When I run cucumber features
|
97
|
+
When I run cucumber features --drb
|
86
98
|
Then it should pass
|
87
99
|
And STDERR should match
|
88
100
|
"""
|
@@ -118,3 +130,44 @@ Feature: DRb Server Integration
|
|
118
130
|
I'm loading all the heavy stuff...
|
119
131
|
I'm loading the stuff just for this run...
|
120
132
|
"""
|
133
|
+
|
134
|
+
Scenario: Feature Run with --drb specifying a non-standard port
|
135
|
+
|
136
|
+
Given I am running spork in the background on port 9000
|
137
|
+
|
138
|
+
When I run cucumber features --drb --port 9000
|
139
|
+
Then it should pass
|
140
|
+
And STDERR should be empty
|
141
|
+
And the output should contain
|
142
|
+
"""
|
143
|
+
1 step (1 passed)
|
144
|
+
"""
|
145
|
+
And the output should contain
|
146
|
+
"""
|
147
|
+
I'm loading the stuff just for this run...
|
148
|
+
"""
|
149
|
+
And the output should not contain
|
150
|
+
"""
|
151
|
+
I'm loading all the heavy stuff...
|
152
|
+
"""
|
153
|
+
|
154
|
+
Scenario: Feature Run with $CUCUMBER_DRB environment variable
|
155
|
+
|
156
|
+
Given I have environment variable CUCUMBER_DRB set to "9000"
|
157
|
+
And I am running spork in the background on port 9000
|
158
|
+
|
159
|
+
When I run cucumber features/ --drb
|
160
|
+
Then it should pass
|
161
|
+
And STDERR should be empty
|
162
|
+
And the output should contain
|
163
|
+
"""
|
164
|
+
1 step (1 passed)
|
165
|
+
"""
|
166
|
+
And the output should contain
|
167
|
+
"""
|
168
|
+
I'm loading the stuff just for this run...
|
169
|
+
"""
|
170
|
+
And the output should not contain
|
171
|
+
"""
|
172
|
+
I'm loading all the heavy stuff...
|
173
|
+
"""
|
@@ -27,15 +27,13 @@ Feature: JUnit output formatter
|
|
27
27
|
|
28
28
|
Message:
|
29
29
|
(RuntimeError)
|
30
|
-
./features/step_definitions/steps.rb:6:in `/a failing scenario/'
|
31
30
|
features/one_passing_one_failing.feature:7:in `Given a failing scenario' </failure>
|
32
31
|
</testcase>
|
33
32
|
</testsuite>
|
34
33
|
|
35
34
|
"""
|
36
35
|
|
37
|
-
|
38
|
-
Scenario: pending step
|
36
|
+
Scenario: pending steps are simply skipped
|
39
37
|
When I run cucumber --format junit --out tmp/ features/pending.feature
|
40
38
|
Then it should pass with
|
41
39
|
"""
|
@@ -44,17 +42,30 @@ Feature: JUnit output formatter
|
|
44
42
|
And "examples/junit/tmp/TEST-pending.xml" with junit duration "0.009" should contain
|
45
43
|
"""
|
46
44
|
<?xml version="1.0" encoding="UTF-8"?>
|
47
|
-
<testsuite errors="0" failures="
|
48
|
-
|
45
|
+
<testsuite errors="0" failures="0" name="Pending step" tests="0" time="0.009">
|
46
|
+
</testsuite>
|
47
|
+
|
48
|
+
"""
|
49
|
+
|
50
|
+
Scenario: pending step with strict option should fail
|
51
|
+
When I run cucumber --format junit --out tmp/ features/pending.feature --strict
|
52
|
+
Then it should fail with
|
53
|
+
"""
|
54
|
+
|
55
|
+
"""
|
56
|
+
And "examples/junit/tmp/TEST-pending.xml" with junit duration "0.000160" should contain
|
57
|
+
"""
|
58
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
59
|
+
<testsuite errors="0" failures="1" name="Pending step" tests="1" time="0.000160">
|
60
|
+
<testcase classname="Pending step.Pending" name="Pending" time="0.000160">
|
49
61
|
<failure message="pending Pending" type="pending">
|
50
62
|
Scenario: Pending
|
51
63
|
|
52
64
|
TODO (Cucumber::Pending)
|
53
|
-
./features/step_definitions/steps.rb:10:in `/a pending step/'
|
54
65
|
features/pending.feature:4:in `Given a pending step' </failure>
|
55
66
|
</testcase>
|
56
67
|
</testsuite>
|
57
|
-
|
68
|
+
|
58
69
|
"""
|
59
70
|
|
60
71
|
Scenario: run all features
|
@@ -68,11 +79,11 @@ Feature: JUnit output formatter
|
|
68
79
|
|
69
80
|
Scenario: show correct error message if no --out is passed
|
70
81
|
When I run cucumber --format junit features
|
71
|
-
|
72
|
-
|
82
|
+
Then STDERR should not match
|
83
|
+
"""
|
73
84
|
can't convert .* into String \(TypeError\)
|
74
|
-
|
85
|
+
"""
|
75
86
|
And STDERR should match
|
76
|
-
|
87
|
+
"""
|
77
88
|
You \*must\* specify \-\-out DIR for the junit formatter
|
78
|
-
|
89
|
+
"""
|
@@ -35,12 +35,20 @@ Given /^I am running spork in the background$/ do
|
|
35
35
|
run_spork_in_background
|
36
36
|
end
|
37
37
|
|
38
|
+
Given /^I am running spork in the background on port (\d+)$/ do |port|
|
39
|
+
run_spork_in_background(port.to_i)
|
40
|
+
end
|
41
|
+
|
38
42
|
Given /^I am not running (?:.*) in the background$/ do
|
39
43
|
# no-op
|
40
44
|
end
|
41
45
|
|
46
|
+
Given /^I have environment variable (\w+) set to "([^\"]*)"$/ do |variable, value|
|
47
|
+
set_env_var(variable, value)
|
48
|
+
end
|
49
|
+
|
42
50
|
When /^I run cucumber (.*)$/ do |cucumber_opts|
|
43
|
-
run "#{Cucumber::RUBY_BINARY} #{Cucumber::BINARY} --no-color #{cucumber_opts}"
|
51
|
+
run "#{Cucumber::RUBY_BINARY} -I #{Spork::LIBDIR} #{Cucumber::BINARY} --no-color #{cucumber_opts}"
|
44
52
|
end
|
45
53
|
|
46
54
|
When /^I run rake (.*)$/ do |rake_opts|
|
@@ -74,13 +82,15 @@ Then /^the output should be$/ do |text|
|
|
74
82
|
last_stdout.should == text
|
75
83
|
end
|
76
84
|
|
85
|
+
|
77
86
|
Then /^"([^\"]*)" should contain$/ do |file, text|
|
78
87
|
strip_duration(IO.read(file)).should == text
|
79
88
|
end
|
80
89
|
|
81
90
|
Then /^"([^\"]*)" with junit duration "([^\"]*)" should contain$/ do |actual_file, duration_replacement, text|
|
82
91
|
actual = IO.read(actual_file)
|
83
|
-
actual = replace_junit_duration(actual, duration_replacement)
|
92
|
+
actual = replace_junit_duration(actual, duration_replacement)
|
93
|
+
actual = strip_ruby186_extra_trace(actual)
|
84
94
|
actual.should == text
|
85
95
|
end
|
86
96
|
|
@@ -141,3 +151,4 @@ Then /^print output$/ do
|
|
141
151
|
puts last_stdout
|
142
152
|
end
|
143
153
|
|
154
|
+
|
data/features/support/env.rb
CHANGED
@@ -6,7 +6,7 @@ require 'forwardable'
|
|
6
6
|
begin
|
7
7
|
require 'spork'
|
8
8
|
rescue Gem::LoadError => ex
|
9
|
-
gem 'spork', '>= 0.5.
|
9
|
+
gem 'spork', '>= 0.5.9' # Ensure correct spork version number to avoid false-negatives.
|
10
10
|
end
|
11
11
|
|
12
12
|
class CucumberWorld
|
@@ -54,6 +54,10 @@ class CucumberWorld
|
|
54
54
|
s.gsub(/\d+\.\d\d+/m, replacement)
|
55
55
|
end
|
56
56
|
|
57
|
+
def strip_ruby186_extra_trace(s)
|
58
|
+
s.gsub(/^.*\.\/features\/step_definitions(.*)\n/, "")
|
59
|
+
end
|
60
|
+
|
57
61
|
def create_file(file_name, file_content)
|
58
62
|
file_content.gsub!("CUCUMBER_LIB", "'#{cucumber_lib_dir}'") # Some files, such as Rakefiles need to use the lib dir
|
59
63
|
in_current_dir do
|
@@ -61,6 +65,12 @@ class CucumberWorld
|
|
61
65
|
end
|
62
66
|
end
|
63
67
|
|
68
|
+
def set_env_var(variable, value)
|
69
|
+
@original_env_vars ||= {}
|
70
|
+
@original_env_vars[variable] = ENV[variable]
|
71
|
+
ENV[variable] = value
|
72
|
+
end
|
73
|
+
|
64
74
|
def background_jobs
|
65
75
|
@background_jobs ||= []
|
66
76
|
end
|
@@ -84,7 +94,7 @@ class CucumberWorld
|
|
84
94
|
@last_stderr = IO.read(stderr_file.path)
|
85
95
|
end
|
86
96
|
|
87
|
-
def run_spork_in_background
|
97
|
+
def run_spork_in_background(port = nil)
|
88
98
|
pid = fork
|
89
99
|
in_current_dir do
|
90
100
|
if pid
|
@@ -92,7 +102,8 @@ class CucumberWorld
|
|
92
102
|
else
|
93
103
|
# STDOUT.close
|
94
104
|
# STDERR.close
|
95
|
-
|
105
|
+
port_arg = port ? "-p #{port}" : ''
|
106
|
+
cmd = "#{Cucumber::RUBY_BINARY} -I #{Cucumber::LIBDIR} #{Spork::BINARY} cuc #{port_arg}"
|
96
107
|
exec cmd
|
97
108
|
end
|
98
109
|
end
|
@@ -107,6 +118,10 @@ class CucumberWorld
|
|
107
118
|
end
|
108
119
|
end
|
109
120
|
|
121
|
+
def restore_original_env_vars
|
122
|
+
@original_env_vars.each { |variable, value| ENV[variable] = value } if @original_env_vars
|
123
|
+
end
|
124
|
+
|
110
125
|
end
|
111
126
|
|
112
127
|
World do
|
@@ -120,4 +135,5 @@ end
|
|
120
135
|
|
121
136
|
After do
|
122
137
|
terminate_background_jobs
|
138
|
+
restore_original_env_vars
|
123
139
|
end
|
data/lib/cucumber/ast/step.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'cucumber/step_match'
|
2
|
+
|
1
3
|
module Cucumber
|
2
4
|
module Ast
|
3
5
|
class StepInvocation
|
@@ -33,8 +35,7 @@ module Cucumber
|
|
33
35
|
unless @skip_invoke || options[:dry_run] || @exception || @step_collection.exception
|
34
36
|
@skip_invoke = true
|
35
37
|
begin
|
36
|
-
|
37
|
-
@step_match.invoke(step_mother.current_world, @multiline_arg)
|
38
|
+
@step_match.invoke(@multiline_arg)
|
38
39
|
step_mother.after_step
|
39
40
|
status!(:passed)
|
40
41
|
rescue Pending => e
|
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'cucumber/cli/options'
|
2
|
+
require 'cucumber/constantize'
|
2
3
|
|
3
4
|
module Cucumber
|
4
5
|
module Cli
|
@@ -7,6 +8,8 @@ module Cucumber
|
|
7
8
|
class ProfileNotFound < StandardError; end
|
8
9
|
|
9
10
|
class Configuration
|
11
|
+
include Constantize
|
12
|
+
|
10
13
|
attr_reader :options
|
11
14
|
|
12
15
|
def initialize(out_stream = STDOUT, error_stream = STDERR)
|
@@ -50,6 +53,10 @@ module Cucumber
|
|
50
53
|
@options[:drb]
|
51
54
|
end
|
52
55
|
|
56
|
+
def drb_port
|
57
|
+
@options[:drb_port].to_i if @options[:drb_port]
|
58
|
+
end
|
59
|
+
|
53
60
|
def build_formatter_broadcaster(step_mother)
|
54
61
|
return Formatter::Pretty.new(step_mother, nil, @options) if @options[:autoformat]
|
55
62
|
formatters = @options[:formats].map do |format_and_out|
|
@@ -98,6 +105,8 @@ module Cucumber
|
|
98
105
|
env_files = sorted_files.select {|f| f =~ %r{/support/env\..*} }
|
99
106
|
files = env_files + sorted_files.reject {|f| f =~ %r{/support/env\..*} }
|
100
107
|
remove_excluded_files_from(files)
|
108
|
+
files.reject! {|f| !File.file?(f)}
|
109
|
+
files.reject! {|f| File.extname(f) == '.feature' }
|
101
110
|
files.reject! {|f| f =~ %r{/support/env\..*} } if @options[:dry_run]
|
102
111
|
files
|
103
112
|
end
|
@@ -112,22 +121,6 @@ module Cucumber
|
|
112
121
|
potential_feature_files
|
113
122
|
end
|
114
123
|
|
115
|
-
def constantize(camel_cased_word)
|
116
|
-
begin
|
117
|
-
names = camel_cased_word.split('::')
|
118
|
-
names.shift if names.empty? || names.first.empty?
|
119
|
-
|
120
|
-
constant = Object
|
121
|
-
names.each do |name|
|
122
|
-
constant = constant.const_defined?(name) ? constant.const_get(name) : constant.const_missing(name)
|
123
|
-
end
|
124
|
-
constant
|
125
|
-
rescue NameError
|
126
|
-
require underscore(camel_cased_word)
|
127
|
-
retry
|
128
|
-
end
|
129
|
-
end
|
130
|
-
|
131
124
|
private
|
132
125
|
|
133
126
|
def paths
|
@@ -159,15 +152,6 @@ module Cucumber
|
|
159
152
|
def require_dirs
|
160
153
|
feature_dirs + Dir['vendor/{gems,plugins}/*/cucumber']
|
161
154
|
end
|
162
|
-
|
163
|
-
# Snagged from active_support
|
164
|
-
def underscore(camel_cased_word)
|
165
|
-
camel_cased_word.to_s.gsub(/::/, '/').
|
166
|
-
gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
|
167
|
-
gsub(/([a-z\d])([A-Z])/,'\1_\2').
|
168
|
-
tr("-", "_").
|
169
|
-
downcase
|
170
|
-
end
|
171
155
|
|
172
156
|
end
|
173
157
|
|