macros4cuke 0.4.09 → 0.5.03
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.
- checksums.yaml +8 -8
- data/.travis.yml +2 -2
- data/CHANGELOG.md +17 -0
- data/README.md +41 -22
- data/bin/macros4cuke +15 -0
- data/examples/demo/features/support/use_macros4cuke.rb +12 -0
- data/examples/i18n/fr/features/demo01-fr.feature +13 -0
- data/examples/i18n/fr/features/step_definitions/demo_steps.rb +5 -0
- data/examples/i18n/fr/features/step_definitions/{use_macro_steps.rb → macro_steps_fr.rb} +3 -2
- data/examples/i18n/fr/features/support/use_macros4cuke.rb +12 -0
- data/examples/i18n/nl/cucumber.yml +6 -0
- data/examples/i18n/nl/features/demo01-nl.feature +40 -0
- data/examples/i18n/nl/features/step_definitions/demo_steps.rb +21 -0
- data/examples/i18n/nl/features/step_definitions/macro_steps_nl.rb +31 -0
- data/examples/i18n/nl/features/support/use_macros4cuke.rb +12 -0
- data/features/support/use_macros4cuke.rb +11 -0
- data/lib/macros4cuke.rb +1 -0
- data/lib/macros4cuke/application.rb +75 -0
- data/lib/macros4cuke/cli/cmd-line.rb +142 -0
- data/lib/macros4cuke/constants.rb +2 -2
- data/lib/macros4cuke/cucumber.rb +16 -0
- data/lib/macros4cuke/exceptions.rb +25 -1
- data/lib/macros4cuke/templating/comment.rb +43 -0
- data/lib/macros4cuke/templating/eo-line.rb +30 -0
- data/lib/macros4cuke/templating/static-text.rb +40 -0
- data/lib/macros4cuke/templating/template-element.rb +7 -88
- data/spec/macros4cuke/application_spec.rb +117 -0
- data/spec/macros4cuke/cli/cmd-line_spec.rb +223 -0
- data/spec/macros4cuke/macro-collection_spec.rb +1 -1
- data/spec/macros4cuke/macro-step-support_spec.rb +1 -1
- data/spec/macros4cuke/templating/comment_spec.rb +1 -1
- data/spec/macros4cuke/templating/eo-line_spec.rb +2 -2
- data/spec/macros4cuke/templating/static_text_spec.rb +1 -1
- data/templates/use_macros4cuke.erb +12 -0
- metadata +35 -19
- data/examples/demo/features/step_definitions/use_macro_steps.rb +0 -10
- data/examples/demo/features/support/macro_support.rb +0 -16
- data/examples/i18n/fr/features/support/macro_support.rb +0 -17
- data/features/step_definitions/use_macro_steps.rb +0 -10
- data/features/support/macro_support.rb +0 -16
@@ -0,0 +1,223 @@
|
|
1
|
+
# File: cmd-line_spec.rb
|
2
|
+
|
3
|
+
require 'stringio'
|
4
|
+
require_relative '../../spec_helper'
|
5
|
+
|
6
|
+
require_relative '../../../lib/macros4cuke/exceptions'
|
7
|
+
|
8
|
+
# Load the class under test
|
9
|
+
require_relative '../../../lib/macros4cuke/cli/cmd-line'
|
10
|
+
|
11
|
+
module Macros4Cuke
|
12
|
+
|
13
|
+
module CLI
|
14
|
+
|
15
|
+
describe CmdLine do
|
16
|
+
before(:each) do
|
17
|
+
@current_wkdir = Dir.getwd
|
18
|
+
Dir.chdir(File.dirname(__FILE__))
|
19
|
+
end
|
20
|
+
|
21
|
+
after(:each) do
|
22
|
+
Dir.chdir(@current_wkdir)
|
23
|
+
end
|
24
|
+
|
25
|
+
def hijack_stdout()
|
26
|
+
@orig_stdout = $stdout
|
27
|
+
$stdout = StringIO.new('', 'w')
|
28
|
+
end
|
29
|
+
|
30
|
+
def restore_stdout()
|
31
|
+
$stdout = @orig_stdout
|
32
|
+
end
|
33
|
+
|
34
|
+
def hijack_stderr()
|
35
|
+
@orig_stderr = $stderr
|
36
|
+
$stderr = StringIO.new('', 'w')
|
37
|
+
end
|
38
|
+
|
39
|
+
def restore_stderr()
|
40
|
+
$stderr = @orig_stderr
|
41
|
+
end
|
42
|
+
|
43
|
+
def mk_subdir(relativePath)
|
44
|
+
subdir = File.dirname(__FILE__) + '/' + relativePath
|
45
|
+
Dir.mkdir(subdir)
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'Creation and initialization:' do
|
49
|
+
it 'should be created without argument' do
|
50
|
+
expect { CmdLine.new }.not_to raise_error
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should have an command-line parser' do
|
54
|
+
expect(subject.parser).to be_kind_of(OptionParser)
|
55
|
+
end
|
56
|
+
|
57
|
+
end # context
|
58
|
+
|
59
|
+
|
60
|
+
context 'Informative options:' do
|
61
|
+
|
62
|
+
it 'should provide short help when command-line is empty' do
|
63
|
+
hijack_stdout
|
64
|
+
short_help = <<-END_MESSAGE
|
65
|
+
For help about the command-line syntax, do:
|
66
|
+
macros4cuke --help
|
67
|
+
END_MESSAGE
|
68
|
+
|
69
|
+
# Application is stopped
|
70
|
+
expect { subject.parse!([]) }.to raise_error(SystemExit)
|
71
|
+
|
72
|
+
# Help text is displayed
|
73
|
+
expect($stdout.string).to eq(short_help)
|
74
|
+
restore_stdout
|
75
|
+
end
|
76
|
+
|
77
|
+
it 'should provide complete help when help requested' do
|
78
|
+
help_options = [ ['-h'], ['--help'] ]
|
79
|
+
help_text = subject.parser.help
|
80
|
+
|
81
|
+
help_options.each do |cmd_line|
|
82
|
+
hijack_stdout
|
83
|
+
# Application is stopped
|
84
|
+
expect { subject.parse!(cmd_line) }.to raise_error(SystemExit)
|
85
|
+
|
86
|
+
# Help text is displayed
|
87
|
+
expect($stdout.string).to eq(help_text)
|
88
|
+
restore_stdout
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should provide version when it is requested' do
|
93
|
+
version_options = [ ['-v'], ['--version'] ]
|
94
|
+
|
95
|
+
version_options.each do |cmd_line|
|
96
|
+
hijack_stdout
|
97
|
+
# Application is stopped
|
98
|
+
expect { subject.parse!(cmd_line) }.to raise_error(SystemExit)
|
99
|
+
|
100
|
+
# platform versions are displayed
|
101
|
+
|
102
|
+
expect($stdout.string).to eq(Macros4Cuke::Version + "\n")
|
103
|
+
restore_stdout
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
it 'should provide platform data when requested' do
|
108
|
+
verbose_version_options = [ ['-V'], ['--version-verbose'] ]
|
109
|
+
|
110
|
+
cuke = "Cucumber #{Cucumber::VERSION}"
|
111
|
+
ruby = "Ruby #{RUBY_VERSION} #{RUBY_PLATFORM}"
|
112
|
+
full_msg = "#{Macros4Cuke::Version} (using #{cuke}, running on #{ruby})"
|
113
|
+
|
114
|
+
verbose_version_options.each do |cmd_line|
|
115
|
+
hijack_stdout
|
116
|
+
# Application is stopped
|
117
|
+
expect { subject.parse!(cmd_line) }.to raise_error(SystemExit)
|
118
|
+
|
119
|
+
# Version number is displayed
|
120
|
+
expect($stdout.string).to eq(full_msg + "\n")
|
121
|
+
restore_stdout
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
end # context
|
126
|
+
|
127
|
+
context 'Error in command-line:' do
|
128
|
+
|
129
|
+
it 'should complain when detecting an unknown option' do
|
130
|
+
hijack_stderr
|
131
|
+
err_msg = "invalid option: --unknown\n"
|
132
|
+
|
133
|
+
# Application is stopped
|
134
|
+
expect { subject.parse!(['--unknown']) }.to raise_error(SystemExit)
|
135
|
+
|
136
|
+
# Error message text is displayed
|
137
|
+
expect($stderr.string).to eq(err_msg)
|
138
|
+
restore_stderr
|
139
|
+
end
|
140
|
+
|
141
|
+
it 'should complain when an option misses an argument' do
|
142
|
+
hijack_stderr
|
143
|
+
err_msg = <<-END_MESSAGE
|
144
|
+
No argument provided with command line option: --setup
|
145
|
+
END_MESSAGE
|
146
|
+
|
147
|
+
# Application is stopped
|
148
|
+
expect { subject.parse!(['--setup']) }.to raise_error(SystemExit)
|
149
|
+
|
150
|
+
# Error message text is displayed
|
151
|
+
expect($stderr.string).to eq(err_msg)
|
152
|
+
restore_stderr
|
153
|
+
end
|
154
|
+
|
155
|
+
it "should complain when project to setup does'nt exist" do
|
156
|
+
hijack_stderr
|
157
|
+
err_msg = <<-END_MESSAGE
|
158
|
+
Error in command-line:
|
159
|
+
Cannot find the directory 'not_a_dir'.
|
160
|
+
END_MESSAGE
|
161
|
+
|
162
|
+
# Application is stopped
|
163
|
+
args = %w(--setup not_a_dir)
|
164
|
+
expect { subject.parse!(args) }.to raise_error(SystemExit)
|
165
|
+
|
166
|
+
# Error message text is displayed
|
167
|
+
expect($stderr.string).to eq(err_msg)
|
168
|
+
restore_stderr
|
169
|
+
end
|
170
|
+
|
171
|
+
it "should complain when features dir does'nt exist" do
|
172
|
+
mk_subdir('test_dir')
|
173
|
+
|
174
|
+
hijack_stderr
|
175
|
+
err_msg = <<-END_MESSAGE
|
176
|
+
Error in command-line:
|
177
|
+
Cannot find the directory 'test_dir/features'.
|
178
|
+
END_MESSAGE
|
179
|
+
args = %w(--setup ./test_dir)
|
180
|
+
|
181
|
+
# Application is stopped
|
182
|
+
expect { subject.parse!(args) }.to raise_error(SystemExit)
|
183
|
+
|
184
|
+
# Error message text is displayed
|
185
|
+
expect($stderr.string).to eq(err_msg)
|
186
|
+
restore_stderr
|
187
|
+
|
188
|
+
mk_subdir('test_dir/features')
|
189
|
+
hijack_stderr
|
190
|
+
err_msg = <<-END_MESSAGE
|
191
|
+
Error in command-line:
|
192
|
+
Cannot find the directory 'test_dir/features/support'.
|
193
|
+
END_MESSAGE
|
194
|
+
|
195
|
+
# Application is stopped
|
196
|
+
expect { subject.parse!(args) }.to raise_error(SystemExit)
|
197
|
+
|
198
|
+
# Error message text is displayed
|
199
|
+
expect($stderr.string).to eq(err_msg)
|
200
|
+
restore_stderr
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should not complain when all dirs are present' do
|
204
|
+
mk_subdir('test_dir/features/support')
|
205
|
+
|
206
|
+
expected = { setup: [Pathname.getwd + 'test_dir/features/support'] }
|
207
|
+
expect(subject.parse!(%w(--setup ./test_dir))).to eq(expected)
|
208
|
+
|
209
|
+
file_path = expected[:setup].first
|
210
|
+
Dir.rmdir(file_path)
|
211
|
+
Dir.rmdir(file_path.parent)
|
212
|
+
Dir.rmdir(file_path.parent.parent)
|
213
|
+
end
|
214
|
+
|
215
|
+
end # context
|
216
|
+
|
217
|
+
end # describe
|
218
|
+
|
219
|
+
end # module
|
220
|
+
|
221
|
+
end # module
|
222
|
+
|
223
|
+
# End of file
|
@@ -42,7 +42,7 @@ SNIPPET
|
|
42
42
|
expect(singleton).to have(1).macro_steps
|
43
43
|
|
44
44
|
# Error case: inserting another macro with same phrase.
|
45
|
-
msg = "A macro-step with phrase '[enter my credentials]' already
|
45
|
+
msg = "A macro-step with phrase '[enter my credentials]' already exists."
|
46
46
|
expect { singleton.add_macro(*args) }.to raise_error(
|
47
47
|
Macros4Cuke::DuplicateMacroError, msg)
|
48
48
|
end
|
@@ -55,7 +55,7 @@ SNIPPET
|
|
55
55
|
it 'should complain when entering the same macro again' do
|
56
56
|
# Error case: trying to register another macro with same key/phrase.
|
57
57
|
error_type = Macros4Cuke::DuplicateMacroError
|
58
|
-
msg = "A macro-step with phrase 'enter the credentials' already
|
58
|
+
msg = "A macro-step with phrase 'enter the credentials' already exists."
|
59
59
|
expect { world.add_macro(phrase1, m1_substeps, true) }.to raise_error(
|
60
60
|
error_type, msg)
|
61
61
|
end
|
@@ -3,7 +3,7 @@
|
|
3
3
|
require_relative '../../spec_helper'
|
4
4
|
|
5
5
|
# Load the classes under test
|
6
|
-
require_relative '../../../lib/macros4cuke/templating/
|
6
|
+
require_relative '../../../lib/macros4cuke/templating/eo-line'
|
7
7
|
|
8
8
|
module Macros4Cuke
|
9
9
|
|
@@ -14,7 +14,7 @@ describe EOLine do
|
|
14
14
|
subject { EOLine.new }
|
15
15
|
|
16
16
|
context 'Creation and initialization:' do
|
17
|
-
it 'should be created
|
17
|
+
it 'should be created without argument' do
|
18
18
|
expect { EOLine.new }.not_to raise_error
|
19
19
|
end
|
20
20
|
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# File: <%=file_name%>.rb
|
2
|
+
# Generated with Macros4Cuke v. <%= prog_version%> on <%=Time.now.strftime('%F %T')%>
|
3
|
+
# Purpose: Instruct Cucumber to add the support for macros.
|
4
|
+
# This file is meant to be put next to the 'env.rb' file
|
5
|
+
# of your Cucumber project.
|
6
|
+
|
7
|
+
|
8
|
+
# Load modules, classes step definitions from macro4cuke gem.
|
9
|
+
require 'macros4cuke/cucumber'
|
10
|
+
|
11
|
+
# End of file
|
12
|
+
|
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.
|
4
|
+
version: 0.5.03
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -82,7 +82,8 @@ dependencies:
|
|
82
82
|
version: 2.0.0
|
83
83
|
description: Expand Cucumber with macro-steps.
|
84
84
|
email: famished.tiger@yahoo.com
|
85
|
-
executables:
|
85
|
+
executables:
|
86
|
+
- macros4cuke
|
86
87
|
extensions: []
|
87
88
|
extra_rdoc_files:
|
88
89
|
- README.md
|
@@ -100,10 +101,30 @@ files:
|
|
100
101
|
- CHANGELOG.md
|
101
102
|
- LICENSE.txt
|
102
103
|
- README.md
|
104
|
+
- examples/demo/cucumber.yml
|
105
|
+
- examples/demo/features/basic.feature
|
106
|
+
- examples/demo/features/multiline.feature
|
107
|
+
- examples/demo/features/step_definitions/step_defs.rb
|
108
|
+
- examples/demo/features/support/env.rb
|
109
|
+
- examples/demo/features/support/use_macros4cuke.rb
|
110
|
+
- examples/demo/features/table.feature
|
111
|
+
- examples/i18n/fr/cucumber.yml
|
112
|
+
- examples/i18n/fr/features/demo01-fr.feature
|
113
|
+
- examples/i18n/fr/features/step_definitions/demo_steps.rb
|
114
|
+
- examples/i18n/fr/features/step_definitions/macro_steps_fr.rb
|
115
|
+
- examples/i18n/fr/features/support/use_macros4cuke.rb
|
116
|
+
- examples/i18n/nl/cucumber.yml
|
117
|
+
- examples/i18n/nl/features/demo01-nl.feature
|
118
|
+
- examples/i18n/nl/features/step_definitions/demo_steps.rb
|
119
|
+
- examples/i18n/nl/features/step_definitions/macro_steps_nl.rb
|
120
|
+
- examples/i18n/nl/features/support/use_macros4cuke.rb
|
103
121
|
- lib/macros4cuke.rb
|
104
122
|
- lib/macro_steps.rb
|
123
|
+
- lib/macros4cuke/application.rb
|
124
|
+
- lib/macros4cuke/cli/cmd-line.rb
|
105
125
|
- lib/macros4cuke/coll-walker-factory.rb
|
106
126
|
- lib/macros4cuke/constants.rb
|
127
|
+
- lib/macros4cuke/cucumber.rb
|
107
128
|
- lib/macros4cuke/exceptions.rb
|
108
129
|
- lib/macros4cuke/formatter/all-notifications.rb
|
109
130
|
- lib/macros4cuke/formatter/to-gherkin.rb
|
@@ -113,24 +134,14 @@ files:
|
|
113
134
|
- lib/macros4cuke/macro-collection.rb
|
114
135
|
- lib/macros4cuke/macro-step-support.rb
|
115
136
|
- lib/macros4cuke/macro-step.rb
|
137
|
+
- lib/macros4cuke/templating/comment.rb
|
116
138
|
- lib/macros4cuke/templating/engine.rb
|
139
|
+
- lib/macros4cuke/templating/eo-line.rb
|
117
140
|
- lib/macros4cuke/templating/placeholder.rb
|
118
141
|
- lib/macros4cuke/templating/section.rb
|
142
|
+
- lib/macros4cuke/templating/static-text.rb
|
119
143
|
- lib/macros4cuke/templating/template-element.rb
|
120
144
|
- lib/macros4cuke/templating/unary-element.rb
|
121
|
-
- examples/demo/cucumber.yml
|
122
|
-
- examples/demo/features/basic.feature
|
123
|
-
- examples/demo/features/multiline.feature
|
124
|
-
- examples/demo/features/step_definitions/step_defs.rb
|
125
|
-
- examples/demo/features/step_definitions/use_macro_steps.rb
|
126
|
-
- examples/demo/features/support/env.rb
|
127
|
-
- examples/demo/features/support/macro_support.rb
|
128
|
-
- examples/demo/features/table.feature
|
129
|
-
- examples/i18n/fr/cucumber.yml
|
130
|
-
- examples/i18n/fr/features/demo01-fr.feature
|
131
|
-
- examples/i18n/fr/features/step_definitions/demo_steps.rb
|
132
|
-
- examples/i18n/fr/features/step_definitions/use_macro_steps.rb
|
133
|
-
- examples/i18n/fr/features/support/macro_support.rb
|
134
145
|
- features/1_the_basics/demo01.feature
|
135
146
|
- features/2_macros_with_arguments/demo02.feature
|
136
147
|
- features/2_macros_with_arguments/demo03.feature
|
@@ -144,9 +155,10 @@ files:
|
|
144
155
|
- features/3_macros_with_table_arguments/README.md
|
145
156
|
- features/README.md
|
146
157
|
- features/step_definitions/demo_steps.rb
|
147
|
-
- features/step_definitions/use_macro_steps.rb
|
148
158
|
- features/support/env.rb
|
149
|
-
- features/support/
|
159
|
+
- features/support/use_macros4cuke.rb
|
160
|
+
- spec/macros4cuke/application_spec.rb
|
161
|
+
- spec/macros4cuke/cli/cmd-line_spec.rb
|
150
162
|
- spec/macros4cuke/coll-walker-factory_spec.rb
|
151
163
|
- spec/macros4cuke/formatter/to-gherkin_spec.rb
|
152
164
|
- spec/macros4cuke/formatter/to-null_spec.rb
|
@@ -163,6 +175,8 @@ files:
|
|
163
175
|
- spec/macros4cuke/templating/static_text_spec.rb
|
164
176
|
- spec/macros4cuke/use-sample-collection.rb
|
165
177
|
- spec/spec_helper.rb
|
178
|
+
- templates/use_macros4cuke.erb
|
179
|
+
- bin/macros4cuke
|
166
180
|
homepage: https://github.com/famished-tiger/Macros4Cuke
|
167
181
|
licenses:
|
168
182
|
- MIT
|
@@ -195,8 +209,10 @@ rubyforge_project:
|
|
195
209
|
rubygems_version: 2.0.3
|
196
210
|
signing_key:
|
197
211
|
specification_version: 4
|
198
|
-
summary:
|
212
|
+
summary: Add your own macro-steps to Cucumber scenarios
|
199
213
|
test_files:
|
214
|
+
- spec/macros4cuke/application_spec.rb
|
215
|
+
- spec/macros4cuke/cli/cmd-line_spec.rb
|
200
216
|
- spec/macros4cuke/coll-walker-factory_spec.rb
|
201
217
|
- spec/macros4cuke/formatter/to-gherkin_spec.rb
|
202
218
|
- spec/macros4cuke/formatter/to-null_spec.rb
|
@@ -1,10 +0,0 @@
|
|
1
|
-
# File: use_macro_steps.rb
|
2
|
-
# Place a copy of this file in the feature/step_definitions folder
|
3
|
-
# of your own Cucumber-based project.
|
4
|
-
|
5
|
-
# The following require will load the step definitions from Macros4Cuke.
|
6
|
-
# This allows feature file authors to use macro steps
|
7
|
-
# in their Cucumber scenarios.
|
8
|
-
require 'macros4cuke/../macro_steps'
|
9
|
-
|
10
|
-
# End of file
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# File: macro_support.rb
|
2
|
-
# Purpose: Add the support for macros in Cucumber.
|
3
|
-
# This file is meant to be put next to the 'env.rb' file
|
4
|
-
# of your Cucumber project.
|
5
|
-
|
6
|
-
|
7
|
-
# Macros4Cuke step one: Load modules and classes from the gem.
|
8
|
-
require 'macros4cuke'
|
9
|
-
|
10
|
-
|
11
|
-
# Macros4Cuke step two: extend the world object with the mix-in module
|
12
|
-
# that adds the support for macros in Cucumber.
|
13
|
-
World(Macros4Cuke::MacroStepSupport)
|
14
|
-
|
15
|
-
|
16
|
-
# End of file
|
@@ -1,17 +0,0 @@
|
|
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 Cucumber 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
|
-
# End of file
|