macros4cuke 0.5.14 → 0.5.15
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,5 +1,4 @@
|
|
1
1
|
# File: engine_spec.rb
|
2
|
-
|
3
2
|
require_relative '../../spec_helper'
|
4
3
|
|
5
4
|
# Load the class under test
|
@@ -155,23 +154,23 @@ SNIPPET
|
|
155
154
|
|
156
155
|
it 'should complain if a tag misses an closing chevron' do
|
157
156
|
sample_text = 'begin <some_tag\> end'
|
158
|
-
|
159
|
-
|
160
|
-
|
157
|
+
exc = StandardError
|
158
|
+
err_msg = "Missing closing chevron '>'."
|
159
|
+
expect { Engine.parse(sample_text) }.to raise_error(exc, err_msg)
|
161
160
|
end
|
162
161
|
|
163
162
|
it 'should complain if a text misses an opening chevron' do
|
164
163
|
sample_text = 'begin <some_tag> > end'
|
165
|
-
|
166
|
-
|
167
|
-
|
164
|
+
exc = StandardError
|
165
|
+
err_msg = "Missing opening chevron '<'."
|
166
|
+
expect { Engine.parse(sample_text) }.to raise_error(exc, err_msg)
|
168
167
|
end
|
169
168
|
|
170
169
|
it 'should complain if a text has nested opening chevrons' do
|
171
170
|
sample_text = 'begin <<some_tag> > end'
|
172
|
-
|
173
|
-
|
174
|
-
|
171
|
+
exc = StandardError
|
172
|
+
err_msg = "Nested opening chevron '<'."
|
173
|
+
expect { Engine.parse(sample_text) }.to raise_error(exc, err_msg)
|
175
174
|
end
|
176
175
|
end # context
|
177
176
|
|
@@ -203,35 +202,33 @@ SNIPPET
|
|
203
202
|
|
204
203
|
it 'should complain when a placeholder is empty or blank' do
|
205
204
|
text_w_empty_arg = sample_template.sub(/userid/, '')
|
206
|
-
|
205
|
+
exc = Macros4Cuke::EmptyArgumentError
|
206
|
+
msg = %(An empty or blank argument occurred in\
|
207
207
|
'And I fill in "Username" with "<>"'.)
|
208
|
-
expect { Engine.new text_w_empty_arg }.to raise_error(
|
209
|
-
Macros4Cuke::EmptyArgumentError, msg)
|
208
|
+
expect { Engine.new text_w_empty_arg }.to raise_error(exc, msg)
|
210
209
|
end
|
211
210
|
|
212
211
|
it 'should complain when a placeholder contains an invalid character' do
|
213
212
|
text_w_empty_arg = sample_template.sub(/userid/, 'user%id')
|
213
|
+
exc = Macros4Cuke::InvalidCharError
|
214
214
|
msg = "The invalid sign '%' occurs in the argument 'user%id'."
|
215
|
-
expect { Engine.new text_w_empty_arg }.to raise_error(
|
216
|
-
Macros4Cuke::InvalidCharError, msg)
|
215
|
+
expect { Engine.new text_w_empty_arg }.to raise_error(exc, msg)
|
217
216
|
end
|
218
217
|
|
219
218
|
it 'should complain when a section has no closing tag' do
|
220
219
|
# Removing an end of section tag...
|
221
220
|
text_w_open_section = sophisticated_template.sub(%r{</address>}, '')
|
222
|
-
|
223
|
-
|
224
|
-
expect { Engine.new text_w_open_section }.to raise_error(
|
225
|
-
StandardError, error_message)
|
221
|
+
exc = StandardError
|
222
|
+
msg = 'Unterminated section <?address>.'
|
223
|
+
expect { Engine.new text_w_open_section }.to raise_error(exc, msg)
|
226
224
|
end
|
227
225
|
|
228
226
|
it 'should complain when a closing tag has no corresponding opening tag' do
|
229
227
|
# Replacing an end of section tag by another...
|
230
228
|
text_w_wrong_end = sophisticated_template.sub(%r{</address>}, '</foobar>')
|
231
|
-
|
229
|
+
exc = StandardError
|
232
230
|
msg = "End of section</foobar> doesn't match current section 'address'."
|
233
|
-
expect { Engine.new text_w_wrong_end }.to raise_error(
|
234
|
-
StandardError, msg)
|
231
|
+
expect { Engine.new text_w_wrong_end }.to raise_error(exc, msg)
|
235
232
|
end
|
236
233
|
|
237
234
|
it 'should complain when a closing tag is found without opening tag' do
|
@@ -1,32 +1,31 @@
|
|
1
|
-
# File: eo-line_spec.rb
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
module
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
end #
|
29
|
-
end # module
|
30
|
-
|
31
|
-
|
32
|
-
# End of file
|
1
|
+
# File: eo-line_spec.rb
|
2
|
+
require_relative '../../spec_helper'
|
3
|
+
|
4
|
+
# Load the classes under test
|
5
|
+
require_relative '../../../lib/macros4cuke/templating/eo-line'
|
6
|
+
|
7
|
+
module Macros4Cuke
|
8
|
+
module Templating # Open this namespace to get rid of module qualifier prefixes
|
9
|
+
describe EOLine do
|
10
|
+
subject { EOLine.new }
|
11
|
+
|
12
|
+
context 'Creation and initialization:' do
|
13
|
+
it 'should be created without argument' do
|
14
|
+
expect { EOLine.new }.not_to raise_error
|
15
|
+
end
|
16
|
+
end # context
|
17
|
+
|
18
|
+
context 'Provided services:' do
|
19
|
+
it 'should render a new line' do
|
20
|
+
context = double('fake_context')
|
21
|
+
locals = double('fake_locals')
|
22
|
+
|
23
|
+
expect(subject.render(context, locals)).to eq("\n")
|
24
|
+
end
|
25
|
+
|
26
|
+
end # context
|
27
|
+
end # describe
|
28
|
+
end # module
|
29
|
+
end # module
|
30
|
+
|
31
|
+
# End of file
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# File: placeholder_spec.rb
|
2
|
-
|
3
2
|
require_relative '../../spec_helper'
|
4
3
|
|
5
4
|
# Load the classes under test
|
@@ -33,7 +32,7 @@ describe Placeholder do
|
|
33
32
|
|
34
33
|
# Case: context object has a nil value associated to 'foobar'
|
35
34
|
context = Object.new
|
36
|
-
def context.foobar
|
35
|
+
def context.foobar # Add singleton method foobar that returns nil
|
37
36
|
nil
|
38
37
|
end
|
39
38
|
rendered_text = subject.render(context, {})
|
@@ -1,5 +1,4 @@
|
|
1
1
|
# File: section_spec.rb
|
2
|
-
|
3
2
|
require_relative '../../spec_helper'
|
4
3
|
require_relative '../../../lib/macros4cuke/templating/template-element'
|
5
4
|
require_relative '../../../lib/macros4cuke/templating/placeholder'
|
@@ -17,7 +16,8 @@ describe Section do
|
|
17
16
|
|
18
17
|
# Return a list of possible child elements
|
19
18
|
let(:sample_children) do
|
20
|
-
[
|
19
|
+
[
|
20
|
+
StaticText.new('Hello '),
|
21
21
|
Placeholder.new('user'),
|
22
22
|
EOLine.new
|
23
23
|
]
|
@@ -54,7 +54,8 @@ describe Section do
|
|
54
54
|
|
55
55
|
# Case: at least one child is a group
|
56
56
|
parent = Section.new('son')
|
57
|
-
[
|
57
|
+
[
|
58
|
+
subject,
|
58
59
|
Comment.new('# Simple step'),
|
59
60
|
EOLine.new,
|
60
61
|
StaticText.new('Bye '),
|
@@ -67,9 +68,10 @@ describe Section do
|
|
67
68
|
|
68
69
|
|
69
70
|
it 'should expect that its subclasses render the children' do
|
70
|
-
|
71
|
-
|
72
|
-
|
71
|
+
exc = NotImplementedError
|
72
|
+
err_msg = 'Method Section.render must be implemented in subclass.'
|
73
|
+
obj = Object.new
|
74
|
+
expect { subject.send(:render, obj, {}) }.to raise_error(exc, err_msg)
|
73
75
|
end
|
74
76
|
end # context
|
75
77
|
end # describe
|
@@ -95,7 +97,8 @@ describe ConditionalSection do
|
|
95
97
|
context 'Provided services:' do
|
96
98
|
# Return a list of possible child elements
|
97
99
|
let(:sample_children) do
|
98
|
-
[
|
100
|
+
[
|
101
|
+
StaticText.new('Hello '),
|
99
102
|
Placeholder.new('user'),
|
100
103
|
EOLine.new
|
101
104
|
]
|
@@ -1,39 +1,38 @@
|
|
1
|
-
# File: placeholder_spec.rb
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
module
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
end #
|
36
|
-
end # module
|
37
|
-
|
38
|
-
|
39
|
-
# End of file
|
1
|
+
# File: placeholder_spec.rb
|
2
|
+
require_relative '../../spec_helper'
|
3
|
+
|
4
|
+
# Load the classes under test
|
5
|
+
require_relative '../../../lib/macros4cuke/templating/static-text'
|
6
|
+
|
7
|
+
module Macros4Cuke
|
8
|
+
module Templating # Open this namespace to get rid of module qualifier prefixes
|
9
|
+
describe StaticText do
|
10
|
+
let(:sample_text) { 'Some text' }
|
11
|
+
|
12
|
+
subject { StaticText.new(sample_text) }
|
13
|
+
|
14
|
+
context 'Creation and initialization:' do
|
15
|
+
it 'should be created with a text' do
|
16
|
+
expect { StaticText.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 the source text as is' do
|
27
|
+
context = double('fake_context')
|
28
|
+
locals = double('fake_locals')
|
29
|
+
|
30
|
+
expect(subject.render(context, locals)).to eq(sample_text)
|
31
|
+
end
|
32
|
+
|
33
|
+
end # context
|
34
|
+
end # describe
|
35
|
+
end # module
|
36
|
+
end # module
|
37
|
+
|
38
|
+
# End of file
|
@@ -10,7 +10,7 @@ module Macros4Cuke # Open this namespace to avoid module qualifier prefixes
|
|
10
10
|
# a sample collection of macro-steps.
|
11
11
|
module UseSampleCollection
|
12
12
|
# Phrase of first macro-step in the collection.
|
13
|
-
SamplePhrase1 = 'enter my credentials as <userid>'
|
13
|
+
SamplePhrase1 = 'enter my credentials as <userid>'.freeze
|
14
14
|
|
15
15
|
# Sub-steps of the first macro-step in the collection.
|
16
16
|
SampleSubsteps1 = begin
|
@@ -26,7 +26,7 @@ SNIPPET
|
|
26
26
|
end
|
27
27
|
|
28
28
|
# Phrase of second macro-step in the collection.
|
29
|
-
SamplePhrase2 = 'fill in the form with'
|
29
|
+
SamplePhrase2 = 'fill in the form with'.freeze
|
30
30
|
|
31
31
|
# Sub-steps of the second macro-step in the collection.
|
32
32
|
SampleSubsteps2 = begin
|
@@ -58,7 +58,7 @@ SNIPPET
|
|
58
58
|
def fill_collection()
|
59
59
|
coll = MacroCollection.instance
|
60
60
|
|
61
|
-
coll.clear
|
61
|
+
coll.clear # Start from scratch: zap the existing macro-steps
|
62
62
|
|
63
63
|
coll.add_macro(SamplePhrase1, SampleSubsteps1, true)
|
64
64
|
coll.add_macro(SamplePhrase2, SampleSubsteps2, true)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: macros4cuke
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -30,14 +30,14 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 0.
|
33
|
+
version: 10.0.0
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 0.
|
40
|
+
version: 10.0.0
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: rspec
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.7.0
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.7.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubygems
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- LICENSE.txt
|
101
101
|
- README.md
|
102
102
|
- Rakefile
|
103
|
+
- appveyor.yml
|
103
104
|
- bin/macros4cuke
|
104
105
|
- cucumber.yml
|
105
106
|
- examples/demo/cucumber.yml
|
@@ -195,7 +196,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
195
196
|
requirements:
|
196
197
|
- - ">="
|
197
198
|
- !ruby/object:Gem::Version
|
198
|
-
version:
|
199
|
+
version: 2.0.0
|
199
200
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
201
|
requirements:
|
201
202
|
- - ">="
|
@@ -203,7 +204,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
204
|
version: '0'
|
204
205
|
requirements: []
|
205
206
|
rubyforge_project:
|
206
|
-
rubygems_version: 2.
|
207
|
+
rubygems_version: 2.6.7
|
207
208
|
signing_key:
|
208
209
|
specification_version: 4
|
209
210
|
summary: Add your own macro-steps to Cucumber scenarios
|