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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +7 -9
  3. data/CHANGELOG.md +20 -11
  4. data/Gemfile +2 -2
  5. data/LICENSE.txt +1 -1
  6. data/README.md +43 -42
  7. data/Rakefile +54 -54
  8. data/appveyor.yml +20 -0
  9. data/bin/macros4cuke +14 -15
  10. data/lib/macro_steps.rb +3 -3
  11. data/lib/macros4cuke/application.rb +1 -3
  12. data/lib/macros4cuke/cli/cmd-line.rb +1 -3
  13. data/lib/macros4cuke/coll-walker-factory.rb +1 -1
  14. data/lib/macros4cuke/constants.rb +2 -2
  15. data/lib/macros4cuke/formatter/all-notifications.rb +1 -1
  16. data/lib/macros4cuke/formatter/to-gherkin.rb +4 -6
  17. data/lib/macros4cuke/formatter/to-null.rb +14 -14
  18. data/lib/macros4cuke/formatter/to-trace.rb +1 -3
  19. data/lib/macros4cuke/formatting-service.rb +2 -2
  20. data/lib/macros4cuke/macro-collection.rb +4 -6
  21. data/lib/macros4cuke/macro-step-support.rb +0 -2
  22. data/lib/macros4cuke/macro-step.rb +18 -19
  23. data/lib/macros4cuke/templating/comment.rb +0 -2
  24. data/lib/macros4cuke/templating/engine.rb +26 -29
  25. data/lib/macros4cuke/templating/eo-line.rb +18 -21
  26. data/lib/macros4cuke/templating/placeholder.rb +12 -12
  27. data/lib/macros4cuke/templating/section.rb +1 -5
  28. data/lib/macros4cuke/templating/static-text.rb +0 -2
  29. data/lib/macros4cuke/templating/template-element.rb +6 -7
  30. data/spec/macros4cuke/cli/cmd-line_spec.rb +4 -4
  31. data/spec/macros4cuke/coll-walker-factory_spec.rb +42 -42
  32. data/spec/macros4cuke/formatter/to-trace_spec.rb +148 -149
  33. data/spec/macros4cuke/macro-collection_spec.rb +2 -2
  34. data/spec/macros4cuke/macro-step-support_spec.rb +10 -9
  35. data/spec/macros4cuke/macro-step_spec.rb +10 -9
  36. data/spec/macros4cuke/templating/comment_spec.rb +37 -38
  37. data/spec/macros4cuke/templating/engine_spec.rb +19 -22
  38. data/spec/macros4cuke/templating/eo-line_spec.rb +31 -32
  39. data/spec/macros4cuke/templating/placeholder_spec.rb +1 -2
  40. data/spec/macros4cuke/templating/section_spec.rb +10 -7
  41. data/spec/macros4cuke/templating/static_text_spec.rb +38 -39
  42. data/spec/macros4cuke/use-sample-collection.rb +3 -3
  43. metadata +9 -8
