macros4cuke 0.3.23 → 0.3.24
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 +6 -0
- data/CHANGELOG.md +4 -0
- data/Rakefile +3 -3
- data/examples/demo/features/step_definitions/step_defs.rb +30 -30
- data/examples/demo/features/step_definitions/use_macro_steps.rb +10 -10
- data/examples/demo/features/support/env.rb +37 -37
- data/examples/demo/features/support/macro_support.rb +16 -16
- data/examples/i18n/fr/features/step_definitions/demo_steps.rb +13 -13
- data/examples/i18n/fr/features/step_definitions/use_macro_steps.rb +29 -29
- data/examples/i18n/fr/features/support/macro_support.rb +16 -16
- data/features/step_definitions/demo_steps.rb +40 -40
- data/features/step_definitions/use_macro_steps.rb +10 -10
- data/features/support/env.rb +45 -45
- data/features/support/macro_support.rb +16 -16
- data/lib/macros4cuke/constants.rb +1 -1
- data/lib/macros4cuke/macro-collection.rb +2 -0
- data/lib/macros4cuke/macro-step.rb +2 -2
- data/lib/macros4cuke/templating/engine.rb +2 -0
- data/spec/macros4cuke/macro-collection_spec.rb +1 -1
- data/spec/macros4cuke/templating/engine_spec.rb +1 -1
- metadata +2 -2
data/.rubocop.yml
CHANGED
@@ -1,3 +1,6 @@
|
|
1
|
+
AccessControl:
|
2
|
+
Enabled: false
|
3
|
+
|
1
4
|
# This is disabled because some demos use UTF-8
|
2
5
|
AsciiComments:
|
3
6
|
Enabled: false
|
@@ -5,6 +8,9 @@ AsciiComments:
|
|
5
8
|
CaseIndentation:
|
6
9
|
Enabled: false
|
7
10
|
|
11
|
+
ConstantName:
|
12
|
+
Enabled: false
|
13
|
+
|
8
14
|
DefWithParentheses:
|
9
15
|
Enabled: false
|
10
16
|
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## 0.3.24 / 2013-05-28
|
2
|
+
* [CHANGE] File `.rubocop.yml`: A few new Rubocop 0.8.0 checks are disabled.
|
3
|
+
* [CHANGE] Many source files refactored to satisfy new "cops" from Rubocop 0.8.0
|
4
|
+
|
1
5
|
## 0.3.23 / 2013-05-26
|
2
6
|
* [CHANGE] Demo file `table.feature`: Added one scenario combining argument passing via the phrase and table.
|
3
7
|
|
data/Rakefile
CHANGED
@@ -9,7 +9,7 @@ task :push do
|
|
9
9
|
system("gem push macros4cuke-#{Macros4Cuke::Version}.gem")
|
10
10
|
end
|
11
11
|
|
12
|
-
end
|
12
|
+
end # namespace
|
13
13
|
|
14
14
|
# Testing-specific tasks
|
15
15
|
|
@@ -20,13 +20,13 @@ end
|
|
20
20
|
|
21
21
|
# RSpec as testing tool
|
22
22
|
require 'rspec/core/rake_task'
|
23
|
-
desc
|
23
|
+
desc 'Run RSpec'
|
24
24
|
RSpec::Core::RakeTask.new do |spec|
|
25
25
|
spec.pattern = 'spec/**/*_spec.rb'
|
26
26
|
end
|
27
27
|
|
28
28
|
# Combine RSpec and Cucumber tests
|
29
|
-
desc
|
29
|
+
desc 'Run tests, with RSpec and Cucumber'
|
30
30
|
task :test => [:spec, :cucumber]
|
31
31
|
|
32
32
|
# Default rake task
|
@@ -1,31 +1,31 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# File: demo_steps.rb
|
3
|
-
# A few step definitions for demo and testing purpose.
|
4
|
-
|
5
|
-
When(/^I leave '(.*)'$/) do |city|
|
6
|
-
show "I leave #{city}"
|
7
|
-
end
|
8
|
-
|
9
|
-
|
10
|
-
When(/^I visit (\S+)$/) do |city|
|
11
|
-
show "I visit #{city}"
|
12
|
-
end
|
13
|
-
|
14
|
-
|
15
|
-
# This step uses a multiline text argument
|
16
|
-
When(/^I visit the cities:$/) do |cities_raw|
|
17
|
-
cities = cities_raw.split(/\r\n?|\n/)
|
18
|
-
cities.each { |city| show "I visit #{city}" }
|
19
|
-
end
|
20
|
-
|
21
|
-
|
22
|
-
When(/^I arrive in (.+)$/) do |city|
|
23
|
-
show "I arrive in #{city}"
|
24
|
-
end
|
25
|
-
|
26
|
-
|
27
|
-
When(/^I type \"([^"]*)\"$/) do |text|
|
28
|
-
show text
|
29
|
-
end
|
30
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# File: demo_steps.rb
|
3
|
+
# A few step definitions for demo and testing purpose.
|
4
|
+
|
5
|
+
When(/^I leave '(.*)'$/) do |city|
|
6
|
+
show "I leave #{city}"
|
7
|
+
end
|
8
|
+
|
9
|
+
|
10
|
+
When(/^I visit (\S+)$/) do |city|
|
11
|
+
show "I visit #{city}"
|
12
|
+
end
|
13
|
+
|
14
|
+
|
15
|
+
# This step uses a multiline text argument
|
16
|
+
When(/^I visit the cities:$/) do |cities_raw|
|
17
|
+
cities = cities_raw.split(/\r\n?|\n/)
|
18
|
+
cities.each { |city| show "I visit #{city}" }
|
19
|
+
end
|
20
|
+
|
21
|
+
|
22
|
+
When(/^I arrive in (.+)$/) do |city|
|
23
|
+
show "I arrive in #{city}"
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
When(/^I type \"([^"]*)\"$/) do |text|
|
28
|
+
show text
|
29
|
+
end
|
30
|
+
|
31
31
|
# End of file
|
@@ -1,11 +1,11 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# File: use_macro_steps.rb
|
3
|
-
# Place a copy of this file in the feature/step_definitions folder
|
4
|
-
# of your own Cucumber-based project.
|
5
|
-
|
6
|
-
# The following require will load the step definitions from Macros4Cuke.
|
7
|
-
# This allows feature file authors to use macro steps
|
8
|
-
# in their Cucumber scenarios.
|
9
|
-
require 'macros4cuke/../macro_steps'
|
10
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# File: use_macro_steps.rb
|
3
|
+
# Place a copy of this file in the feature/step_definitions folder
|
4
|
+
# of your own Cucumber-based project.
|
5
|
+
|
6
|
+
# The following require will load the step definitions from Macros4Cuke.
|
7
|
+
# This allows feature file authors to use macro steps
|
8
|
+
# in their Cucumber scenarios.
|
9
|
+
require 'macros4cuke/../macro_steps'
|
10
|
+
|
11
11
|
# End of file
|
@@ -1,38 +1,38 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# File: env.rb
|
3
|
-
|
4
|
-
|
5
|
-
module DemoMacros4Cuke # Use the module as a namespace
|
6
|
-
|
7
|
-
|
8
|
-
# Class created just for testing and demonstration purposes.
|
9
|
-
# Its instance, will record the output emitted by the steps.
|
10
|
-
class TracingWorld
|
11
|
-
# Will contain the text emitted by the steps
|
12
|
-
attr_reader(:trace_steps)
|
13
|
-
|
14
|
-
|
15
|
-
def initialize()
|
16
|
-
# Constructor
|
17
|
-
@trace_steps = []
|
18
|
-
end
|
19
|
-
|
20
|
-
public
|
21
|
-
# Write the given text to the error console
|
22
|
-
def show(someText)
|
23
|
-
# Replace every \" sequence by genuine "
|
24
|
-
unescaped = someText.gsub(/\\"/, '"')
|
25
|
-
$stderr.puts(unescaped)
|
26
|
-
end
|
27
|
-
|
28
|
-
|
29
|
-
end # class
|
30
|
-
|
31
|
-
end # module
|
32
|
-
|
33
|
-
# For testing purpose we override the default Cucumber behaviour
|
34
|
-
# making our world object an instance of the TracingWorld class
|
35
|
-
World { DemoMacros4Cuke::TracingWorld.new }
|
36
|
-
|
37
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# File: env.rb
|
3
|
+
|
4
|
+
|
5
|
+
module DemoMacros4Cuke # Use the module as a namespace
|
6
|
+
|
7
|
+
|
8
|
+
# Class created just for testing and demonstration purposes.
|
9
|
+
# Its instance, will record the output emitted by the steps.
|
10
|
+
class TracingWorld
|
11
|
+
# Will contain the text emitted by the steps
|
12
|
+
attr_reader(:trace_steps)
|
13
|
+
|
14
|
+
|
15
|
+
def initialize()
|
16
|
+
# Constructor
|
17
|
+
@trace_steps = []
|
18
|
+
end
|
19
|
+
|
20
|
+
public
|
21
|
+
# Write the given text to the error console
|
22
|
+
def show(someText)
|
23
|
+
# Replace every \" sequence by genuine "
|
24
|
+
unescaped = someText.gsub(/\\"/, '"')
|
25
|
+
$stderr.puts(unescaped)
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
end # class
|
30
|
+
|
31
|
+
end # module
|
32
|
+
|
33
|
+
# For testing purpose we override the default Cucumber behaviour
|
34
|
+
# making our world object an instance of the TracingWorld class
|
35
|
+
World { DemoMacros4Cuke::TracingWorld.new }
|
36
|
+
|
37
|
+
|
38
38
|
# End of file
|
@@ -1,17 +1,17 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# File: macro_support.rb
|
3
|
-
# Purpose: Add the support for macros in Cucumber.
|
4
|
-
# This file is meant to be put next to the 'env.rb' file
|
5
|
-
# of your Cucumeber project.
|
6
|
-
|
7
|
-
|
8
|
-
# Macros4Cuke step one: Load modules and classes from the gem.
|
9
|
-
require 'macros4cuke'
|
10
|
-
|
11
|
-
|
12
|
-
# Macros4Cuke step two: extend the world object with the mix-in module
|
13
|
-
# that adds the support for macros in Cucumber.
|
14
|
-
World(Macros4Cuke::MacroStepSupport)
|
15
|
-
|
16
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# File: macro_support.rb
|
3
|
+
# Purpose: Add the support for macros in Cucumber.
|
4
|
+
# This file is meant to be put next to the 'env.rb' file
|
5
|
+
# of your Cucumeber project.
|
6
|
+
|
7
|
+
|
8
|
+
# Macros4Cuke step one: Load modules and classes from the gem.
|
9
|
+
require 'macros4cuke'
|
10
|
+
|
11
|
+
|
12
|
+
# Macros4Cuke step two: extend the world object with the mix-in module
|
13
|
+
# that adds the support for macros in Cucumber.
|
14
|
+
World(Macros4Cuke::MacroStepSupport)
|
15
|
+
|
16
|
+
|
17
17
|
# End of file
|
@@ -1,14 +1,14 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# Quelques définitions de pas de scénarios Cucumber.
|
3
|
-
require 'stringio'
|
4
|
-
|
5
|
-
Quand(/^j'imprime "(.*?)" à l'écran$/) do |some_text|
|
6
|
-
$stderr.puts some_text
|
7
|
-
end
|
8
|
-
|
9
|
-
Quand(/^je garde "(.*?)" en mémoire$/) do |some_text|
|
10
|
-
@output ||= StringIO.new('')
|
11
|
-
@output.puts some_text
|
12
|
-
end
|
13
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# Quelques définitions de pas de scénarios Cucumber.
|
3
|
+
require 'stringio'
|
4
|
+
|
5
|
+
Quand(/^j'imprime "(.*?)" à l'écran$/) do |some_text|
|
6
|
+
$stderr.puts some_text
|
7
|
+
end
|
8
|
+
|
9
|
+
Quand(/^je garde "(.*?)" en mémoire$/) do |some_text|
|
10
|
+
@output ||= StringIO.new('')
|
11
|
+
@output.puts some_text
|
12
|
+
end
|
13
|
+
|
14
14
|
# End of file
|
@@ -1,30 +1,30 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# Définitions de pas de scénarios utilisant Macros4Cuke.
|
3
|
-
|
4
|
-
|
5
|
-
Etantdonné(/^que je crée le pas "(?:Soit|Quand|Alors) j(?:e |')\[((?:[^\\\]]|\\.)+)\](:?)" qui équivaut à:$/) do |macro_phrase, colon_capture, template|
|
6
|
-
use_table = (colon_capture == ':')
|
7
|
-
add_macro(macro_phrase, template, use_table)
|
8
|
-
end
|
9
|
-
|
10
|
-
|
11
|
-
Quand(/^j(?:e |')\[((?:[^\\\]]|\\.)+)\]$/) do |macro_phrase|
|
12
|
-
# This will call the macro with the given phrase
|
13
|
-
invoke_macro(macro_phrase)
|
14
|
-
end
|
15
|
-
|
16
|
-
|
17
|
-
Quand(/^j(?:e |')\[([^\]]+)\]:$/) do |macro_phrase, table_argument|
|
18
|
-
# Ensure that the second argument is of the correct type
|
19
|
-
unless table_argument.kind_of?(Cucumber::Ast::Table)
|
20
|
-
error_message = 'This step must have a data table as an argument.'
|
21
|
-
raise Macros4Cuke::DataTableNotFound, error_message
|
22
|
-
end
|
23
|
-
|
24
|
-
# This will call the macro with the given phrase.
|
25
|
-
# The second argument consists of an array with couples
|
26
|
-
# of the kind: [argument name, actual value]
|
27
|
-
invoke_macro(macro_phrase, table_argument.raw)
|
28
|
-
end
|
29
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# Définitions de pas de scénarios utilisant Macros4Cuke.
|
3
|
+
|
4
|
+
|
5
|
+
Etantdonné(/^que je crée le pas "(?:Soit|Quand|Alors) j(?:e |')\[((?:[^\\\]]|\\.)+)\](:?)" qui équivaut à:$/) do |macro_phrase, colon_capture, template|
|
6
|
+
use_table = (colon_capture == ':')
|
7
|
+
add_macro(macro_phrase, template, use_table)
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
Quand(/^j(?:e |')\[((?:[^\\\]]|\\.)+)\]$/) do |macro_phrase|
|
12
|
+
# This will call the macro with the given phrase
|
13
|
+
invoke_macro(macro_phrase)
|
14
|
+
end
|
15
|
+
|
16
|
+
|
17
|
+
Quand(/^j(?:e |')\[([^\]]+)\]:$/) do |macro_phrase, table_argument|
|
18
|
+
# Ensure that the second argument is of the correct type
|
19
|
+
unless table_argument.kind_of?(Cucumber::Ast::Table)
|
20
|
+
error_message = 'This step must have a data table as an argument.'
|
21
|
+
raise Macros4Cuke::DataTableNotFound, error_message
|
22
|
+
end
|
23
|
+
|
24
|
+
# This will call the macro with the given phrase.
|
25
|
+
# The second argument consists of an array with couples
|
26
|
+
# of the kind: [argument name, actual value]
|
27
|
+
invoke_macro(macro_phrase, table_argument.raw)
|
28
|
+
end
|
29
|
+
|
30
30
|
# End of file
|
@@ -1,17 +1,17 @@
|
|
1
|
-
# encoding: utf-8 You should see a paragraph character: §
|
2
|
-
# File: macro_support.rb
|
3
|
-
# Purpose: Add the support for macros in Cucumber.
|
4
|
-
# This file is meant to be put next to the 'env.rb' file
|
5
|
-
# of your Cucumeber project.
|
6
|
-
|
7
|
-
|
8
|
-
# Macros4Cuke step one: Load modules and classes from the gem.
|
9
|
-
require 'macros4cuke'
|
10
|
-
|
11
|
-
|
12
|
-
# Macros4Cuke step two: extend the world object with the mix-in module
|
13
|
-
# that adds the support for macros in Cucumber.
|
14
|
-
World(Macros4Cuke::MacroStepSupport)
|
15
|
-
|
16
|
-
|
1
|
+
# encoding: utf-8 You should see a paragraph character: §
|
2
|
+
# File: macro_support.rb
|
3
|
+
# Purpose: Add the support for macros in Cucumber.
|
4
|
+
# This file is meant to be put next to the 'env.rb' file
|
5
|
+
# of your Cucumeber project.
|
6
|
+
|
7
|
+
|
8
|
+
# Macros4Cuke step one: Load modules and classes from the gem.
|
9
|
+
require 'macros4cuke'
|
10
|
+
|
11
|
+
|
12
|
+
# Macros4Cuke step two: extend the world object with the mix-in module
|
13
|
+
# that adds the support for macros in Cucumber.
|
14
|
+
World(Macros4Cuke::MacroStepSupport)
|
15
|
+
|
16
|
+
|
17
17
|
# End of file
|
@@ -1,41 +1,41 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# File: demo_steps.rb
|
3
|
-
# A few step definitions for demo and testing purpose.
|
4
|
-
|
5
|
-
When(/^I landed in the homepage$/) do
|
6
|
-
trace_steps << 'Invoked step: ... I landed in the homepage'
|
7
|
-
end
|
8
|
-
|
9
|
-
When(/^I click "([^"]*)"$/) do |element|
|
10
|
-
trace_steps << "Invoked step: ... I click \"#{element}\""
|
11
|
-
end
|
12
|
-
|
13
|
-
|
14
|
-
When(/^I fill in "(.*?)" with "(.*?)"$/) do |element, text|
|
15
|
-
trace_steps << "Invoked step: ... I fill in \"#{element}\" with \"#{text}\""
|
16
|
-
end
|
17
|
-
|
18
|
-
|
19
|
-
Then(/^I expect the following step trace:$/) do |step_text|
|
20
|
-
trace_steps.should == step_text.split(/\r?\n|\n/)
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
# This step is used for testing a particular exception
|
25
|
-
When(/^I generate a DataTableNotFound exception$/) do
|
26
|
-
wrong = <<-SNIPPET
|
27
|
-
When I [fill in the form with]:
|
28
|
-
"""
|
29
|
-
Should be a table instead of triple quote string
|
30
|
-
"""
|
31
|
-
SNIPPET
|
32
|
-
begin
|
33
|
-
steps(wrong)
|
34
|
-
rescue Macros4Cuke::DataTableNotFound => exc
|
35
|
-
msg = 'The step with phrase [fill in the form with]: requires a data table.'
|
36
|
-
exc.message.should == msg
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# File: demo_steps.rb
|
3
|
+
# A few step definitions for demo and testing purpose.
|
4
|
+
|
5
|
+
When(/^I landed in the homepage$/) do
|
6
|
+
trace_steps << 'Invoked step: ... I landed in the homepage'
|
7
|
+
end
|
8
|
+
|
9
|
+
When(/^I click "([^"]*)"$/) do |element|
|
10
|
+
trace_steps << "Invoked step: ... I click \"#{element}\""
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
When(/^I fill in "(.*?)" with "(.*?)"$/) do |element, text|
|
15
|
+
trace_steps << "Invoked step: ... I fill in \"#{element}\" with \"#{text}\""
|
16
|
+
end
|
17
|
+
|
18
|
+
|
19
|
+
Then(/^I expect the following step trace:$/) do |step_text|
|
20
|
+
trace_steps.should == step_text.split(/\r?\n|\n/)
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# This step is used for testing a particular exception
|
25
|
+
When(/^I generate a DataTableNotFound exception$/) do
|
26
|
+
wrong = <<-SNIPPET
|
27
|
+
When I [fill in the form with]:
|
28
|
+
"""
|
29
|
+
Should be a table instead of triple quote string
|
30
|
+
"""
|
31
|
+
SNIPPET
|
32
|
+
begin
|
33
|
+
steps(wrong)
|
34
|
+
rescue Macros4Cuke::DataTableNotFound => exc
|
35
|
+
msg = 'The step with phrase [fill in the form with]: requires a data table.'
|
36
|
+
exc.message.should == msg
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
41
41
|
# End of file
|
@@ -1,11 +1,11 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# File: use_macro_steps.rb
|
3
|
-
# Place a copy of this file in the feature/step_definitions folder
|
4
|
-
# of your own Cucumber-based project.
|
5
|
-
|
6
|
-
# The following require will load the step definitions from Macros4Cuke.
|
7
|
-
# This allows feature file authors to use macro steps
|
8
|
-
# in their Cucumber scenarios.
|
9
|
-
require 'macros4cuke/../macro_steps'
|
10
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# File: use_macro_steps.rb
|
3
|
+
# Place a copy of this file in the feature/step_definitions folder
|
4
|
+
# of your own Cucumber-based project.
|
5
|
+
|
6
|
+
# The following require will load the step definitions from Macros4Cuke.
|
7
|
+
# This allows feature file authors to use macro steps
|
8
|
+
# in their Cucumber scenarios.
|
9
|
+
require 'macros4cuke/../macro_steps'
|
10
|
+
|
11
11
|
# End of file
|
data/features/support/env.rb
CHANGED
@@ -1,46 +1,46 @@
|
|
1
|
-
# encoding: utf-8 You should see a paragraph character: §
|
2
|
-
# File: env.rb
|
3
|
-
# Purpose: Allow Cucumber to load the sample application configuration
|
4
|
-
# and hooks.
|
5
|
-
# It also demonstrate what to do in your env.rb file
|
6
|
-
# to use the Macros4Cuke gem.
|
7
|
-
|
8
|
-
begin
|
9
|
-
require 'simplecov'
|
10
|
-
rescue LoadError
|
11
|
-
# Gobble silently the exception if simplecov isn't installed.
|
12
|
-
end
|
13
|
-
|
14
|
-
module DemoMacros4Cuke # Use the module as a namespace
|
15
|
-
|
16
|
-
|
17
|
-
# Class created just for testing and demonstration purposes.
|
18
|
-
# Its instance, will record the output emitted by the steps.
|
19
|
-
|
20
|
-
class TracingWorld
|
21
|
-
# Will contain the text emitted by the steps
|
22
|
-
attr_reader(:trace_steps)
|
23
|
-
|
24
|
-
|
25
|
-
def initialize()
|
26
|
-
# Constructor
|
27
|
-
@trace_steps = []
|
28
|
-
end
|
29
|
-
|
30
|
-
public
|
31
|
-
# Write the given text to the error console
|
32
|
-
|
33
|
-
def show(someText)
|
34
|
-
$stderr.puts(someText)
|
35
|
-
end
|
36
|
-
|
37
|
-
|
38
|
-
end # class
|
39
|
-
|
40
|
-
end # module
|
41
|
-
|
42
|
-
# For testing purpose we override the default Cucumber behaviour
|
43
|
-
# making our world object an instance of the TracingWorld class
|
44
|
-
World { DemoMacros4Cuke::TracingWorld.new }
|
45
|
-
|
1
|
+
# encoding: utf-8 You should see a paragraph character: §
|
2
|
+
# File: env.rb
|
3
|
+
# Purpose: Allow Cucumber to load the sample application configuration
|
4
|
+
# and hooks.
|
5
|
+
# It also demonstrate what to do in your env.rb file
|
6
|
+
# to use the Macros4Cuke gem.
|
7
|
+
|
8
|
+
begin
|
9
|
+
require 'simplecov'
|
10
|
+
rescue LoadError
|
11
|
+
# Gobble silently the exception if simplecov isn't installed.
|
12
|
+
end
|
13
|
+
|
14
|
+
module DemoMacros4Cuke # Use the module as a namespace
|
15
|
+
|
16
|
+
|
17
|
+
# Class created just for testing and demonstration purposes.
|
18
|
+
# Its instance, will record the output emitted by the steps.
|
19
|
+
|
20
|
+
class TracingWorld
|
21
|
+
# Will contain the text emitted by the steps
|
22
|
+
attr_reader(:trace_steps)
|
23
|
+
|
24
|
+
|
25
|
+
def initialize()
|
26
|
+
# Constructor
|
27
|
+
@trace_steps = []
|
28
|
+
end
|
29
|
+
|
30
|
+
public
|
31
|
+
# Write the given text to the error console
|
32
|
+
|
33
|
+
def show(someText)
|
34
|
+
$stderr.puts(someText)
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
end # class
|
39
|
+
|
40
|
+
end # module
|
41
|
+
|
42
|
+
# For testing purpose we override the default Cucumber behaviour
|
43
|
+
# making our world object an instance of the TracingWorld class
|
44
|
+
World { DemoMacros4Cuke::TracingWorld.new }
|
45
|
+
|
46
46
|
# End of file
|
@@ -1,17 +1,17 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# File: macro_support.rb
|
3
|
-
# Purpose: Add the support for macros in Cucumber.
|
4
|
-
# This file is meant to be put next to the 'env.rb' file
|
5
|
-
# of your Cucumeber project.
|
6
|
-
|
7
|
-
|
8
|
-
# Macros4Cuke step one: Load modules and classes from the gem.
|
9
|
-
require 'macros4cuke'
|
10
|
-
|
11
|
-
|
12
|
-
# Macros4Cuke step two: extend the world object with the mix-in module
|
13
|
-
# that adds the support for macros in Cucumber.
|
14
|
-
World(Macros4Cuke::MacroStepSupport)
|
15
|
-
|
16
|
-
|
1
|
+
# encoding: utf-8
|
2
|
+
# File: macro_support.rb
|
3
|
+
# Purpose: Add the support for macros in Cucumber.
|
4
|
+
# This file is meant to be put next to the 'env.rb' file
|
5
|
+
# of your Cucumeber project.
|
6
|
+
|
7
|
+
|
8
|
+
# Macros4Cuke step one: Load modules and classes from the gem.
|
9
|
+
require 'macros4cuke'
|
10
|
+
|
11
|
+
|
12
|
+
# Macros4Cuke step two: extend the world object with the mix-in module
|
13
|
+
# that adds the support for macros in Cucumber.
|
14
|
+
World(Macros4Cuke::MacroStepSupport)
|
15
|
+
|
16
|
+
|
17
17
|
# End of file
|
@@ -19,6 +19,7 @@ class MacroCollection
|
|
19
19
|
|
20
20
|
|
21
21
|
public
|
22
|
+
|
22
23
|
# Add a new macro.
|
23
24
|
# Pre-condition: there is no existing macro with the same key.
|
24
25
|
# @param aPhrase [String] The text that is enclosed between
|
@@ -71,6 +72,7 @@ public
|
|
71
72
|
end
|
72
73
|
|
73
74
|
private
|
75
|
+
|
74
76
|
# Retrieve the macro, given a phrase.
|
75
77
|
def find_macro(aMacroPhrase, useTable)
|
76
78
|
key = MacroStep.macro_key(aMacroPhrase, useTable, :invokation)
|
@@ -215,8 +215,8 @@ private
|
|
215
215
|
# and the macro-step does not use data table.
|
216
216
|
unless use_table?
|
217
217
|
substepsVars.each do |substep_arg|
|
218
|
-
unless
|
219
|
-
BuiltinParameters.include?(substep_arg)
|
218
|
+
unless thePhraseArgs.include?(substep_arg) ||
|
219
|
+
BuiltinParameters.include?(substep_arg)
|
220
220
|
raise UnreachableSubstepArgument.new(substep_arg)
|
221
221
|
end
|
222
222
|
end
|
@@ -65,6 +65,7 @@ class UnaryElement
|
|
65
65
|
end
|
66
66
|
|
67
67
|
protected
|
68
|
+
|
68
69
|
# This method has the same signature as the {Engine#render} method.
|
69
70
|
# @return [Object] The actual value from the locals or context
|
70
71
|
# that is assigned to the variable.
|
@@ -317,6 +318,7 @@ public
|
|
317
318
|
end
|
318
319
|
|
319
320
|
private
|
321
|
+
|
320
322
|
# Called when the given text line could not be parsed.
|
321
323
|
# Raises an exception with the syntax issue identified.
|
322
324
|
# @param aTextLine [String] A text line from the template.
|
@@ -35,7 +35,7 @@ SNIPPET
|
|
35
35
|
it 'should accept the addition of a new macro-step' do
|
36
36
|
phrase = '[enter my credentials]'
|
37
37
|
args = [phrase, sample_substeps, true]
|
38
|
-
->() { singleton.add_macro(*args)}.should_not raise_error
|
38
|
+
->() { singleton.add_macro(*args) }.should_not raise_error
|
39
39
|
singleton.should have(1).macro_steps
|
40
40
|
|
41
41
|
# Error case: inserting another macro with same phrase.
|
@@ -226,7 +226,7 @@ SNIPPET
|
|
226
226
|
text_w_open_section = sophisticated_template.sub(/<\/address>/, '')
|
227
227
|
|
228
228
|
error_message = 'Unterminated section <?address>.'
|
229
|
-
->(){ Engine.new text_w_open_section}.should raise_error(
|
229
|
+
->(){ Engine.new text_w_open_section }.should raise_error(
|
230
230
|
StandardError, error_message)
|
231
231
|
end
|
232
232
|
|
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.
|
4
|
+
version: 0.3.24
|
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-
|
12
|
+
date: 2013-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: cucumber
|