macros4cuke 0.3.29 → 0.3.30

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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ### 0.3.30 / 2013-06-13
2
+ * [CHANGE] File `README.md`: Added section `A word on Step Argument Transforms`.
3
+ * [CHANGE] File `engine.rb`: Changed a few case statements in order to please Rubocop.
4
+ * [CHANGE] `engine_spec.rb`: A test assertion was missing in a test.
5
+ * [TESTED] Regression testing with Cucumber 1.3.2. Pass.
6
+
1
7
  ### 0.3.29 / 2013-06-05
2
8
  * [CHANGE] `MacroStep#validate_params` method: `Extract Method` Refactoring, resulting in new method `MacroStep#validate_row`.
3
9
  * [CHANGE] `README.md`: Few editorial changes. Added section `More resources`.
data/README.md CHANGED
@@ -410,6 +410,19 @@ text in an entry field may be noticeably different than skipping that same entry
410
410
  Think of specific UI-events that can trigger some special system response.
411
411
 
412
412
 
413
+ ## A word on Step Argument Transforms##
414
+ Cucumber provides a handy facility that helps to convert implicitly the values of step arguments.
415
+ A first description of this lesser-known functionality is available at
416
+ [Step Argument Transforms] (https://github.com/cucumber/cucumber/wiki/Step-Argument-Transforms).
417
+ Does Macros4Cuke provide such a facility for its own macro-step arguments?
418
+ The answer is no: if macro-steps had their own kind of transformations, then these would have interfere with the ones defined directly in Cucumber.
419
+ In fact, Cucumber will happily apply transformations on any step, including the macro definition steps and the
420
+ steps invoking macros. Stated otherwise, the rules pertaining the Step Argument Transforms work as usual. Or almost.
421
+ There is one very specific case where Cucumber behaves slightly differently: the transforms aren't applied when a sub-step is executed.
422
+ Internally, Macros4Cuke calls the `Cucumber::RbSupport::RbWorld::#steps` method that allows to run a Gherkin snippet (the substeps),
423
+ and it appears that this method does not trigger the transforms. In practice, this doesn't prevent the use of transforms together
424
+ with Macros4Cuke. In the vast majority of cases both will work fine as expected.
425
+
413
426
 
414
427
  ## FAQ ##
415
428
  __Q__: Can I define a macro in one scenario and invoke it in another scenario in the same feature file?
@@ -440,6 +453,7 @@ __Q__: Can I __invoke/call__ a macro-step in a `Background` or `Scenario Outline
440
453
  __A__: Yes. As a macro-step can be invoked multiple times.
441
454
 
442
455
 
456
+
443
457
  ## Changelog
444
458
 
445
459
  Macros4Cuke's changelog is available [here](CHANGELOG.md).
@@ -450,7 +464,7 @@ Macros4Cuke's changelog is available [here](CHANGELOG.md).
450
464
  - [**Report a bug**](https://github.com/famished-tiger/Macros4Cuke/issues)
451
465
 
452
466
 
453
- ## With great power comes great responsibility. ##
467
+ ### With great power comes great responsibility. ###
454
468
  _Stan Lee_
455
469
 
456
470
  Our experience is that macro-steps change deeply the way one designs and writes feature files.
@@ -4,7 +4,7 @@
4
4
 
5
5
  module Macros4Cuke # Module used as a namespace
6
6
  # The version number of the gem.
7
- Version = '0.3.29'
7
+ Version = '0.3.30'
8
8
 
9
9
  # Brief description of the gem.
10
10
  Description = 'Macros for Cucumber'
@@ -142,12 +142,12 @@ public
142
142
  def variables()
143
143
  all_vars = children.each_with_object([]) do |a_child, subResult|
144
144
  case a_child
145
- when Placeholder
146
- subResult << a_child.name
147
- when Section
148
- subResult.concat(a_child.variables)
149
- else
150
- # Do nothing
145
+ when Placeholder
146
+ subResult << a_child.name
147
+ when Section
148
+ subResult.concat(a_child.variables)
149
+ else
150
+ # Do nothing
151
151
  end
152
152
  end
153
153
 
@@ -277,14 +277,14 @@ public
277
277
  @variables ||= begin
278
278
  vars = @representation.each_with_object([]) do |element, subResult|
279
279
  case element
280
- when Placeholder
281
- subResult << element.name
282
-
283
- when Section
284
- subResult.concat(element.variables)
285
-
286
- else
287
- # Do nothing
280
+ when Placeholder
281
+ subResult << element.name
282
+
283
+ when Section
284
+ subResult.concat(element.variables)
285
+
286
+ else
287
+ # Do nothing
288
288
  end
289
289
  end
290
290
 
@@ -333,10 +333,8 @@ private
333
333
 
334
334
  no_escaped.each_char do |ch|
335
335
  case ch
336
- when '<'
337
- unbalance += 1
338
- when '>'
339
- unbalance -= 1
336
+ when '<' then unbalance += 1
337
+ when '>' then unbalance -= 1
340
338
  end
341
339
 
342
340
  raise StandardError, "Nested opening chevron '<'." if unbalance > 1
@@ -379,18 +377,18 @@ private
379
377
  section_item = nil
380
378
  line_to_squeeze = line_rep.all? do |item|
381
379
  case item
382
- when StaticText
383
- item.source =~ /\s+/
384
-
385
- when Section, SectionEndMarker
386
- if section_item.nil?
387
- section_item = item
388
- true
389
- else
390
- false
391
- end
380
+ when StaticText
381
+ item.source =~ /\s+/
382
+
383
+ when Section, SectionEndMarker
384
+ if section_item.nil?
385
+ section_item = item
386
+ true
392
387
  else
393
388
  false
389
+ end
390
+ else
391
+ false
394
392
  end
395
393
  end
396
394
  if line_to_squeeze && ! section_item.nil?
@@ -423,12 +421,9 @@ private
423
421
  (kind, text) = aCouple
424
422
 
425
423
  result = case kind
426
- when :static
427
- StaticText.new(text)
428
-
429
- when :dynamic
430
- parse_tag(text)
431
- end
424
+ when :static then StaticText.new(text)
425
+ when :dynamic then parse_tag(text)
426
+ end
432
427
 
433
428
  return result
434
429
  end
@@ -465,20 +460,19 @@ private
465
460
 
466
461
  compiled = flat_sequence.each_with_object([]) do |element, subResult|
467
462
  case element
468
- when Section
469
- open_sections << element
470
-
471
- when SectionEndMarker
472
- validate_section_end(element, open_sections)
473
- subResult << open_sections.pop()
474
-
463
+ when Section
464
+ open_sections << element
465
+
466
+ when SectionEndMarker
467
+ validate_section_end(element, open_sections)
468
+ subResult << open_sections.pop()
469
+
470
+ else
471
+ if open_sections.empty?
472
+ subResult << element
475
473
  else
476
- if open_sections.empty?
477
- subResult << element
478
- else
479
- open_sections.last.add_child(element)
480
- end
481
-
474
+ open_sections.last.add_child(element)
475
+ end
482
476
  end
483
477
  end
484
478
 
@@ -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(:phrase1) { 'enter the credentials' }
33
33
 
34
34
  let(:m1_substeps) do
35
35
  ssteps = <<-SNIPPET
@@ -44,13 +44,13 @@ SNIPPET
44
44
 
45
45
  context 'Defining macro(s):' do
46
46
  it 'should add valid new macro' do
47
- expect { world.add_macro m1_phrase, m1_substeps, true }.not_to raise_error
47
+ expect { world.add_macro phrase1, m1_substeps, true }.not_to raise_error
48
48
  end
49
49
 
50
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
- expect { world.add_macro(m1_phrase, m1_substeps, true) }.to raise_error(
53
+ expect { world.add_macro(phrase1, m1_substeps, true) }.to raise_error(
54
54
  Macros4Cuke::DuplicateMacroError, msg)
55
55
  end
56
56
 
@@ -251,7 +251,7 @@ SNIPPET
251
251
 
252
252
  it 'should know the variable(s) it contains' do
253
253
  # Case using the sample template
254
- subject.variables == [:userid, :password]
254
+ expect(subject.variables).to be == ['userid', 'password']
255
255
 
256
256
  # Case of an empty source template text
257
257
  instance = Engine.new ''
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.29
4
+ version: 0.3.30
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-06-05 00:00:00.000000000 Z
12
+ date: 2013-06-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: cucumber