@@ -183,57 +183,57 @@ describe CollWalkerFactory do
183
183
  [
184
184
  [:on_placeholder, 3, :name], # 0
185
185
  [:on_static_text, 3, :source], # 1
186
- [:on_eol, 3, nil], # 2
186
+ [:on_eol, 3, nil], # 2
187
187
  [:on_static_text, 3, :source], # 3
188
188
  [:on_placeholder, 3, :name], # 4
189
- [:on_static_text, 3, :source], # 5
190
- [:on_eol, 3, nil], # 6
191
- [:on_static_text, 3, :source], # 7
192
- [:on_placeholder, 3, :name], # 8
193
- [:on_static_text, 3, :source], # 9
194
- [:on_eol, 3, nil], # 10
195
- [:on_static_text, 3, :source], # 11
196
- [:on_placeholder, 3, :name], # 12
197
- [:on_static_text, 3, :source], # 13
198
- [:on_eol, 3, nil], # 14
199
- [:on_static_text, 3, :source], # 15
200
- [:on_placeholder, 3, :name], # 16
201
- [:on_static_text, 3, :source], # 17
202
- [:on_eol, 3, nil], # 18
203
- [:on_static_text, 3, :source], # 19
204
- [:on_placeholder, 3, :name], # 20
205
- [:on_static_text, 3, :source], # 21
206
- [:on_eol, 3, nil], # 22
207
- [:on_eol, 3, nil], # 23
189
+ [:on_static_text, 3, :source], # 5
190
+ [:on_eol, 3, nil], # 6
191
+ [:on_static_text, 3, :source], # 7
192
+ [:on_placeholder, 3, :name], # 8
193
+ [:on_static_text, 3, :source], # 9
194
+ [:on_eol, 3, nil], # 10
195
+ [:on_static_text, 3, :source], # 11
196
+ [:on_placeholder, 3, :name], # 12
197
+ [:on_static_text, 3, :source], # 13
198
+ [:on_eol, 3, nil], # 14
199
+ [:on_static_text, 3, :source], # 15
200
+ [:on_placeholder, 3, :name], # 16
201
+ [:on_static_text, 3, :source], # 17
202
+ [:on_eol, 3, nil], # 18
203
+ [:on_static_text, 3, :source], # 19
204
+ [:on_placeholder, 3, :name], # 20
205
+ [:on_static_text, 3, :source], # 21
206
+ [:on_eol, 3, nil], # 22
207
+ [:on_eol, 3, nil], # 23
208
208
  [:on_comment, 3, :source], # 24
209
- [:on_eol, 3, nil], # 25
209
+ [:on_eol, 3, nil], # 25
210
210
  [:on_comment, 3, :source], # 26
211
- [:on_eol, 3, nil], # 27
211
+ [:on_eol, 3, nil], # 27
212
212
  [:on_comment, 3, :source], # 28
213
- [:on_eol, 3, nil], # 29
214
- [:on_section, 3, :name], # 30
215
- [:on_static_text, 4, :source], # 31
216
- [:on_placeholder, 4, :name], # 32
217
- [:on_static_text, 4, :source], # 33
218
- [:on_eol, 4, nil], # 34
219
- [:on_section_end, 3, nil], # 35
220
- [:on_eol, 3, nil], # 36
213
+ [:on_eol, 3, nil], # 29
214
+ [:on_section, 3, :name], # 30
215
+ [:on_static_text, 4, :source], # 31
216
+ [:on_placeholder, 4, :name], # 32
217
+ [:on_static_text, 4, :source], # 33
218
+ [:on_eol, 4, nil], # 34
219
+ [:on_section_end, 3, nil], # 35
220
+ [:on_eol, 3, nil], # 36
221
221
  [:on_comment, 3, :source], # 37
222
- [:on_eol, 3, nil], # 38
222
+ [:on_eol, 3, nil], # 38
223
223
  [:on_comment, 3, :source], # 39
224
- [:on_eol, 3, nil], # 40
224
+ [:on_eol, 3, nil], # 40
225
225
  [:on_comment, 3, :source], # 41
226
- [:on_eol, 3, nil], # 42
227
- [:on_section, 3, :name], # 43
228
- [:on_static_text, 4, :source], # 44
229
- [:on_placeholder, 4, :name], # 45
230
- [:on_static_text, 4, :source], # 46
231
- [:on_eol, 4, nil], # 47
232
- [:on_section_end, 3, nil], # 48
233
- [:on_static_text, 3, :source], # 49
226
+ [:on_eol, 3, nil], # 42
227
+ [:on_section, 3, :name], # 43
228
+ [:on_static_text, 4, :source], # 44
229
+ [:on_placeholder, 4, :name], # 45
230
+ [:on_static_text, 4, :source], # 46
231
+ [:on_eol, 4, nil], # 47
232
+ [:on_section_end, 3, nil], # 48
233
+ [:on_static_text, 3, :source], # 49
234
234
  [:on_eol, 3, nil], # 50
235
- [:on_renderer_end, 2, nil], # 51
236
- [:on_step_end, 1, nil], # 52
235
+ [:on_renderer_end, 2, nil], # 51
236
+ [:on_step_end, 1, nil], # 52
237
237
  [:on_collection_end, 0, nil] # 53
238
238
  ].each_with_index do |event, i|
