macros4cuke 0.3.20 → 0.3.21

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.
data/.rubocop.yml CHANGED
@@ -17,9 +17,6 @@ MethodLength:
17
17
 
18
18
  SpaceInsideBrackets:
19
19
  Enabled: false
20
-
21
- StringLiterals:
22
- Enabled: false
23
20
 
24
21
  TrailingWhitespace:
25
22
  Enabled: false
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.3.20 / 2013-05-23
2
+ * [CHANGE] File `.rubocop.yml`: StringLiterals cop is now enabled.
3
+ * [CHANGE] Many file: replaced double quotes by single quotes in order to pass the StringLiterals Robocop rule.
4
+
1
5
  ## 0.3.20 / 2013-05-23
2
6
  * [CHANGE] File `.travis.yml`: Added more CI environments: ruby-head and jruby-head.
3
7
  * [CHANGE] File `Rakefile`: Added task to push gem to Rubygems.
@@ -17,7 +17,7 @@ end
17
17
  Quand(/^j(?:e |')\[([^\]]+)\]:$/) do |macro_phrase, table_argument|
18
18
  # Ensure that the second argument is of the correct type
19
19
  unless table_argument.kind_of?(Cucumber::Ast::Table)
20
- error_message = "This step must have a data table as an argument."
20
+ error_message = 'This step must have a data table as an argument.'
21
21
  raise Macros4Cuke::DataTableNotFound, error_message
22
22
  end
23
23
 
@@ -32,7 +32,7 @@ SNIPPET
32
32
  begin
33
33
  steps(wrong)
34
34
  rescue Macros4Cuke::DataTableNotFound => exc
35
- msg = "The step with phrase [fill in the form with]: requires a data table."
35
+ msg = 'The step with phrase [fill in the form with]: requires a data table.'
36
36
  exc.message.should == msg
37
37
  end
38
38
  end
@@ -4,10 +4,10 @@
4
4
 
5
5
  module Macros4Cuke # Module used as a namespace
6
6
  # The version number of the gem.
7
- Version = '0.3.20'
7
+ Version = '0.3.21'
8
8
 
9
9
  # Brief description of the gem.
10
- Description = "Macros for Cucumber"
10
+ Description = 'Macros for Cucumber'
11
11
 
12
12
  # Constant Macros4Cuke::RootDir contains the absolute path of Rodent's
13
13
  # root directory. Note: it also ends with a slash character.
@@ -3,7 +3,7 @@
3
3
  # Purpose: Implementation of the MacroCollection class.
4
4
 
5
5
  require 'singleton' # We'll use the Singleton design pattern for this class.
6
- require_relative "macro-step"
6
+ require_relative 'macro-step'
7
7
 
8
8
  module Macros4Cuke # Module used as a namespace
9
9
 
@@ -1,8 +1,8 @@
1
1
  # encoding: utf-8
2
2
  # File: macro-step-support.rb
3
3
 
4
- require_relative "exceptions"
5
- require_relative "macro-collection"
4
+ require_relative 'exceptions'
5
+ require_relative 'macro-collection'
6
6
 
7
7
  module Macros4Cuke # Module used as a namespace
8
8
 
@@ -102,7 +102,7 @@ public
102
102
 
103
103
  when Array
104
104
  # TODO: Move away from hard-coded separator.
105
- actual_value.join("<br/>")
105
+ actual_value.join('<br/>')
106
106
 
107
107
  when String
108
108
  actual_value
@@ -232,7 +232,7 @@ class Engine
232
232
  forbidden = ' !"#' + "$%&'()*+,-./:;<=>?[\\]^`{|}~"
233
233
  all_escaped = []
234
234
  forbidden.each_char() { |ch| all_escaped << Regexp.escape(ch) }
235
- pattern = all_escaped.join("|")
235
+ pattern = all_escaped.join('|')
236
236
  Regexp.new(pattern)
237
237
  end
238
238
 
@@ -324,10 +324,10 @@ private
324
324
  # Unsuccessful scanning: we typically have improperly balanced chevrons.
325
325
  # We will analyze the opening and closing chevrons...
326
326
  # First: replace escaped chevron(s)
327
- no_escaped = aTextLine.gsub(/\\[<>]/, "--")
328
-
327
+ no_escaped = aTextLine.gsub(/\\[<>]/, '--')
328
+
329
329
  # var. equals count_of(<) - count_of(>): can only be 0 or temporarily 1
330
- unbalance = 0
330
+ unbalance = 0
331
331
 
332
332
  no_escaped.each_char do |ch|
333
333
  case ch
@@ -12,14 +12,14 @@ describe MacroCollection do
12
12
 
13
13
  let(:singleton) { MacroCollection.instance() }
14
14
 
15
- context "Initialization:" do
16
- it "should be empty" do
15
+ context 'Initialization:' do
16
+ it 'should be empty' do
17
17
  singleton.macro_steps.should be_empty
18
18
  end
19
19
 
20
20
  end
21
21
 
22
- context "Provided services:" do
22
+ context 'Provided services:' do
23
23
  let(:sample_substeps) do
24
24
  snippet = <<-SNIPPET
25
25
  Given I landed in the homepage
@@ -32,8 +32,8 @@ SNIPPET
32
32
  snippet
33
33
  end
34
34
 
35
- it "should accept the addition of a new macro-step" do
36
- phrase = "[enter my credentials]"
35
+ it 'should accept the addition of a new macro-step' do
36
+ phrase = '[enter my credentials]'
37
37
  args = [phrase, sample_substeps, true]
38
38
  ->() { singleton.add_macro(*args)}.should_not raise_error
39
39
  singleton.should have(1).macro_steps
@@ -29,7 +29,7 @@ describe MacroStepSupport do
29
29
  # Rule to build a custom world object
30
30
  let(:world) { MyWorld.new }
31
31
 
32
- let(:m1_phrase) { "enter the credentials" }
32
+ let(:m1_phrase) { 'enter the credentials' }
33
33
 
34
34
  let(:m1_substeps) do
35
35
  ssteps = <<-SNIPPET
@@ -42,32 +42,32 @@ SNIPPET
42
42
  ssteps
43
43
  end
44
44
 
45
- context "Defining macro(s):" do
46
- it "should add valid new macro" do
45
+ context 'Defining macro(s):' do
46
+ it 'should add valid new macro' do
47
47
  ->(){ world.add_macro(m1_phrase, m1_substeps, true) }.should_not raise_error
48
48
  end
49
49
 
50
- it "should complain when entering the same macro again" do
50
+ it 'should complain when entering the same macro again' do
51
51
  # Error case: trying to register another macro with same key/phrase.
52
52
  msg = "A macro-step with phrase 'enter the credentials' already exist."
53
53
  -> { world.add_macro(m1_phrase, m1_substeps, true) }.should raise_error(
54
54
  Macros4Cuke::DuplicateMacroError, msg)
55
55
  end
56
56
 
57
- it "should complain macro uses no table and phrase is parameterless" do
57
+ it 'should complain macro uses no table and phrase is parameterless' do
58
58
  # Error case: substeps have arguments,
59
59
  # but the macro has no mechanism to pass the needed data.
60
- phrase = "fill in the credentials"
60
+ phrase = 'fill in the credentials'
61
61
  msg = "The sub-step argument 'userid' does not appear in the phrase."
62
62
  ->(){ world.add_macro(phrase, m1_substeps, false) }.should raise_error(
63
63
  Macros4Cuke::UnreachableSubstepArgument, msg)
64
64
  end
65
65
  end # context
66
66
 
67
- context "Invoking macro(s):" do
67
+ context 'Invoking macro(s):' do
68
68
 
69
- it "should complain when invoking an unknown macro-step" do
70
- phrase_unknown = "dream of a perfect world"
69
+ it 'should complain when invoking an unknown macro-step' do
70
+ phrase_unknown = 'dream of a perfect world'
71
71
  msg = "Unknown macro-step with phrase: 'dream of a perfect world'."
72
72
  ->(){ world.invoke_macro(phrase_unknown) }.should raise_error(
73
73
  Macros4Cuke::UnknownMacroError, msg)
@@ -75,9 +75,9 @@ SNIPPET
75
75
 
76
76
  end # context
77
77
 
78
- context "Clearing macro(s):" do
78
+ context 'Clearing macro(s):' do
79
79
 
80
- it "should clear all macros" do
80
+ it 'should clear all macros' do
81
81
  ->(){ world.clear_macros() }.should_not raise_error
82
82
 
83
83
  # Control the post-condition
@@ -10,7 +10,7 @@ require_relative '../../lib/macros4cuke/macro-step' # The class under test
10
10
  module Macros4Cuke # Open the module to avoid lengthy qualified names
11
11
 
12
12
  describe MacroStep do
13
- let(:sample_phrase) { "enter my credentials as <userid>" }
13
+ let(:sample_phrase) { 'enter my credentials as <userid>' }
14
14
 
15
15
  let(:sample_template) do
16
16
  snippet = <<-SNIPPET
@@ -28,47 +28,47 @@ end
28
28
  subject { MacroStep.new(sample_phrase, sample_template, true) }
29
29
 
30
30
 
31
- context "Creation & initialization" do
32
- it "should be created with a phrase, substeps and a table use indicator" do
31
+ context 'Creation & initialization:' do
32
+ it 'should be created with a phrase, substeps and a table use indicator' do
33
33
  ->(){ MacroStep.new(sample_phrase, sample_template, true) }.should_not raise_error
34
34
  end
35
35
 
36
36
 
37
- it "should complain when a sub-step argument can never be assigned a value via the phrase" do
37
+ it 'should complain when a sub-step argument can never be assigned a value via the phrase' do
38
38
  msg = "The sub-step argument 'password' does not appear in the phrase."
39
39
  ->(){ MacroStep.new(sample_phrase, sample_template, false) }.should raise_error(
40
40
  Macros4Cuke::UnreachableSubstepArgument, msg)
41
41
  end
42
42
 
43
43
 
44
- it "should complain when an argument in phrase never occurs in substeps" do
45
- phrase = "enter my credentials as <foobar>"
44
+ it 'should complain when an argument in phrase never occurs in substeps' do
45
+ phrase = 'enter my credentials as <foobar>'
46
46
  msg = "The phrase argument 'foobar' does not appear in a sub-step."
47
47
  ->(){ MacroStep.new(phrase, sample_template, true) }.should raise_error(
48
48
  Macros4Cuke::UselessPhraseArgument, msg)
49
49
  end
50
50
 
51
51
 
52
- it "should know its key" do
53
- subject.key.should == "enter_my_credentials_as_X_T"
52
+ it 'should know its key' do
53
+ subject.key.should == 'enter_my_credentials_as_X_T'
54
54
  end
55
55
 
56
- it "should know the tags(placeholders) from its phrase" do
56
+ it 'should know the tags(placeholders) from its phrase' do
57
57
  subject.phrase_args.should == %w[userid]
58
58
  end
59
59
 
60
- it "should know the tags(placeholders) from its phrase and template" do
60
+ it 'should know the tags(placeholders) from its phrase and template' do
61
61
  subject.args.should == %w[userid password]
62
62
  end
63
63
 
64
64
  end # context
65
65
 
66
66
 
67
- context "Provided services" do
67
+ context 'Provided services:' do
68
68
 
69
69
  let(:phrase_instance) { %Q|enter my credentials as "nobody"| }
70
70
 
71
- it "should render the substeps" do
71
+ it 'should render the substeps' do
72
72
  text = subject.expand(phrase_instance, [ %w(password no-secret) ])
73
73
  expectation = <<-SNIPPET
74
74
  Given I landed in the homepage
@@ -81,7 +81,7 @@ SNIPPET
81
81
  text.should == expectation
82
82
  end
83
83
 
84
- it "should render steps even when one argument has no actual value" do
84
+ it 'should render steps even when one argument has no actual value' do
85
85
  # Special case: password has no value...
86
86
  text = subject.expand(phrase_instance, [ ])
87
87
  expectation = <<-SNIPPET
@@ -95,7 +95,7 @@ SNIPPET
95
95
  text.should == expectation
96
96
  end
97
97
 
98
- it "should un-escape the double-quotes for phrase arguments" do
98
+ it 'should un-escape the double-quotes for phrase arguments' do
99
99
  specific_phrase = %q|enter my credentials as "quotable\""|
100
100
  text = subject.expand(specific_phrase, [ %w(password no-secret) ])
101
101
  expectation = <<-SNIPPET
@@ -110,7 +110,7 @@ SNIPPET
110
110
  end
111
111
 
112
112
 
113
- it "should complain when an unknown variable is used" do
113
+ it 'should complain when an unknown variable is used' do
114
114
  # Error case: there is no macro argument called <unknown>
115
115
  error_message = "Unknown macro-step argument 'unknown'."
116
116
  args = [ %w(unknown anything) ]
@@ -119,8 +119,8 @@ SNIPPET
119
119
  end
120
120
 
121
121
 
122
- it "should expand built-in variables" do
123
- phrase = "do nothing useful"
122
+ it 'should expand built-in variables' do
123
+ phrase = 'do nothing useful'
124
124
  substeps = <<-SNIPPET
125
125
  Given I travel through:
126
126
  <quotes>
@@ -48,19 +48,19 @@ SNIPPET
48
48
  subject { Engine.new sample_template }
49
49
 
50
50
 
51
- context "Class services" do
51
+ context 'Class services:' do
52
52
  # Helper method.
53
53
  # Remove enclosing chevrons <..> (if any)
54
54
  def strip_chevrons(aText)
55
55
  return aText.gsub(/^<|>$/, '')
56
56
  end
57
57
 
58
- it "should parse an empty text line" do
58
+ it 'should parse an empty text line' do
59
59
  # Expectation: result should be an empty array.
60
60
  Engine.parse('').should be_empty
61
61
  end
62
62
 
63
- it "should parse a text line without tag" do
63
+ it 'should parse a text line without tag' do
64
64
  sample_text = 'Mary has a little lamb'
65
65
  result = Engine.parse(sample_text)
66
66
 
@@ -70,7 +70,7 @@ SNIPPET
70
70
  result[0].should == [:static, sample_text]
71
71
  end
72
72
 
73
- it "should parse a text line that consists of just a tag" do
73
+ it 'should parse a text line that consists of just a tag' do
74
74
  sample_text = '<some_tag>'
75
75
  result = Engine.parse(sample_text)
76
76
 
@@ -80,7 +80,7 @@ SNIPPET
80
80
  result[0].should == [:dynamic, strip_chevrons(sample_text)]
81
81
  end
82
82
 
83
- it "should parse a text line with a tag at the start" do
83
+ it 'should parse a text line with a tag at the start' do
84
84
  sample_text = '<some_tag>some text'
85
85
  result = Engine.parse(sample_text)
86
86
 
@@ -91,7 +91,7 @@ SNIPPET
91
91
  result[1].should == [:static, 'some text']
92
92
  end
93
93
 
94
- it "should parse a text line with a tag at the end" do
94
+ it 'should parse a text line with a tag at the end' do
95
95
  sample_text = 'some text<some_tag>'
96
96
  result = Engine.parse(sample_text)
97
97
 
@@ -102,7 +102,7 @@ SNIPPET
102
102
  result[1].should == [:dynamic, 'some_tag']
103
103
  end
104
104
 
105
- it "should parse a text line with a tag in the middle" do
105
+ it 'should parse a text line with a tag in the middle' do
106
106
  sample_text = 'begin <some_tag> end'
107
107
  result = Engine.parse(sample_text)
108
108
 
@@ -113,7 +113,7 @@ SNIPPET
113
113
  result[2].should == [:static, ' end']
114
114
  end
115
115
 
116
- it "should parse a text line with two tags in the middle" do
116
+ it 'should parse a text line with two tags in the middle' do
117
117
  sample_text = 'begin <some_tag>middle<another_tag> end'
118
118
  result = Engine.parse(sample_text)
119
119
 
@@ -137,7 +137,7 @@ SNIPPET
137
137
  result[3].should == [:static, ' end']
138
138
  end
139
139
 
140
- it "should parse a text line with escaped chevrons" do
140
+ it 'should parse a text line with escaped chevrons' do
141
141
  sample_text = 'Mary has a \<little\> lamb'
142
142
  result = Engine.parse(sample_text)
143
143
 
@@ -146,7 +146,7 @@ SNIPPET
146
146
  result[0].should == [:static, sample_text]
147
147
  end
148
148
 
149
- it "should parse a text line with escaped chevrons in a tag" do
149
+ it 'should parse a text line with escaped chevrons in a tag' do
150
150
  sample_text = 'begin <some_\<\\>weird\>_tag> end'
151
151
  result = Engine.parse(sample_text)
152
152
 
@@ -157,21 +157,21 @@ SNIPPET
157
157
  result[2].should == [:static, ' end']
158
158
  end
159
159
 
160
- it "should complain if a tag misses an closing chevron" do
160
+ it 'should complain if a tag misses an closing chevron' do
161
161
  sample_text = 'begin <some_tag\> end'
162
162
  error_message = "Missing closing chevron '>'."
163
163
  ->(){ Engine.parse(sample_text) }.should raise_error(
164
164
  StandardError, error_message)
165
165
  end
166
166
 
167
- it "should complain if a text misses an opening chevron" do
167
+ it 'should complain if a text misses an opening chevron' do
168
168
  sample_text = 'begin <some_tag> > end'
169
169
  error_message = "Missing opening chevron '<'."
170
170
  ->(){ Engine.parse(sample_text) }.should raise_error(
171
171
  StandardError, error_message)
172
172
  end
173
173
 
174
- it "should complain if a text has nested opening chevrons" do
174
+ it 'should complain if a text has nested opening chevrons' do
175
175
  sample_text = 'begin <<some_tag> > end'
176
176
  error_message = "Nested opening chevron '<'."
177
177
  ->(){ Engine.parse(sample_text) }.should raise_error(
@@ -180,17 +180,17 @@ SNIPPET
180
180
 
181
181
  end # context
182
182
 
183
- context "Creation and initialization" do
183
+ context 'Creation and initialization:' do
184
184
 
185
- it "should accept an empty template text" do
185
+ it 'should accept an empty template text' do
186
186
  ->(){ Engine.new '' }.should_not raise_error
187
187
  end
188
188
 
189
- it "should be created with a template text" do
189
+ it 'should be created with a template text' do
190
190
  ->(){ Engine.new sample_template }.should_not raise_error
191
191
  end
192
192
 
193
- it "should know the source text" do
193
+ it 'should know the source text' do
194
194
  subject.source.should == sample_template
195
195
 
196
196
  # Case of an empty template
@@ -198,7 +198,7 @@ SNIPPET
198
198
  instance.source.should be_empty
199
199
  end
200
200
 
201
- it "should accept conditional section" do
201
+ it 'should accept conditional section' do
202
202
  ->(){ Engine.new sophisticated_template }.should_not raise_error
203
203
  instance = Engine.new sophisticated_template
204
204
  elements = instance.instance_variable_get(:@representation)
@@ -207,30 +207,30 @@ SNIPPET
207
207
  names.should == %w(<?address> <?birthdate> <?dummy>)
208
208
  end
209
209
 
210
- it "should complain when a placeholder is empty or blank" do
210
+ it 'should complain when a placeholder is empty or blank' do
211
211
  text_w_empty_arg = sample_template.sub(/userid/, '')
212
212
  msg = %q(An empty or blank argument occurred in 'And I fill in "Username" with "<>"'.)
213
213
  ->(){ Engine.new text_w_empty_arg }.should raise_error(
214
214
  Macros4Cuke::EmptyArgumentError, msg)
215
215
  end
216
216
 
217
- it "should complain when a placeholder contains an invalid character" do
217
+ it 'should complain when a placeholder contains an invalid character' do
218
218
  text_w_empty_arg = sample_template.sub(/userid/, 'user%id')
219
219
  msg = "The invalid sign '%' occurs in the argument 'user%id'."
220
220
  ->(){ Engine.new text_w_empty_arg }.should raise_error(
221
221
  Macros4Cuke::InvalidCharError, msg)
222
222
  end
223
223
 
224
- it "should complain when a section has no closing tag" do
224
+ it 'should complain when a section has no closing tag' do
225
225
  # Removing an end of section tag...
226
226
  text_w_open_section = sophisticated_template.sub(/<\/address>/, '')
227
227
 
228
- error_message = "Unterminated section <?address>."
228
+ error_message = 'Unterminated section <?address>.'
229
229
  ->(){ Engine.new text_w_open_section}.should raise_error(
230
230
  StandardError, error_message)
231
231
  end
232
232
 
233
- it "should complain when a closing tag has no corresponding opening tag" do
233
+ it 'should complain when a closing tag has no corresponding opening tag' do
234
234
  # Replacing an end of section tag by another...
235
235
  text_w_wrong_end = sophisticated_template.sub(/<\/address>/, '</foobar>')
236
236
 
@@ -239,18 +239,18 @@ SNIPPET
239
239
  StandardError, msg)
240
240
  end
241
241
 
242
- it "should complain when a closing tag is found without opening tag" do
242
+ it 'should complain when a closing tag is found without opening tag' do
243
243
  # Replacing an end of section tag by another...
244
244
  wrong_end = sophisticated_template.sub(/<\?birthdate>/, '</foobar>')
245
- msg = "End of section</foobar> found while no corresponding section is open."
245
+ msg = 'End of section</foobar> found while no corresponding section is open.'
246
246
  ->(){ Engine.new wrong_end }.should raise_error(StandardError, msg)
247
247
  end
248
248
 
249
249
  end # context
250
250
 
251
- context "Provided services" do
251
+ context 'Provided services:' do
252
252
 
253
- it "should know the variable(s) it contains" do
253
+ it 'should know the variable(s) it contains' do
254
254
  # Case using the sample template
255
255
  subject.variables == [:userid, :password]
256
256
 
@@ -260,7 +260,7 @@ SNIPPET
260
260
  end
261
261
 
262
262
 
263
- it "should ignore variables/placeholders in comments" do
263
+ it 'should ignore variables/placeholders in comments' do
264
264
  substeps = " # Comment 1 <miscellaneous>\n" + sample_template
265
265
  substeps += " #\n Comment 2 <haphazard>"
266
266
  instance = Engine.new substeps
@@ -268,8 +268,8 @@ SNIPPET
268
268
  end
269
269
 
270
270
 
271
- it "should render the text given the actuals" do
272
- locals = { 'userid' => "johndoe" }
271
+ it 'should render the text given the actuals' do
272
+ locals = { 'userid' => 'johndoe' }
273
273
 
274
274
  rendered_text = subject.render(Object.new, locals)
275
275
  expected = <<-SNIPPET
@@ -283,7 +283,7 @@ SNIPPET
283
283
  rendered_text.should == expected
284
284
 
285
285
  # Case of an actual that's not a String
286
- locals = { 'userid' => "johndoe", "password" => 12345 }
286
+ locals = { 'userid' => 'johndoe', 'password' => 12345 }
287
287
  rendered_text = subject.render(Object.new, locals)
288
288
  expected = <<-SNIPPET
289
289
  Given I landed in the homepage
@@ -298,7 +298,7 @@ SNIPPET
298
298
 
299
299
  # Place actual value in context object
300
300
  Context = Struct.new(:userid, :password)
301
- context = Context.new("sherlock", "holmes")
301
+ context = Context.new('sherlock', 'holmes')
302
302
  rendered_text = subject.render(context, { 'userid' => 'susan' })
303
303
  expected = <<-SNIPPET
304
304
  Given I landed in the homepage
@@ -317,12 +317,12 @@ SNIPPET
317
317
  end
318
318
 
319
319
 
320
- it "should render conditional sections" do
320
+ it 'should render conditional sections' do
321
321
  instance = Engine.new(sophisticated_template)
322
322
 
323
- locals = { 'firstname' => "Anon",
324
- "lastname" => "Eemoos" ,
325
- "birthdate" => "1976-04-21"
323
+ locals = { 'firstname' => 'Anon',
324
+ 'lastname' => 'Eemoos' ,
325
+ 'birthdate' => '1976-04-21'
326
326
  }
327
327
  rendered_text = instance.render(Object.new, locals)
328
328
  expected = <<-SNIPPET
@@ -335,8 +335,8 @@ SNIPPET
335
335
  rendered_text.should == expected
336
336
 
337
337
  # Redo with another context
338
- locals["birthdate"] = nil
339
- locals["address"] = "122, Mercer Street"
338
+ locals['birthdate'] = nil
339
+ locals['address'] = '122, Mercer Street'
340
340
 
341
341
  rendered_text = instance.render(Object.new, locals)
342
342
  expected = <<-SNIPPET
@@ -350,7 +350,7 @@ SNIPPET
350
350
  end
351
351
 
352
352
 
353
- it "should render multivalued actuals" do
353
+ it 'should render multivalued actuals' do
354
354
  locals = { 'userid' => %w(johndoe yeti) } # Silly case
355
355
 
356
356
  rendered_text = subject.render(Object.new, locals)
@@ -15,20 +15,20 @@ describe Placeholder do
15
15
  # Default instantiation rule
16
16
  subject { Placeholder.new('foobar') }
17
17
 
18
- context "Creation and initialization:" do
18
+ context 'Creation and initialization:' do
19
19
 
20
- it "should be created with a variable name" do
20
+ it 'should be created with a variable name' do
21
21
  ->() { Placeholder.new('foobar') }.should_not raise_error
22
22
  end
23
23
 
24
- it "should know the name of its variable" do
24
+ it 'should know the name of its variable' do
25
25
  subject.name.should == 'foobar'
26
26
  end
27
27
 
28
28
  end # context
29
29
 
30
- context "Provided services:" do
31
- it "should render an empty string when no actual value is absent" do
30
+ context 'Provided services:' do
31
+ it 'should render an empty string when no actual value is absent' do
32
32
  # Case: context has no value associated to 'foobar'
33
33
  rendered_text = subject.render(Object.new, {})
34
34
  rendered_text.should be_empty
@@ -41,12 +41,12 @@ describe Placeholder do
41
41
  context = Object.new
42
42
  def context.foobar # Add singleton method foobar that returns nil
43
43
  nil
44
- end
44
+ end
45
45
  rendered_text = subject.render(context, {})
46
46
  rendered_text.should be_empty
47
47
  end
48
48
 
49
- it "should render the actual value bound to the placeholder" do
49
+ it 'should render the actual value bound to the placeholder' do
50
50
  # Case: locals Hash has a value associated to 'foobar'
51
51
  rendered_text = subject.render(Object.new, { 'foobar' => 'hello' })
52
52
  rendered_text.should == 'hello'
@@ -17,30 +17,30 @@ describe Section do
17
17
 
18
18
  # Return a list of possible child elements
19
19
  let(:sample_children) do
20
- [ StaticText.new("Hello "),
21
- Placeholder.new("user"),
20
+ [ StaticText.new('Hello '),
21
+ Placeholder.new('user'),
22
22
  EOLine.new
23
23
  ]
24
24
  end
25
25
 
26
- context "Creation and initialization" do
26
+ context 'Creation and initialization' do
27
27
 
28
- it "should be created with a variable name" do
28
+ it 'should be created with a variable name' do
29
29
  ->() { Section.new('foobar') }.should_not raise_error
30
30
  end
31
31
 
32
- it "should know the name of its variable" do
32
+ it 'should know the name of its variable' do
33
33
  subject.name.should == 'foobar'
34
34
  end
35
35
 
36
- it "should have no child at start" do
36
+ it 'should have no child at start' do
37
37
  subject.should have(0).children
38
38
  end
39
39
 
40
40
  end # context
41
41
 
42
- context "Provided services:" do
43
- it "should add child element(s)" do
42
+ context 'Provided services:' do
43
+ it 'should add child element(s)' do
44
44
  sample_children.each do |a_child|
45
45
  subject.add_child(a_child)
46
46
  end
@@ -49,7 +49,7 @@ describe Section do
49
49
  subject.children.should == sample_children
50
50
  end
51
51
 
52
- it "should know the name all child placeholders" do
52
+ it 'should know the name all child placeholders' do
53
53
  # Case: simple flat list of children
54
54
  sample_children.each { |a_child| subject.add_child(a_child) }
55
55
  subject.variables.should == [ 'user' ]
@@ -57,8 +57,8 @@ describe Section do
57
57
  # Case: at least one child is a group
58
58
  parent = Section.new('son')
59
59
  [ subject,
60
- StaticText.new("Bye "),
61
- Placeholder.new("firstname"),
60
+ StaticText.new('Bye '),
61
+ Placeholder.new('firstname'),
62
62
  EOLine.new
63
63
  ].each { |a_child| parent.add_child(a_child) }
64
64
 
@@ -66,8 +66,8 @@ describe Section do
66
66
  end
67
67
 
68
68
 
69
- it "should expect that its subclasses render the children" do
70
- error_message = "Method Section.render must be implemented in subclass."
69
+ it 'should expect that its subclasses render the children' do
70
+ error_message = 'Method Section.render must be implemented in subclass.'
71
71
  ->(){ subject.send(:render, Object.new, {}) }.should raise_error(
72
72
  NotImplementedError, error_message)
73
73
  end
@@ -81,14 +81,14 @@ end # describe
81
81
 
82
82
  describe ConditionalSection do
83
83
 
84
- context "Creation and initialization:" do
84
+ context 'Creation and initialization:' do
85
85
 
86
- it "should be created with a variable name and a boolean" do
86
+ it 'should be created with a variable name and a boolean' do
87
87
  ->(){ ConditionalSection.new('foobar', false) }.should_not raise_error
88
88
  ->(){ ConditionalSection.new('foobar', true) }.should_not raise_error
89
89
  end
90
90
 
91
- it "should know whether the rendition on existence of actual value" do
91
+ it 'should know whether the rendition on existence of actual value' do
92
92
  [false, true].each do |existence|
93
93
  instance = ConditionalSection.new('foobar', existence)
94
94
  instance.existence.should == existence
@@ -97,11 +97,11 @@ describe ConditionalSection do
97
97
 
98
98
  end # context
99
99
 
100
- context "Provided services:" do
100
+ context 'Provided services:' do
101
101
  # Return a list of possible child elements
102
102
  let(:sample_children) do
103
- [ StaticText.new("Hello "),
104
- Placeholder.new("user"),
103
+ [ StaticText.new('Hello '),
104
+ Placeholder.new('user'),
105
105
  EOLine.new
106
106
  ]
107
107
  end
@@ -109,16 +109,16 @@ describe ConditionalSection do
109
109
  # Default instantiation rule
110
110
  subject { ConditionalSection.new('foobar', true) }
111
111
 
112
- it "should know its original source text" do
112
+ it 'should know its original source text' do
113
113
  subject.to_s.should == '<?foobar>'
114
114
  end
115
115
 
116
- it "should render its children when conditions are met" do
116
+ it 'should render its children when conditions are met' do
117
117
  # Adding the children
118
118
  sample_children.each { |a_child| subject.add_child(a_child) }
119
119
 
120
120
  # Case of an existing actual
121
- locals = { 'user' => "joe", "foobar" => 'exists' }
121
+ locals = { 'user' => 'joe', 'foobar' => 'exists' }
122
122
  rendered_text = subject.render(Object.new, locals)
123
123
  expected_text = "Hello joe\n"
124
124
  rendered_text.should == expected_text
@@ -129,7 +129,7 @@ describe ConditionalSection do
129
129
  sample_children.each { |a_child| instance.add_child(a_child) }
130
130
 
131
131
  # Case of a non-existing actual
132
- locals = { 'user' => "joe" }
132
+ locals = { 'user' => 'joe' }
133
133
  rendered_text = instance.render(Object.new, locals)
134
134
  rendered_text.should == expected_text
135
135
  end
@@ -139,9 +139,9 @@ describe ConditionalSection do
139
139
  sample_children.each { |a_child| subject.add_child(a_child) }
140
140
 
141
141
  # Case of a non-existing actual
142
- locals = { 'user' => "joe" }
142
+ locals = { 'user' => 'joe' }
143
143
  rendered_text = subject.render(Object.new, locals)
144
- rendered_text.should == ""
144
+ rendered_text.should == ''
145
145
 
146
146
  # Case of a conditional section that should be
147
147
  # rendering when value is non-existing.
@@ -149,9 +149,9 @@ describe ConditionalSection do
149
149
  sample_children.each { |a_child| instance.add_child(a_child) }
150
150
 
151
151
  # Case of a non-existing actual
152
- locals = { 'user' => "joe", "foobar" => 'exists' }
152
+ locals = { 'user' => 'joe', 'foobar' => 'exists' }
153
153
  rendered_text = instance.render(Object.new, locals)
154
- rendered_text.should == ""
154
+ rendered_text.should == ''
155
155
  end
156
156
 
157
157
  end # context
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: macros4cuke
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.20
4
+ version: 0.3.21
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-23 00:00:00.000000000 Z
12
+ date: 2013-05-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber