macros4cuke 0.5.14 → 0.5.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.travis.yml +7 -9
- data/CHANGELOG.md +20 -11
- data/Gemfile +2 -2
- data/LICENSE.txt +1 -1
- data/README.md +43 -42
- data/Rakefile +54 -54
- data/appveyor.yml +20 -0
- data/bin/macros4cuke +14 -15
- data/lib/macro_steps.rb +3 -3
- data/lib/macros4cuke/application.rb +1 -3
- data/lib/macros4cuke/cli/cmd-line.rb +1 -3
- data/lib/macros4cuke/coll-walker-factory.rb +1 -1
- data/lib/macros4cuke/constants.rb +2 -2
- data/lib/macros4cuke/formatter/all-notifications.rb +1 -1
- data/lib/macros4cuke/formatter/to-gherkin.rb +4 -6
- data/lib/macros4cuke/formatter/to-null.rb +14 -14
- data/lib/macros4cuke/formatter/to-trace.rb +1 -3
- data/lib/macros4cuke/formatting-service.rb +2 -2
- data/lib/macros4cuke/macro-collection.rb +4 -6
- data/lib/macros4cuke/macro-step-support.rb +0 -2
- data/lib/macros4cuke/macro-step.rb +18 -19
- data/lib/macros4cuke/templating/comment.rb +0 -2
- data/lib/macros4cuke/templating/engine.rb +26 -29
- data/lib/macros4cuke/templating/eo-line.rb +18 -21
- data/lib/macros4cuke/templating/placeholder.rb +12 -12
- data/lib/macros4cuke/templating/section.rb +1 -5
- data/lib/macros4cuke/templating/static-text.rb +0 -2
- data/lib/macros4cuke/templating/template-element.rb +6 -7
- data/spec/macros4cuke/cli/cmd-line_spec.rb +4 -4
- data/spec/macros4cuke/coll-walker-factory_spec.rb +42 -42
- data/spec/macros4cuke/formatter/to-trace_spec.rb +148 -149
- data/spec/macros4cuke/macro-collection_spec.rb +2 -2
- data/spec/macros4cuke/macro-step-support_spec.rb +10 -9
- data/spec/macros4cuke/macro-step_spec.rb +10 -9
- data/spec/macros4cuke/templating/comment_spec.rb +37 -38
- data/spec/macros4cuke/templating/engine_spec.rb +19 -22
- data/spec/macros4cuke/templating/eo-line_spec.rb +31 -32
- data/spec/macros4cuke/templating/placeholder_spec.rb +1 -2
- data/spec/macros4cuke/templating/section_spec.rb +10 -7
- data/spec/macros4cuke/templating/static_text_spec.rb +38 -39
- data/spec/macros4cuke/use-sample-collection.rb +3 -3
- metadata +9 -8
@@ -70,8 +70,6 @@ EOS
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
-
public
|
74
|
-
|
75
73
|
# Perform the command-line parsing
|
76
74
|
def parse!(theCmdLineArgs)
|
77
75
|
begin
|
@@ -112,7 +110,7 @@ EOS
|
|
112
110
|
feature_path = dirs.reduce(Pathname.getwd) do |path, dir_name|
|
113
111
|
path += dir_name
|
114
112
|
unless path.exist?
|
115
|
-
|
113
|
+
raise DirectoryNotFound.new(path.relative_path_from(Pathname.getwd))
|
116
114
|
end
|
117
115
|
path
|
118
116
|
end
|
@@ -3,10 +3,10 @@
|
|
3
3
|
|
4
4
|
module Macros4Cuke # Module used as a namespace
|
5
5
|
# The version number of the gem.
|
6
|
-
Version = '0.5.
|
6
|
+
Version = '0.5.15'.freeze
|
7
7
|
|
8
8
|
# Brief description of the gem.
|
9
|
-
Description = 'Add your own macro-steps to Cucumber scenarios'
|
9
|
+
Description = 'Add your own macro-steps to Cucumber scenarios'.freeze
|
10
10
|
|
11
11
|
# Constant Macros4Cuke::RootDir contains the absolute path of Macro4Cuke's
|
12
12
|
# root directory. Note: it also ends with a slash character.
|
@@ -19,8 +19,6 @@ class ToGherkin
|
|
19
19
|
@step_count = 0
|
20
20
|
end
|
21
21
|
|
22
|
-
public
|
23
|
-
|
24
22
|
# Tell which notifications this formatter subscribes to.
|
25
23
|
def implements()
|
26
24
|
return [:on_collection, :on_step, :on_step_end, :on_phrase, :on_source]
|
@@ -49,16 +47,16 @@ class ToGherkin
|
|
49
47
|
def on_phrase(aLevel, aPhraseText, useTable)
|
50
48
|
suffix = useTable ? ':' : ''
|
51
49
|
io.print "#{indentation(aLevel)}Given I define the step "
|
52
|
-
io.puts %
|
50
|
+
io.puts %("* I [#{aPhraseText}]#{suffix}" to mean:)
|
53
51
|
end
|
54
52
|
|
55
53
|
def on_source(aLevel, aSourceText)
|
56
54
|
ljust = indentation(aLevel)
|
57
|
-
triple_quotes = %
|
55
|
+
triple_quotes = %(#{ljust}""")
|
58
56
|
io.puts triple_quotes
|
59
57
|
|
60
58
|
# Indent source text
|
61
|
-
indented_text = aSourceText.gsub(/^/m,
|
59
|
+
indented_text = aSourceText.gsub(/^/m, ljust.to_s)
|
62
60
|
|
63
61
|
io.puts indented_text
|
64
62
|
io.puts triple_quotes
|
@@ -67,7 +65,7 @@ class ToGherkin
|
|
67
65
|
private
|
68
66
|
|
69
67
|
def indentation(aLevel)
|
70
|
-
return ' ' *
|
68
|
+
return ' ' * aLevel
|
71
69
|
end
|
72
70
|
end # class
|
73
71
|
end # module
|
@@ -17,59 +17,59 @@ module Macros4Cuke # Module used as a namespace
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def on_collection(_, _)
|
20
|
-
|
20
|
+
# Do nothing
|
21
21
|
end
|
22
22
|
|
23
23
|
def on_collection_end(_)
|
24
|
-
|
24
|
+
# Do nothing
|
25
25
|
end
|
26
26
|
|
27
27
|
def on_step(_, _)
|
28
|
-
|
28
|
+
# Do nothing
|
29
29
|
end
|
30
30
|
|
31
31
|
def on_step_end(_)
|
32
|
-
|
32
|
+
# Do nothing
|
33
33
|
end
|
34
34
|
|
35
35
|
def on_phrase(_, _, _)
|
36
|
-
|
36
|
+
# Do nothing
|
37
37
|
end
|
38
38
|
|
39
39
|
def on_renderer(_, _)
|
40
|
-
|
40
|
+
# Do nothing
|
41
41
|
end
|
42
42
|
|
43
43
|
def on_renderer_end(_)
|
44
|
-
|
44
|
+
# Do nothing
|
45
45
|
end
|
46
46
|
|
47
47
|
def on_source(_, _)
|
48
|
-
|
48
|
+
# Do nothing
|
49
49
|
end
|
50
50
|
|
51
51
|
def on_static_text(_, _)
|
52
|
-
|
52
|
+
# Do nothing
|
53
53
|
end
|
54
54
|
|
55
55
|
def on_comment(_, _)
|
56
|
-
|
56
|
+
# Do nothing
|
57
57
|
end
|
58
58
|
|
59
59
|
def on_eol(_)
|
60
|
-
|
60
|
+
# Do nothing
|
61
61
|
end
|
62
62
|
|
63
63
|
def on_placeholder(_, _)
|
64
|
-
|
64
|
+
# Do nothing
|
65
65
|
end
|
66
66
|
|
67
67
|
def on_section(_, _)
|
68
|
-
|
68
|
+
# Do Nothing
|
69
69
|
end
|
70
70
|
|
71
71
|
def on_section_end(_)
|
72
|
-
|
72
|
+
# Do Nothing
|
73
73
|
end
|
74
74
|
end # class
|
75
75
|
end # module
|
@@ -17,8 +17,6 @@ module Formatter
|
|
17
17
|
@io = anIO
|
18
18
|
end
|
19
19
|
|
20
|
-
public
|
21
|
-
|
22
20
|
# Tell which notifications the formatter subscribes to.
|
23
21
|
def implements()
|
24
22
|
return Formatter::AllNotifications
|
@@ -40,7 +38,7 @@ module Formatter
|
|
40
38
|
trace_event(aLevel, __method__)
|
41
39
|
end
|
42
40
|
|
43
|
-
def on_phrase(aLevel, _,
|
41
|
+
def on_phrase(aLevel, _, _)
|
44
42
|
trace_event(aLevel, __method__)
|
45
43
|
end
|
46
44
|
|
@@ -33,14 +33,14 @@ class FormattingService
|
|
33
33
|
|
34
34
|
# Complain if list is empty or nil
|
35
35
|
if supported_events.nil? || supported_events.empty?
|
36
|
-
|
36
|
+
raise(NoFormattingEventForFormatter.new(aFormatter))
|
37
37
|
end
|
38
38
|
|
39
39
|
# Check that each event from the event list the formatter is known.
|
40
40
|
supported_events.each do |event|
|
41
41
|
next if Formatter::AllNotifications.include? event
|
42
42
|
|
43
|
-
|
43
|
+
raise(UnknownFormattingEvent.new(aFormatter, event))
|
44
44
|
end
|
45
45
|
|
46
46
|
formatters << aFormatter
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# File: macro-collection.rb
|
2
2
|
# Purpose: Implementation of the MacroCollection class.
|
3
3
|
|
4
|
-
require 'singleton'
|
4
|
+
require 'singleton' # We'll use the Singleton design pattern for this class.
|
5
5
|
require_relative 'macro-step'
|
6
6
|
|
7
7
|
module Macros4Cuke # Module used as a namespace
|
@@ -16,8 +16,6 @@ class MacroCollection
|
|
16
16
|
# A Hash with pairs of the form: macro key => MacroStep object
|
17
17
|
|
18
18
|
|
19
|
-
public
|
20
|
-
|
21
19
|
# Add a new macro.
|
22
20
|
# Pre-condition: there is no existing macro with the same key.
|
23
21
|
# @param aPhrase [String] The text that is enclosed between
|
@@ -31,7 +29,7 @@ class MacroCollection
|
|
31
29
|
# Prevent collision of macros (macros with same phrase).
|
32
30
|
# This can occur if a macro was defined in a background section.
|
33
31
|
# An exception is raised if the phrase syntax of both macros are the
|
34
|
-
|
32
|
+
raise(DuplicateMacroError, aPhrase) if find_macro(aPhrase, useTable)
|
35
33
|
|
36
34
|
macro_steps[new_macro.key] = new_macro
|
37
35
|
end
|
@@ -47,10 +45,10 @@ class MacroCollection
|
|
47
45
|
def render_steps(aPhrase, rawData = nil)
|
48
46
|
use_table = !rawData.nil?
|
49
47
|
macro = find_macro(aPhrase, use_table)
|
50
|
-
|
48
|
+
raise(UnknownMacroError, aPhrase) if macro.nil?
|
51
49
|
|
52
50
|
# Render the steps
|
53
|
-
return
|
51
|
+
return macro.expand(aPhrase, rawData)
|
54
52
|
end
|
55
53
|
|
56
54
|
|
@@ -16,8 +16,6 @@ module MacroStepSupport
|
|
16
16
|
# The substeps being executed in the scenario represented as text.
|
17
17
|
attr_reader(:substeps_trace)
|
18
18
|
|
19
|
-
public
|
20
|
-
|
21
19
|
# Add a new macro.
|
22
20
|
# Pre-condition: there is no existing macro with the same key.
|
23
21
|
# @param aPhrase [String] The text that is enclosed between
|
@@ -1,7 +1,6 @@
|
|
1
1
|
# File: macro-step.rb
|
2
2
|
# Purpose: Implementation of the MacroStep class.
|
3
3
|
|
4
|
-
|
5
4
|
require_relative 'exceptions'
|
6
5
|
require_relative 'templating/engine'
|
7
6
|
|
@@ -17,7 +16,7 @@ class MacroStep
|
|
17
16
|
# The set of predefined macro argument constant values.
|
18
17
|
BuiltinParameters = {
|
19
18
|
'quotes' => '"""'
|
20
|
-
}
|
19
|
+
}.freeze
|
21
20
|
|
22
21
|
# A template engine that expands the sub-steps upon request.
|
23
22
|
attr_reader(:renderer)
|
@@ -84,7 +83,7 @@ class MacroStep
|
|
84
83
|
stripped_phrase = aMacroPhrase.strip # Remove leading ... trailing space(s)
|
85
84
|
|
86
85
|
# Remove every underscore
|
87
|
-
stripped_phrase.
|
86
|
+
stripped_phrase.delete!('_')
|
88
87
|
|
89
88
|
# Replace all consecutive whitespaces by an underscore
|
90
89
|
stripped_phrase.gsub!(/\s+/, '_')
|
@@ -93,12 +92,12 @@ class MacroStep
|
|
93
92
|
# Determine the pattern to isolate
|
94
93
|
# each argument/parameter with its delimiters
|
95
94
|
pattern = case mode
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
95
|
+
when :definition
|
96
|
+
/<(?:[^\\<>]|\\.)*>/
|
97
|
+
when :invokation
|
98
|
+
/"([^\\"]|\\.)*"/
|
100
99
|
|
101
|
-
|
100
|
+
end
|
102
101
|
|
103
102
|
# Each text between quotes or chevron is replaced by the letter X
|
104
103
|
normalized = stripped_phrase.gsub(pattern, 'X')
|
@@ -165,9 +164,9 @@ class MacroStep
|
|
165
164
|
# @param params [Hash] The pairs phrase argument name => value
|
166
165
|
def validate_row(a_row, params)
|
167
166
|
(a_key, value) = a_row
|
168
|
-
|
167
|
+
raise(UnknownArgumentError.new(a_key)) unless args.include? a_key
|
169
168
|
if (phrase_args.include? a_key) && (params[a_key] != value)
|
170
|
-
|
169
|
+
raise(AmbiguousArgumentValue.new(a_key, params[a_key], value))
|
171
170
|
end
|
172
171
|
|
173
172
|
return a_row
|
@@ -185,17 +184,17 @@ class MacroStep
|
|
185
184
|
# determine the syntax of the arguments/parameters
|
186
185
|
# as a regular expression with one capturing group
|
187
186
|
pattern = case mode
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
187
|
+
when :definition
|
188
|
+
/<((?:[^\\<>]|\\.)*)>/
|
189
|
+
# /{{{([^}]*)}}}|{{([^}]*)}}/ # Two capturing groups!...
|
190
|
+
when :invokation
|
191
|
+
/"((?:[^\\"]|\\.)*)"/
|
192
|
+
end
|
194
193
|
raw_result = aMacroPhrase.scan(pattern)
|
195
194
|
args = raw_result.flatten.compact
|
196
195
|
|
197
196
|
# Replace escaped quotes by quote character.
|
198
|
-
args.map! { |arg| arg.sub(/\\"/, '"') }
|
197
|
+
args.map! { |arg| arg.sub(/\\"/, '"') } if mode == :invokation
|
199
198
|
|
200
199
|
return args
|
201
200
|
end
|
@@ -206,7 +205,7 @@ class MacroStep
|
|
206
205
|
# Error when the phrase names an argument that never occurs in the substeps
|
207
206
|
thePhraseArgs.each do |phrase_arg|
|
208
207
|
next if substepsVars.include? phrase_arg
|
209
|
-
|
208
|
+
raise(UselessPhraseArgument.new(phrase_arg))
|
210
209
|
end
|
211
210
|
# Error when a substep has an argument that never appears in the phrase
|
212
211
|
# and the macro-step does not use data table.
|
@@ -215,7 +214,7 @@ class MacroStep
|
|
215
214
|
next if thePhraseArgs.include?(substep_arg) ||
|
216
215
|
BuiltinParameters.include?(substep_arg)
|
217
216
|
|
218
|
-
|
217
|
+
raise(UnreachableSubstepArgument.new(substep_arg))
|
219
218
|
end
|
220
219
|
end
|
221
220
|
|
@@ -20,8 +20,6 @@ module Macros4Cuke # Module used as a namespace
|
|
20
20
|
@source = aSourceText
|
21
21
|
end
|
22
22
|
|
23
|
-
public
|
24
|
-
|
25
23
|
# Render the comment.
|
26
24
|
# Comments are rendered as empty text. This is necessary because
|
27
25
|
# Cucumber::RbSupport::RbWorld#steps complains when it sees a comment.
|
@@ -9,7 +9,7 @@ require_relative 'eo-line'
|
|
9
9
|
require_relative 'comment'
|
10
10
|
require_relative 'template-element'
|
11
11
|
require_relative 'placeholder'
|
12
|
-
require_relative 'section'
|
12
|
+
require_relative 'section' # Load the Section and ConditionalSection
|
13
13
|
|
14
14
|
|
15
15
|
module Macros4Cuke # Module used as a namespace
|
@@ -32,7 +32,7 @@ class Engine
|
|
32
32
|
# between chevrons <...> template tags.
|
33
33
|
DisallowedSigns = begin
|
34
34
|
# Use concatenation (+) to work around Ruby bug!
|
35
|
-
forbidden =
|
35
|
+
forbidden = ' !"#' + "$%&'()*+,-./:;<=>?[\\]^`{|}~"
|
36
36
|
all_escaped = []
|
37
37
|
forbidden.each_char { |ch| all_escaped << Regexp.escape(ch) }
|
38
38
|
pattern = all_escaped.join('|')
|
@@ -54,8 +54,6 @@ class Engine
|
|
54
54
|
@representation = compile(aSourceTemplate)
|
55
55
|
end
|
56
56
|
|
57
|
-
public
|
58
|
-
|
59
57
|
# Render the template within the given scope object and
|
60
58
|
# with the locals specified.
|
61
59
|
# The method mimicks the signature of the Tilt::Template#render method.
|
@@ -112,7 +110,7 @@ class Engine
|
|
112
110
|
scanner = StringScanner.new(aTextLine)
|
113
111
|
result = []
|
114
112
|
|
115
|
-
if scanner.check(/\s*#/)
|
113
|
+
if scanner.check(/\s*#/) # Detect comment line
|
116
114
|
result << [:comment, aTextLine]
|
117
115
|
else
|
118
116
|
until scanner.eos?
|
@@ -132,8 +130,6 @@ class Engine
|
|
132
130
|
return result
|
133
131
|
end
|
134
132
|
|
135
|
-
private
|
136
|
-
|
137
133
|
# Called when the given text line could not be parsed.
|
138
134
|
# Raises an exception with the syntax issue identified.
|
139
135
|
# @param aTextLine [String] A text line from the template.
|
@@ -152,13 +148,14 @@ class Engine
|
|
152
148
|
when '>' then unbalance -= 1
|
153
149
|
end
|
154
150
|
|
155
|
-
|
156
|
-
|
151
|
+
raise(StandardError, "Nested opening chevron '<'.") if unbalance > 1
|
152
|
+
raise(StandardError, "Missing opening chevron '<'.") if unbalance < 0
|
157
153
|
end
|
158
154
|
|
159
|
-
|
155
|
+
raise(StandardError, "Missing closing chevron '>'.") if unbalance == 1
|
160
156
|
end
|
161
|
-
|
157
|
+
|
158
|
+
private
|
162
159
|
|
163
160
|
# Create the internal representation of the given template.
|
164
161
|
def compile(aSourceTemplate)
|
@@ -172,7 +169,7 @@ class Engine
|
|
172
169
|
# A tag text cannot be empty nor blank
|
173
170
|
next if (kind != :dynamic) || !text.strip.empty?
|
174
171
|
|
175
|
-
|
172
|
+
raise(EmptyArgumentError.new(line.strip))
|
176
173
|
end
|
177
174
|
|
178
175
|
line_items
|
@@ -236,10 +233,10 @@ class Engine
|
|
236
233
|
(kind, text) = aCouple
|
237
234
|
|
238
235
|
result = case kind
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
236
|
+
when :static then StaticText.new(text)
|
237
|
+
when :comment then Comment.new(text)
|
238
|
+
when :dynamic then parse_tag(text)
|
239
|
+
end
|
243
240
|
|
244
241
|
return result
|
245
242
|
end
|
@@ -255,17 +252,17 @@ class Engine
|
|
255
252
|
# Disallow punctuation and delimiter signs in tags.
|
256
253
|
matching = DisallowedSigns.match(aText)
|
257
254
|
end
|
258
|
-
|
255
|
+
raise(InvalidCharError.new(aText, matching[0])) if matching
|
259
256
|
|
260
257
|
result = case aText[0, 1]
|
261
|
-
|
262
|
-
|
258
|
+
when '?'
|
259
|
+
ConditionalSection.new(aText[1..-1], true)
|
263
260
|
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
261
|
+
when '/'
|
262
|
+
SectionEndMarker.new(aText[1..-1])
|
263
|
+
else
|
264
|
+
Placeholder.new(aText)
|
265
|
+
end
|
269
266
|
|
270
267
|
return result
|
271
268
|
end
|
@@ -273,7 +270,7 @@ class Engine
|
|
273
270
|
# Transform a flat sequence of elements into a hierarchy of sections.
|
274
271
|
# @param flat_sequence [Array] a linear list of elements (including sections)
|
275
272
|
def compile_sections(flat_sequence)
|
276
|
-
open_sections = []
|
273
|
+
open_sections = [] # The list of nested open sections
|
277
274
|
|
278
275
|
compiled = flat_sequence.each_with_object([]) do |element, subResult|
|
279
276
|
case element
|
@@ -294,8 +291,8 @@ class Engine
|
|
294
291
|
end
|
295
292
|
|
296
293
|
unless open_sections.empty?
|
297
|
-
error_message =
|
298
|
-
|
294
|
+
error_message = "Unterminated section #{open_sections.last}."
|
295
|
+
raise(StandardError, error_message)
|
299
296
|
end
|
300
297
|
|
301
298
|
return compiled
|
@@ -308,11 +305,11 @@ class Engine
|
|
308
305
|
|
309
306
|
if sections.empty?
|
310
307
|
msg = 'found while no corresponding section is open.'
|
311
|
-
|
308
|
+
raise(StandardError, msg_prefix + msg)
|
312
309
|
end
|
313
310
|
return if marker.name == sections.last.name
|
314
311
|
msg = "doesn't match current section '#{sections.last.name}'."
|
315
|
-
|
312
|
+
raise(StandardError, msg_prefix + msg)
|
316
313
|
end
|
317
314
|
end # class
|
318
315
|
end # module
|
@@ -1,21 +1,18 @@
|
|
1
|
-
#
|
2
|
-
|
3
|
-
|
4
|
-
module
|
5
|
-
#
|
6
|
-
#
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
end # module
|
20
|
-
|
21
|
-
# End of file
|
1
|
+
module Macros4Cuke # Module used as a namespace
|
2
|
+
# Module containing all classes implementing the simple template engine
|
3
|
+
# used internally in Macros4Cuke.
|
4
|
+
module Templating
|
5
|
+
# Class used internally by the template engine.
|
6
|
+
# Represents an end of line that must be rendered as such.
|
7
|
+
class EOLine
|
8
|
+
# Render an end of line.
|
9
|
+
# This method has the same signature as the {Engine#render} method.
|
10
|
+
# @return [String] An end of line marker. Its exact value is OS-dependent.
|
11
|
+
def render(_, _)
|
12
|
+
return "\n"
|
13
|
+
end
|
14
|
+
end # class
|
15
|
+
end # module
|
16
|
+
end # module
|
17
|
+
|
18
|
+
# End of file
|
@@ -22,18 +22,18 @@ module Templating
|
|
22
22
|
actual_value = retrieve_value_from(aContextObject, theLocals)
|
23
23
|
|
24
24
|
result = case actual_value
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
25
|
+
when NilClass
|
26
|
+
''
|
27
|
+
|
28
|
+
when Array
|
29
|
+
# TODO: Move away from hard-coded separator.
|
30
|
+
actual_value.join('<br/>')
|
31
|
+
|
32
|
+
when String
|
33
|
+
actual_value
|
34
|
+
else
|
35
|
+
actual_value.to_s
|
36
|
+
end
|
37
37
|
|
38
38
|
return result
|
39
39
|
end
|
@@ -22,8 +22,6 @@ class Section < UnaryElement
|
|
22
22
|
@children = []
|
23
23
|
end
|
24
24
|
|
25
|
-
public
|
26
|
-
|
27
25
|
# Add a child element as member of the section
|
28
26
|
def add_child(aChild)
|
29
27
|
children << aChild
|
@@ -51,7 +49,7 @@ class Section < UnaryElement
|
|
51
49
|
# Returns an empty string when no value is assigned to the placeholder.
|
52
50
|
def render(_, _)
|
53
51
|
msg = "Method Section.#{__method__} must be implemented in subclass."
|
54
|
-
|
52
|
+
raise(NotImplementedError, msg)
|
55
53
|
end
|
56
54
|
end # class
|
57
55
|
|
@@ -72,8 +70,6 @@ class ConditionalSection < Section
|
|
72
70
|
@existence = renderWhenExisting
|
73
71
|
end
|
74
72
|
|
75
|
-
public
|
76
|
-
|
77
73
|
# Render the placeholder given the passed arguments.
|
78
74
|
# This method has the same signature as the {Engine#render} method.
|
79
75
|
# @return [String] The text value assigned to the placeholder.
|
@@ -20,8 +20,6 @@ module Macros4Cuke # Module used as a namespace
|
|
20
20
|
@source = aSourceText
|
21
21
|
end
|
22
22
|
|
23
|
-
public
|
24
|
-
|
25
23
|
# Render the static text.
|
26
24
|
# This method has the same signature as the {Engine#render} method.
|
27
25
|
# @return [String] Static text is returned verbatim ("as is")
|
@@ -1,7 +1,6 @@
|
|
1
|
-
# File: template-element.rb
|
2
|
-
|
3
|
-
require_relative '
|
4
|
-
require_relative '
|
5
|
-
|
6
|
-
|
7
|
-
# End of file
|
1
|
+
# File: template-element.rb
|
2
|
+
require_relative 'static-text'
|
3
|
+
require_relative 'comment'
|
4
|
+
require_relative 'eo-line'
|
5
|
+
|
6
|
+
# End of file
|
@@ -134,7 +134,7 @@ END_MESSAGE
|
|
134
134
|
|
135
135
|
it 'should complain when an option misses an argument' do
|
136
136
|
hijack_stderr
|
137
|
-
err_msg =
|
137
|
+
err_msg = <<-END_MESSAGE
|
138
138
|
No argument provided with command line option: --setup
|
139
139
|
END_MESSAGE
|
140
140
|
|
@@ -148,7 +148,7 @@ END_MESSAGE
|
|
148
148
|
|
149
149
|
it "should complain when project to setup doesn't exist" do
|
150
150
|
hijack_stderr
|
151
|
-
err_msg =
|
151
|
+
err_msg = <<-END_MESSAGE
|
152
152
|
Error in command-line:
|
153
153
|
Cannot find the directory 'not_a_dir'.
|
154
154
|
END_MESSAGE
|
@@ -166,7 +166,7 @@ END_MESSAGE
|
|
166
166
|
mk_subdir('test_dir')
|
167
167
|
|
168
168
|
hijack_stderr
|
169
|
-
err_msg =
|
169
|
+
err_msg = <<-END_MESSAGE
|
170
170
|
Error in command-line:
|
171
171
|
Cannot find the directory 'test_dir/features'.
|
172
172
|
END_MESSAGE
|
@@ -181,7 +181,7 @@ END_MESSAGE
|
|
181
181
|
|
182
182
|
mk_subdir('test_dir/features')
|
183
183
|
hijack_stderr
|
184
|
-
err_msg =
|
184
|
+
err_msg = <<-END_MESSAGE
|
185
185
|
Error in command-line:
|
186
186
|
Cannot find the directory 'test_dir/features/support'.
|
187
187
|
END_MESSAGE
|