239
239
  actual = subject.next
@@ -1,149 +1,148 @@
1
- # File: to-trace_spec.rb
2
-
3
- require 'stringio'
4
- require_relative '../../spec_helper'
5
-
6
- # Load mix-in module for creating a sample collection of macro-steps
7
- require_relative '../use-sample-collection'
8
-
9
-
10
- require_relative '../../../lib/macros4cuke/formatting-service'
11
- # Load the class under test
12
- require_relative '../../../lib/macros4cuke/formatter/to-trace'
13
-
14
- module Macros4Cuke
15
- module Formatter # Open this namespace to get rid of module qualifier prefixes
16
- describe ToTrace do
17
- include UseSampleCollection # Add convenience methods for sample collection
18
-
19
- let(:destination) { StringIO.new }
20
-
21
- before(:all) do
22
- # Fill the collection of macro-steps with sample steps
23
- fill_collection
24
- end
25
-
26
- after(:all) do
27
- # Clear the collection to prevent interference between spec files
28
- macro_coll.clear
29
- end
30
-
31
-
32
- context 'Initialization:' do
33
- it 'should be created with an IO parameter' do
34
- expect { ToTrace.new(destination) }.not_to raise_error
35
- end
36
-
37
- it 'should react to all the notifications' do
38
- instance = ToTrace.new(destination)
39
- expect(instance.implements).to eq(Formatter::AllNotifications)
40
- end
41
- end # context
42
-
43
-
44
- context 'Provided services:' do
45
- # Default instantiation rule
46
- subject { ToTrace.new(destination) }
47
-
48
- # The expected event trace for the sample collection
49
- let(:expected_trace) do
50
- trace_details = <<-SNIPPET
51
- on_collection
52
- on_step
53
- on_phrase
54
- on_renderer
55
- on_source
56
- on_static_text
57
- on_eol
58
- on_static_text
59
- on_eol
60
- on_static_text
61
- on_placeholder
62
- on_static_text
63
- on_eol
64
- on_static_text
65
- on_placeholder
66
- on_static_text
67
- on_eol
68
- on_static_text
69
- on_eol
70
- on_renderer_end
71
- on_step_end
72
- on_step
73
- on_phrase
74
- on_renderer
75
- on_source
76
- on_static_text
77
- on_placeholder
78
- on_static_text
79
- on_eol
80
- on_static_text
81
- on_placeholder
82
- on_static_text
83
- on_eol
84
- on_static_text
85
- on_placeholder
86
- on_static_text
87
- on_eol
88
- on_static_text
89
- on_placeholder
90
- on_static_text
91
- on_eol
92
- on_static_text
93
- on_placeholder
94
- on_static_text
95
- on_eol
96
- on_static_text
97
- on_placeholder
98
- on_static_text
99
- on_eol
100
- on_eol
101
- on_comment
102
- on_eol
103
- on_comment
104
- on_eol
105
- on_comment
106
- on_eol
107
- on_section
108
- on_static_text
109
- on_placeholder
110
- on_static_text
111
- on_eol
112
- on_section_end
113
- on_eol
114
- on_comment
115
- on_eol
116
- on_comment
117
- on_eol
118
- on_comment
119
- on_eol
120
- on_section
121
- on_static_text
122
- on_placeholder
123
- on_static_text
124
- on_eol
125
- on_section_end
126
- on_static_text
127
- on_eol
128
- on_renderer_end
129
- on_step_end
130
- on_collection_end
131
- SNIPPET
132
-
133
- trace_details
134
- end
135
-
136
-
137
- it 'should render the trace event for a given macro-step collection' do
138
- service = FormattingService.new
139
- service.register(subject)
140
- expect { service.start!(macro_coll) }.not_to raise_error
141
- expect(subject.io.string).to eq(expected_trace)
142
- end
143
- end # context
144
- end # describe
145
- end # module
146
- end # module
147
-
148
-
149
- # End of file
1
+ # File: to-trace_spec.rb
2
+ require 'stringio'
3
+ require_relative '../../spec_helper'
4
+
5
+ # Load mix-in module for creating a sample collection of macro-steps
6
+ require_relative '../use-sample-collection'
7
+
8
+
9
+ require_relative '../../../lib/macros4cuke/formatting-service'
10
+ # Load the class under test
11
+ require_relative '../../../lib/macros4cuke/formatter/to-trace'
12
+
13
+ module Macros4Cuke
14
+ module Formatter # Open this namespace to get rid of module qualifier prefixes
15
+ describe ToTrace do
16
+ include UseSampleCollection # Add convenience methods for sample collection
17
+
18
+ let(:destination) { StringIO.new }
19
+
20
+ before(:all) do
21
+ # Fill the collection of macro-steps with sample steps
22
+ fill_collection
23
+ end
24
+
25
+ after(:all) do
26
+ # Clear the collection to prevent interference between spec files
27
+ macro_coll.clear
28
+ end
29
+
30
+
31
+ context 'Initialization:' do
32
+ it 'should be created with an IO parameter' do
33
+ expect { ToTrace.new(destination) }.not_to raise_error
34
+ end
35
+
36
+ it 'should react to all the notifications' do
37
+ instance = ToTrace.new(destination)
38
+ expect(instance.implements).to eq(Formatter::AllNotifications)
39
+ end
40
+ end # context
41
+
42
+
43
+ context 'Provided services:' do
44
+ # Default instantiation rule
45
+ subject { ToTrace.new(destination) }
46
+
47
+ # The expected event trace for the sample collection
48
+ let(:expected_trace) do
49
+ trace_details = <<-SNIPPET
50
+ on_collection
51
+ on_step
52
+ on_phrase
53
+ on_renderer
54
+ on_source
55
+ on_static_text
56
+ on_eol
57
+ on_static_text
58
+ on_eol
59
+ on_static_text
60
+ on_placeholder
61
+ on_static_text
62
+ on_eol
63
+ on_static_text
64
+ on_placeholder
65
+ on_static_text
66
+ on_eol
67
+ on_static_text
68
+ on_eol
69
+ on_renderer_end
70
+ on_step_end
71
+ on_step
72
+ on_phrase
73
+ on_renderer
74
+ on_source
75
+ on_static_text
76
+ on_placeholder
77
+ on_static_text
78
+ on_eol
79
+ on_static_text
80
+ on_placeholder
81
+ on_static_text
82
+ on_eol
83
+ on_static_text
84
+ on_placeholder
85
+ on_static_text
86
+ on_eol
87
+ on_static_text
88
+ on_placeholder
89
+ on_static_text
90
+ on_eol
91
+ on_static_text
92
+ on_placeholder
93
+ on_static_text
94
+ on_eol
95
+ on_static_text
96
+ on_placeholder
97
+ on_static_text
98
+ on_eol
99
+ on_eol
100
+ on_comment
101
+ on_eol
102
+ on_comment
103
+ on_eol
104
+ on_comment
105
+ on_eol
106
+ on_section
107
+ on_static_text
108
+ on_placeholder
109
+ on_static_text
110
+ on_eol
111
+ on_section_end
112
+ on_eol
113
+ on_comment
114
+ on_eol
115
+ on_comment
116
+ on_eol
117
+ on_comment
118
+ on_eol
119
+ on_section
120
+ on_static_text
121
+ on_placeholder
122
+ on_static_text
123
+ on_eol
124
+ on_section_end
125
+ on_static_text
126
+ on_eol
127
+ on_renderer_end
128
+ on_step_end
129
+ on_collection_end
130
+ SNIPPET
131
+
132
+ trace_details
133
+ end
134
+
135
+
136
+ it 'should render the trace event for a given macro-step collection' do
137
+ service = FormattingService.new
138
+ service.register(subject)
139
+ expect { service.start!(macro_coll) }.not_to raise_error
140
+ expect(subject.io.string).to eq(expected_trace)
141
+ end
142
+ end # context
143
+ end # describe
144
+ end # module
145
+ end # module
146
+
147
+
148
+ # End of file
@@ -39,9 +39,9 @@ SNIPPET
39
39
  expect(singleton.macro_steps.size).to eq(1)
