Module: Cucumber2RSpec
- Defined in:
- lib/cucumber2rspec.rb,
lib/cucumber2rspec/step.rb,
lib/cucumber2rspec/feature.rb,
lib/cucumber2rspec/scenario.rb,
lib/cucumber2rspec/background.rb
Overview
Defined Under Namespace
Classes: Background, Feature, Scenario, Step
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.logger ⇒ Object
Returns the value of attribute logger.
19
20
21
|
# File 'lib/cucumber2rspec.rb', line 19
def logger
@logger
end
|
Class Method Details
.block_variable_names(a_proc) ⇒ Object
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
|
# File 'lib/cucumber2rspec.rb', line 58
def self.block_variable_names a_proc
sexp = a_proc.to_sexp
local_assignments = []
if sexp[2] and sexp[2].is_a?(Sexp)
if sexp[2][0] == :lasgn
local_assignments << sexp[2][1]
elsif sexp[2][0] == :masgn and sexp[2][1][0] == :array array_of_variables = a_proc.to_sexp[2][1]
the_type = array_of_variables.shift
array_of_variables.each do |sub_sexp|
local_assignments << sub_sexp[1] if sub_sexp[0] == :lasgn
end
end
end
local_assignments
end
|
.log(&block) ⇒ Object
22
23
24
|
# File 'lib/cucumber2rspec.rb', line 22
def self.log &block
logger.debug(&block) if logger
end
|
.parser ⇒ Object
26
27
28
29
|
# File 'lib/cucumber2rspec.rb', line 26
def self.parser
Cucumber.load_language('en')
@parser ||= Cucumber::Parser::FeatureParser.new
end
|
.replace_in_sexp(sexp, to_replace, replace_with) ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/cucumber2rspec.rb', line 44
def self.replace_in_sexp sexp, to_replace, replace_with
while sexp.include?(to_replace)
index = sexp.index(to_replace)
sexp.delete_at index
sexp.insert index, replace_with
end
sexp.each do|obj|
replace_in_sexp(obj, to_replace, replace_with) if obj.is_a?(Sexp)
end
sexp
end
|
.step_match(text) ⇒ Object
31
32
33
|
# File 'lib/cucumber2rspec.rb', line 31
def self.step_match text
$step_match.call(text)
end
|
.translate(feature_text) ⇒ Object
.translate_file(filepath) ⇒ Object
39
40
41
42
|
# File 'lib/cucumber2rspec.rb', line 39
def self.translate_file filepath
Cucumber2RSpec.log { "translate_file(#{filepath.inspect})" }
translate File.read(filepath)
end
|