40
40
 
41
41
  # Error case: inserting another macro with same phrase.
42
+ exc = Macros4Cuke::DuplicateMacroError
42
43
  msg = "A macro-step with phrase '[enter my credentials]' already exists."
43
- expect { singleton.add_macro(*args) }.to raise_error(
44
- Macros4Cuke::DuplicateMacroError, msg)
44
+ expect { singleton.add_macro(*args) }.to raise_error(exc, msg)
45
45
  end
46
46
 
47
47
  it 'should return the rendition of a given macro-step' do
@@ -1,5 +1,4 @@
1
1
  # File: macro-step_spec.rb
2
-
3
2
  require_relative '../spec_helper'
4
3
 
5
4
  # The class under test
@@ -50,29 +49,31 @@ SNIPPET
50
49
  end
51
50
 
52
51
  it 'should complain when entering the same macro again' do
52
+ txt = phrase1
53
+ substeps = m1_substeps
53
54
  # Error case: trying to register another macro with same key/phrase.
54
- error_type = Macros4Cuke::DuplicateMacroError
55
+ exc = Macros4Cuke::DuplicateMacroError
55
56
  msg = "A macro-step with phrase 'enter the credentials' already exists."
56
- expect { world.add_macro(phrase1, m1_substeps, true) }.to raise_error(
57
- error_type, msg)
57
+ expect { world.add_macro(txt, substeps, true) }.to raise_error(exc, msg)
58
58
  end
59
59
 
60
60
  it 'should complain macro uses no table and phrase is parameterless' do
61
61
  # Error case: substeps have arguments,
62
62
  # but the macro has no mechanism to pass the needed data.
63
- phrase = 'fill in the credentials'
63
+ txt = 'fill in the credentials'
64
+ substeps = m1_substeps
65
+ exc = Macros4Cuke::UnreachableSubstepArgument
64
66
  msg = "The sub-step argument 'userid' does not appear in the phrase."
65
- expect { world.add_macro(phrase, m1_substeps, false) }.to raise_error(
66
- Macros4Cuke::UnreachableSubstepArgument, msg)
67
+ expect { world.add_macro(txt, substeps, false) }.to raise_error(exc, msg)
67
68
  end
68
69
  end # context
69
70
 
70
71
  context 'Invoking macro(s):' do
71
72
  it 'should complain when invoking an unknown macro-step' do
72
73
  phrase_unknown = 'dream of a perfect world'
74
+ exc = Macros4Cuke::UnknownMacroError
73
75
  msg = "Unknown macro-step with phrase: 'dream of a perfect world'."
74
- expect { world.invoke_macro(phrase_unknown) }.to raise_error(
75
- Macros4Cuke::UnknownMacroError, msg)
76
+ expect { world.invoke_macro(phrase_unknown) }.to raise_error(exc, msg)
76
77
  end
77
78
 
78
79
  it "should call the 'steps' method with substeps and variables" do
@@ -37,17 +37,18 @@ SNIPPET
37
37
  it 'should complain when a sub-step argument can never be assigned' do
38
38
  phrase = sample_phrase
39
39
  template = sample_template
40
+ exc = Macros4Cuke::UnreachableSubstepArgument
40
41
  msg = "The sub-step argument 'password' does not appear in the phrase."
41
- expect { MacroStep.new(phrase, template, false) }.to raise_error(
42
- Macros4Cuke::UnreachableSubstepArgument, msg)
42
+ expect { MacroStep.new(phrase, template, false) }.to raise_error(exc, msg)
43
43
  end
44
44
 
45
45
 
46
46
  it 'should complain when an argument in phrase never occurs in substeps' do
47
47
  phrase = 'enter my credentials as <foobar>'
48
+ exc = Macros4Cuke::UselessPhraseArgument
48
49
  msg = "The phrase argument 'foobar' does not appear in a sub-step."
49
- expect { MacroStep.new(phrase, sample_template, true) }.to raise_error(
50
- Macros4Cuke::UselessPhraseArgument, msg)
50
+ template = sample_template
51
+ expect { MacroStep.new(phrase, template, true) }.to raise_error(exc, msg)
51
52
  end
52
53
 
53
54
  it 'should know its phrase' do
@@ -114,20 +115,20 @@ SNIPPET
114
115
 
115
116
  it 'should complain when an unknown variable is used' do
116
117
  # Error case: there is no macro argument called <unknown>
117
- error_message = "Unknown macro-step argument 'unknown'."
118
+ exc = UnknownArgumentError
119
+ msg = "Unknown macro-step argument 'unknown'."
118
120
  args = [ %w(unknown anything) ]
119
- expect { subject.expand(phrase_instance, args) }.to raise_error(
120
- UnknownArgumentError, error_message)
121
+ expect { subject.expand(phrase_instance, args) }.to raise_error(exc, msg)
121
122
  end
122
123
 
123
124
 
124
125
  it 'should complain when argument gets a value from phrase and table' do
125
126
  # Error case: there is no macro argument called <unknown>
126
127
  phrase = 'enter my credentials as "nobody"'
128
+ exc = AmbiguousArgumentValue
127
129
  msg = "The macro argument 'userid' has value 'nobody' and 'someone'."
128
130
  args = [ %w(userid someone), %w(password no-secret) ]
129
- expect { subject.expand(phrase, args) }.to raise_error(
130
- AmbiguousArgumentValue, msg)
131
+ expect { subject.expand(phrase, args) }.to raise_error(exc, msg)
131
132
  end
132
133
 
133
134
 
@@ -1,38 +1,37 @@
1
- # File: comment_spec.rb
2
-
3
- require_relative '../../spec_helper'
4
-
5
- # Load the classes under test
6
- require_relative '../../../lib/macros4cuke/templating/comment'
7
-
8
- module Macros4Cuke
9
- module Templating # Open this namespace to get rid of module qualifier prefixes
10
- describe Comment do
11
- let(:sample_text) { 'Some text' }
12
-
13
- subject { Comment.new(sample_text) }
14
-
15
- context 'Creation and initialization:' do
16
- it 'should be created with a text' do
17
- expect { Comment.new(sample_text) }.not_to raise_error
18
- end
19
-
20
- it 'should know its source text' do
21
- expect(subject.source).to eq(sample_text)
22
- end
23
-
24
- end # context
25
-
26
- context 'Provided services:' do
27
- it 'should render tan empty text' do
28
- context = double('fake_context')
29
- locals = double('fake_locals')
30
-
31
- expect(subject.render(context, locals)).to be_empty
32
- end
33
- end # context
34
- end # describe
35
- end # module
36
- end # module
37
-
38
- # End of file
1
+ # File: comment_spec.rb
2
+ require_relative '../../spec_helper'
3
+
4
+ # Load the classes under test
5
+ require_relative '../../../lib/macros4cuke/templating/comment'
6
+
7
+ module Macros4Cuke
8
+ module Templating # Open this namespace to get rid of module qualifier prefixes
9
+ describe Comment do
10
+ let(:sample_text) { 'Some text' }
11
+
12
+ subject { Comment.new(sample_text) }
13
+
14
+ context 'Creation and initialization:' do
15
+ it 'should be created with a text' do
16
+ expect { Comment.new(sample_text) }.not_to raise_error
17
+ end
18
+
19
+ it 'should know its source text' do
20
+ expect(subject.source).to eq(sample_text)
21
+ end
22
+
23
+ end # context
24
+
25
+ context 'Provided services:' do
26
+ it 'should render tan empty text' do
27
+ context = double('fake_context')
28
+ locals = double('fake_locals')
29
+
30
+ expect(subject.render(context, locals)).to be_empty
31
+ end
32
+ end # context
33
+ end # describe
34
+ end # module
35
+ end # module
36
+
37
+ # End of file