cukedep 0.1.11 → 0.2.00
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 +6 -14
- data/.ruby-version +1 -1
- data/.travis.yml +10 -10
- data/CHANGELOG.md +6 -0
- data/Gemfile +5 -5
- data/LICENSE.txt +1 -1
- data/README.md +1 -1
- data/Rakefile +30 -30
- data/bin/cukedep +15 -15
- data/lib/cukedep/application.rb +105 -112
- data/lib/cukedep/cli/cmd-line.rb +11 -13
- data/lib/cukedep/config.rb +85 -89
- data/lib/cukedep/constants.rb +5 -5
- data/lib/cukedep/cuke-runner.rb +191 -198
- data/lib/cukedep/customization.rb +30 -30
- data/lib/cukedep/feature-model.rb +43 -46
- data/lib/cukedep/feature-rep.rb +9 -11
- data/lib/cukedep/file-action.rb +11 -18
- data/lib/cukedep/gherkin-facade.rb +11 -6
- data/lib/cukedep/gherkin-listener.rb +12 -42
- data/lib/cukedep/hook-dsl.rb +78 -78
- data/lib/cukedep/sandbox.rb +15 -16
- data/lib/cukedep.rb +1 -2
- data/sample/features/step_definitions/steps.rb +2 -2
- data/sample/model/model.rb +19 -20
- data/spec/cukedep/application_spec.rb +80 -80
- data/spec/cukedep/cli/cmd-line_spec.rb +88 -88
- data/spec/cukedep/cuke-runner_spec.rb +74 -74
- data/spec/cukedep/customization_spec.rb +31 -31
- data/spec/cukedep/debug-file-action.rb +29 -29
- data/spec/cukedep/feature-model_spec.rb +100 -100
- data/spec/cukedep/feature-rep_spec.rb +2 -1
- data/spec/cukedep/file-action_spec.rb +365 -366
- data/spec/cukedep/file-parsing.rb +39 -41
- data/spec/cukedep/gherkin-facade_spec.rb +48 -49
- data/spec/cukedep/gherkin-listener_spec.rb +55 -57
- data/spec/cukedep/hook-dsl_spec.rb +182 -182
- data/spec/cukedep/sample_features/cukedep_hooks.rb +30 -30
- data/spec/cukedep/sample_features/standalone.feature +1 -1
- data/templates/rake.erb +12 -21
- metadata +80 -58
- data/sample/result.html +0 -472
- data/spec/cukedep/sample_features/cukedep.rake +0 -215
- data/spec/cukedep/sample_features/dependencies.dot +0 -38
- data/spec/cukedep/sample_features/feature2id.csv +0 -7
data/lib/cukedep/hook-dsl.rb
CHANGED
|
@@ -1,78 +1,78 @@
|
|
|
1
|
-
# File: hook-dsl.rb
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
module Cukedep # Module used as a namespace
|
|
5
|
-
# Mix-in module that defines the DSL (Domain-Specific Language)
|
|
6
|
-
# for specifying Cukedep hooks.
|
|
7
|
-
# A hook is a custom code block that is executed when
|
|
8
|
-
# a pre-defined Cukedep event occurs.
|
|
9
|
-
module HookDSL
|
|
10
|
-
ValidHookScopes = [
|
|
11
|
-
|
|
12
|
-
attr_reader(:before_hooks)
|
|
13
|
-
attr_reader(:after_hooks)
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# This method registers the code block to execute
|
|
17
|
-
# before a Cucumber invocation.
|
|
18
|
-
def before_cuke(aScope, &aBlock)
|
|
19
|
-
kind = :before
|
|
20
|
-
scope = validated_scope(kind, aScope)
|
|
21
|
-
register_hook(kind, scope, aBlock) if block_given?
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# This method registers the code block to execute
|
|
25
|
-
# before a Cucumber invocation.
|
|
26
|
-
def after_cuke(aScope, &aBlock)
|
|
27
|
-
kind = :after
|
|
28
|
-
scope = validated_scope(kind, aScope)
|
|
29
|
-
register_hook(kind, scope, aBlock) if block_given?
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
=begin
|
|
33
|
-
# Execute the specific hook.
|
|
34
|
-
def execute_hook(aKind, aScope)
|
|
35
|
-
scope = validated_scope(aKind, aScope)
|
|
36
|
-
case [aKind, scope]
|
|
37
|
-
when [:before, :all], [:before, :each], [:after, :each], [:after, :all]
|
|
38
|
-
handler = handler_for(aKind, scope)
|
|
39
|
-
else
|
|
40
|
-
raise StandardError, "Unknown Cukedep hook #{aKind}, #{aScope}"
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
handler.call unless handler.nil?
|
|
44
|
-
end
|
|
45
|
-
=end
|
|
46
|
-
|
|
47
|
-
private
|
|
48
|
-
|
|
49
|
-
def register_hook(aKind, aScope, aBlock)
|
|
50
|
-
scope = validated_scope(aKind, aScope)
|
|
51
|
-
|
|
52
|
-
ivar = "@#{aKind}_hooks".to_sym
|
|
53
|
-
instance_variable_set(ivar, {}) if instance_variable_get(ivar).nil?
|
|
54
|
-
instance_variable_get(ivar)[scope] = aBlock
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def validated_scope(aKind, aScope)
|
|
58
|
-
unless ValidHookScopes.include?(aScope)
|
|
59
|
-
msg = "Unknown scope '#{aScope}' for #{aKind}_cuke hook."
|
|
60
|
-
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
return aScope
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
def handler_for(aKind, aScope)
|
|
67
|
-
if aKind == :before
|
|
68
|
-
hooks = before_hooks
|
|
69
|
-
else
|
|
70
|
-
hooks = after_hooks
|
|
71
|
-
end
|
|
72
|
-
|
|
73
|
-
handler = hooks.nil? ? nil : hooks.fetch(aScope)
|
|
74
|
-
return handler
|
|
75
|
-
end
|
|
76
|
-
end # module
|
|
77
|
-
end # module
|
|
78
|
-
# End of file
|
|
1
|
+
# File: hook-dsl.rb
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module Cukedep # Module used as a namespace
|
|
5
|
+
# Mix-in module that defines the DSL (Domain-Specific Language)
|
|
6
|
+
# for specifying Cukedep hooks.
|
|
7
|
+
# A hook is a custom code block that is executed when
|
|
8
|
+
# a pre-defined Cukedep event occurs.
|
|
9
|
+
module HookDSL
|
|
10
|
+
ValidHookScopes = %i[all each].freeze
|
|
11
|
+
|
|
12
|
+
attr_reader(:before_hooks)
|
|
13
|
+
attr_reader(:after_hooks)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
# This method registers the code block to execute
|
|
17
|
+
# before a Cucumber invocation.
|
|
18
|
+
def before_cuke(aScope, &aBlock)
|
|
19
|
+
kind = :before
|
|
20
|
+
scope = validated_scope(kind, aScope)
|
|
21
|
+
register_hook(kind, scope, aBlock) if block_given?
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
# This method registers the code block to execute
|
|
25
|
+
# before a Cucumber invocation.
|
|
26
|
+
def after_cuke(aScope, &aBlock)
|
|
27
|
+
kind = :after
|
|
28
|
+
scope = validated_scope(kind, aScope)
|
|
29
|
+
register_hook(kind, scope, aBlock) if block_given?
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
=begin
|
|
33
|
+
# Execute the specific hook.
|
|
34
|
+
def execute_hook(aKind, aScope)
|
|
35
|
+
scope = validated_scope(aKind, aScope)
|
|
36
|
+
case [aKind, scope]
|
|
37
|
+
when [:before, :all], [:before, :each], [:after, :each], [:after, :all]
|
|
38
|
+
handler = handler_for(aKind, scope)
|
|
39
|
+
else
|
|
40
|
+
raise StandardError, "Unknown Cukedep hook #{aKind}, #{aScope}"
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
handler.call unless handler.nil?
|
|
44
|
+
end
|
|
45
|
+
=end
|
|
46
|
+
|
|
47
|
+
private
|
|
48
|
+
|
|
49
|
+
def register_hook(aKind, aScope, aBlock)
|
|
50
|
+
scope = validated_scope(aKind, aScope)
|
|
51
|
+
|
|
52
|
+
ivar = "@#{aKind}_hooks".to_sym
|
|
53
|
+
instance_variable_set(ivar, {}) if instance_variable_get(ivar).nil?
|
|
54
|
+
instance_variable_get(ivar)[scope] = aBlock
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def validated_scope(aKind, aScope)
|
|
58
|
+
unless ValidHookScopes.include?(aScope)
|
|
59
|
+
msg = "Unknown scope '#{aScope}' for #{aKind}_cuke hook."
|
|
60
|
+
raise StandardError, msg
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
return aScope
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
def handler_for(aKind, aScope)
|
|
67
|
+
if aKind == :before
|
|
68
|
+
hooks = before_hooks
|
|
69
|
+
else
|
|
70
|
+
hooks = after_hooks
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
handler = hooks.nil? ? nil : hooks.fetch(aScope)
|
|
74
|
+
return handler
|
|
75
|
+
end
|
|
76
|
+
end # module
|
|
77
|
+
end # module
|
|
78
|
+
# End of file
|
data/lib/cukedep/sandbox.rb
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
# File: sandbox.rb
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
attr_reader(:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
@
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
# End of file
|
|
1
|
+
# File: sandbox.rb
|
|
2
|
+
|
|
3
|
+
module Cukedep # This module is used as a namespace
|
|
4
|
+
# A context in which hook block codes are run.
|
|
5
|
+
class Sandbox
|
|
6
|
+
attr_reader(:base_dir)
|
|
7
|
+
attr_reader(:proj_dir)
|
|
8
|
+
|
|
9
|
+
def initialize(theBaseDir, theProjectDir)
|
|
10
|
+
@base_dir = theBaseDir.dup.freeze
|
|
11
|
+
@proj_dir = theProjectDir.dup.freeze
|
|
12
|
+
end
|
|
13
|
+
end # class
|
|
14
|
+
end # module
|
|
15
|
+
# End of file
|
data/lib/cukedep.rb
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
# File: cukedep.rb
|
|
2
|
-
# This file acts as a jumping-off point for loading dependencies expected
|
|
2
|
+
# This file acts as a jumping-off point for loading dependencies expected
|
|
3
3
|
# for a Cukedep user.
|
|
4
4
|
|
|
5
5
|
require_relative './cukedep/constants'
|
|
6
6
|
require_relative './cukedep/application'
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
# End of file
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# File: steps.rb
|
|
2
2
|
# Step definitions for a sample Cucumber application
|
|
3
3
|
|
|
4
|
-
def store
|
|
4
|
+
def store
|
|
5
5
|
$store
|
|
6
6
|
end
|
|
7
7
|
|
|
@@ -30,7 +30,7 @@ When(/^I remove the video "(.*?)"$/) do |a_title|
|
|
|
30
30
|
end
|
|
31
31
|
|
|
32
32
|
Given(/^there is no member yet$/) do
|
|
33
|
-
store.send(:zap_members!)
|
|
33
|
+
store.send(:zap_members!) # Why is this method seen as private?
|
|
34
34
|
end
|
|
35
35
|
|
|
36
36
|
Then(/^I should see member "(.*?)" as unknown$/) do |member_name|
|
data/sample/model/model.rb
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# File: model.rb
|
|
2
2
|
|
|
3
3
|
require 'pp'
|
|
4
|
-
require 'yaml'
|
|
4
|
+
require 'yaml' # Rely on YAML for object persistence
|
|
5
5
|
|
|
6
6
|
|
|
7
7
|
# Module used as a namespace
|
|
@@ -22,7 +22,7 @@ module Sample
|
|
|
22
22
|
# In our sample model, no rental history is performed
|
|
23
23
|
Rental = Struct.new(
|
|
24
24
|
:video, # Use the title of the rented video as key
|
|
25
|
-
:member
|
|
25
|
+
:member # Use the name of the Member as key
|
|
26
26
|
)
|
|
27
27
|
|
|
28
28
|
# The identification of a store rental employee
|
|
@@ -34,10 +34,10 @@ module Sample
|
|
|
34
34
|
# Simplistic domain model of a video rental store.
|
|
35
35
|
class RentalStore
|
|
36
36
|
MyDir = File.dirname(__FILE__) + '/'
|
|
37
|
-
CatalogueFile = 'catalogue.yml'
|
|
38
|
-
MembersFile = 'members.yml'
|
|
39
|
-
RentalsFile = 'rentals.yml'
|
|
40
|
-
UsersFile = 'users.yml'
|
|
37
|
+
CatalogueFile = 'catalogue.yml'.freeze
|
|
38
|
+
MembersFile = 'members.yml'.freeze
|
|
39
|
+
RentalsFile = 'rentals.yml'.freeze
|
|
40
|
+
UsersFile = 'users.yml'.freeze
|
|
41
41
|
|
|
42
42
|
|
|
43
43
|
# The list of all videos owned by the store.
|
|
@@ -52,28 +52,27 @@ module Sample
|
|
|
52
52
|
# The list of application user (credentials)
|
|
53
53
|
attr_reader(:users)
|
|
54
54
|
|
|
55
|
-
def initialize
|
|
55
|
+
def initialize
|
|
56
56
|
init_catalogue
|
|
57
57
|
init_members
|
|
58
58
|
init_rentals
|
|
59
59
|
init_users
|
|
60
60
|
end
|
|
61
61
|
|
|
62
|
-
|
|
63
62
|
# Clear the catalogue (= make it empty).
|
|
64
|
-
def zap_catalogue!
|
|
63
|
+
def zap_catalogue!
|
|
65
64
|
catalogue.clear
|
|
66
65
|
save_catalogue
|
|
67
66
|
zap_rentals!
|
|
68
67
|
end
|
|
69
68
|
|
|
70
|
-
def zap_members!
|
|
69
|
+
def zap_members!
|
|
71
70
|
members.clear
|
|
72
71
|
save_members
|
|
73
72
|
zap_rentals!
|
|
74
73
|
end
|
|
75
74
|
|
|
76
|
-
def zap_users!
|
|
75
|
+
def zap_users!
|
|
77
76
|
users.clear
|
|
78
77
|
save_users
|
|
79
78
|
end
|
|
@@ -143,7 +142,7 @@ module Sample
|
|
|
143
142
|
|
|
144
143
|
private
|
|
145
144
|
|
|
146
|
-
def init_catalogue
|
|
145
|
+
def init_catalogue
|
|
147
146
|
filepath = MyDir + CatalogueFile
|
|
148
147
|
if File.exist?(filepath)
|
|
149
148
|
@catalogue = YAML.load_file(filepath)
|
|
@@ -152,7 +151,7 @@ module Sample
|
|
|
152
151
|
end
|
|
153
152
|
end
|
|
154
153
|
|
|
155
|
-
def init_members
|
|
154
|
+
def init_members
|
|
156
155
|
filepath = MyDir + MembersFile
|
|
157
156
|
if File.exist?(filepath)
|
|
158
157
|
@members = YAML.load_file(filepath)
|
|
@@ -161,7 +160,7 @@ module Sample
|
|
|
161
160
|
end
|
|
162
161
|
end
|
|
163
162
|
|
|
164
|
-
def init_users
|
|
163
|
+
def init_users
|
|
165
164
|
filepath = MyDir + UsersFile
|
|
166
165
|
if File.exist?(filepath)
|
|
167
166
|
@users = YAML.load_file(filepath)
|
|
@@ -170,7 +169,7 @@ module Sample
|
|
|
170
169
|
end
|
|
171
170
|
end
|
|
172
171
|
|
|
173
|
-
def init_rentals
|
|
172
|
+
def init_rentals
|
|
174
173
|
filepath = MyDir + RentalsFile
|
|
175
174
|
if File.exist?(filepath)
|
|
176
175
|
@rentals = YAML.load_file(filepath)
|
|
@@ -179,27 +178,27 @@ module Sample
|
|
|
179
178
|
end
|
|
180
179
|
end
|
|
181
180
|
|
|
182
|
-
def zap_rentals!
|
|
181
|
+
def zap_rentals!
|
|
183
182
|
rentals.clear
|
|
184
183
|
save_rentals
|
|
185
184
|
end
|
|
186
185
|
|
|
187
|
-
def save_catalogue
|
|
186
|
+
def save_catalogue
|
|
188
187
|
filepath = MyDir + CatalogueFile
|
|
189
188
|
File.open(filepath, 'w') { |f| YAML.dump(catalogue, f) }
|
|
190
189
|
end
|
|
191
190
|
|
|
192
|
-
def save_members
|
|
191
|
+
def save_members
|
|
193
192
|
filepath = MyDir + MembersFile
|
|
194
193
|
File.open(filepath, 'w') { |f| YAML.dump(members, f) }
|
|
195
194
|
end
|
|
196
195
|
|
|
197
|
-
def save_users
|
|
196
|
+
def save_users
|
|
198
197
|
filepath = MyDir + UsersFile
|
|
199
198
|
File.open(filepath, 'w') { |f| YAML.dump(users, f) }
|
|
200
199
|
end
|
|
201
200
|
|
|
202
|
-
def save_rentals
|
|
201
|
+
def save_rentals
|
|
203
202
|
filepath = MyDir + RentalsFile
|
|
204
203
|
File.open(filepath, 'w') { |f| YAML.dump(rentals, f) }
|
|
205
204
|
end
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
# File: cmd-line_spec.rb
|
|
2
|
-
|
|
3
|
-
require 'stringio'
|
|
4
|
-
require 'English'
|
|
5
|
-
require_relative '../spec_helper'
|
|
6
|
-
|
|
7
|
-
# Load the class under testing
|
|
8
|
-
require_relative '../../lib/cukedep/application'
|
|
9
|
-
|
|
10
|
-
module Cukedep # Open module to get rid of long qualified names
|
|
11
|
-
describe Application do
|
|
12
|
-
context 'Creation & initialization:' do
|
|
13
|
-
it 'should be created without argument' do
|
|
14
|
-
expect { Application.new }.not_to raise_error
|
|
15
|
-
end
|
|
16
|
-
end # context
|
|
17
|
-
|
|
18
|
-
context 'Provided services:' do
|
|
19
|
-
subject { Application.new }
|
|
20
|
-
|
|
21
|
-
it 'should read its command-line' do
|
|
22
|
-
options = subject.send(:options_from, [])
|
|
23
|
-
expect(options).to be_empty
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
it 'should generate a user settings file' do
|
|
27
|
-
# Start state: no config
|
|
28
|
-
File.delete(Cukedep::YMLFilename) if File.exist?(Cukedep::YMLFilename)
|
|
29
|
-
|
|
30
|
-
# --setup option creates the config file then stops the application
|
|
31
|
-
expect { subject.run!(['--setup']) }.to raise_error(SystemExit)
|
|
32
|
-
|
|
33
|
-
# Check that the config file was effectively created.
|
|
34
|
-
expect(File.exist?(Cukedep::YMLFilename)).to be true
|
|
35
|
-
created_config = Config.load_cfg(Cukedep::YMLFilename)
|
|
36
|
-
expect(created_config).to eq(Config.default)
|
|
37
|
-
|
|
38
|
-
# Re-run again with --setup option.
|
|
39
|
-
# It should ask permission for overwriting
|
|
40
|
-
# Capture console IO
|
|
41
|
-
old_stdout = $DEFAULT_OUTPUT
|
|
42
|
-
ostream = StringIO.new('rw')
|
|
43
|
-
$DEFAULT_OUTPUT = ostream
|
|
44
|
-
old_stdin = $stdin
|
|
45
|
-
$stdin = StringIO.new("n\n", 'r')
|
|
46
|
-
expect { subject.run!(['--setup']) }.to raise_error(SystemExit)
|
|
47
|
-
$DEFAULT_OUTPUT = old_stdout
|
|
48
|
-
$stdin = old_stdin
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it 'should complain in absence of project dir' do
|
|
52
|
-
# Start state: no config
|
|
53
|
-
File.delete(Cukedep::YMLFilename) if File.exist?(Cukedep::YMLFilename)
|
|
54
|
-
expect(File.exist?(Cukedep::YMLFilename)).to be_falsey
|
|
55
|
-
|
|
56
|
-
# Create default config
|
|
57
|
-
expect { subject.run!(['--setup']) }.to raise_error(SystemExit)
|
|
58
|
-
|
|
59
|
-
err = StandardError
|
|
60
|
-
err_msg1 = "No project dir specified in '.cukedep.yml'"
|
|
61
|
-
err_msg2 = ' nor via --project option.'
|
|
62
|
-
expect { subject.run!([]) }.to raise_error(err, err_msg1 + err_msg2)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
it 'should parse the feature files' do
|
|
66
|
-
curr_dir = Dir.getwd
|
|
67
|
-
begin
|
|
68
|
-
file_dir = File.dirname(__FILE__)
|
|
69
|
-
Dir.chdir(file_dir + '/sample_features')
|
|
70
|
-
unless File.exist?(Cukedep::YMLFilename)
|
|
71
|
-
expect { subject.run!(['--setup']) }.to raise_error(SystemExit)
|
|
72
|
-
end
|
|
73
|
-
subject.run!(['--project', '../../../sample'])
|
|
74
|
-
ensure
|
|
75
|
-
Dir.chdir(curr_dir)
|
|
76
|
-
end
|
|
77
|
-
end
|
|
78
|
-
end # context
|
|
79
|
-
end # describe
|
|
80
|
-
end # module
|
|
1
|
+
# File: cmd-line_spec.rb
|
|
2
|
+
|
|
3
|
+
require 'stringio'
|
|
4
|
+
require 'English'
|
|
5
|
+
require_relative '../spec_helper'
|
|
6
|
+
|
|
7
|
+
# Load the class under testing
|
|
8
|
+
require_relative '../../lib/cukedep/application'
|
|
9
|
+
|
|
10
|
+
module Cukedep # Open module to get rid of long qualified names
|
|
11
|
+
describe Application do
|
|
12
|
+
context 'Creation & initialization:' do
|
|
13
|
+
it 'should be created without argument' do
|
|
14
|
+
expect { Application.new }.not_to raise_error
|
|
15
|
+
end
|
|
16
|
+
end # context
|
|
17
|
+
|
|
18
|
+
context 'Provided services:' do
|
|
19
|
+
subject { Application.new }
|
|
20
|
+
|
|
21
|
+
it 'should read its command-line' do
|
|
22
|
+
options = subject.send(:options_from, [])
|
|
23
|
+
expect(options).to be_empty
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'should generate a user settings file' do
|
|
27
|
+
# Start state: no config
|
|
28
|
+
File.delete(Cukedep::YMLFilename) if File.exist?(Cukedep::YMLFilename)
|
|
29
|
+
|
|
30
|
+
# --setup option creates the config file then stops the application
|
|
31
|
+
expect { subject.run!(['--setup']) }.to raise_error(SystemExit)
|
|
32
|
+
|
|
33
|
+
# Check that the config file was effectively created.
|
|
34
|
+
expect(File.exist?(Cukedep::YMLFilename)).to be true
|
|
35
|
+
created_config = Config.load_cfg(Cukedep::YMLFilename)
|
|
36
|
+
expect(created_config).to eq(Config.default)
|
|
37
|
+
|
|
38
|
+
# Re-run again with --setup option.
|
|
39
|
+
# It should ask permission for overwriting
|
|
40
|
+
# Capture console IO
|
|
41
|
+
old_stdout = $DEFAULT_OUTPUT
|
|
42
|
+
ostream = StringIO.new('rw')
|
|
43
|
+
$DEFAULT_OUTPUT = ostream
|
|
44
|
+
old_stdin = $stdin
|
|
45
|
+
$stdin = StringIO.new("n\n", 'r')
|
|
46
|
+
expect { subject.run!(['--setup']) }.to raise_error(SystemExit)
|
|
47
|
+
$DEFAULT_OUTPUT = old_stdout
|
|
48
|
+
$stdin = old_stdin
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it 'should complain in absence of project dir' do
|
|
52
|
+
# Start state: no config
|
|
53
|
+
File.delete(Cukedep::YMLFilename) if File.exist?(Cukedep::YMLFilename)
|
|
54
|
+
expect(File.exist?(Cukedep::YMLFilename)).to be_falsey
|
|
55
|
+
|
|
56
|
+
# Create default config
|
|
57
|
+
expect { subject.run!(['--setup']) }.to raise_error(SystemExit)
|
|
58
|
+
|
|
59
|
+
err = StandardError
|
|
60
|
+
err_msg1 = "No project dir specified in '.cukedep.yml'"
|
|
61
|
+
err_msg2 = ' nor via --project option.'
|
|
62
|
+
expect { subject.run!([]) }.to raise_error(err, err_msg1 + err_msg2)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
it 'should parse the feature files' do
|
|
66
|
+
curr_dir = Dir.getwd
|
|
67
|
+
begin
|
|
68
|
+
file_dir = File.dirname(__FILE__)
|
|
69
|
+
Dir.chdir(file_dir + '/sample_features')
|
|
70
|
+
unless File.exist?(Cukedep::YMLFilename)
|
|
71
|
+
expect { subject.run!(['--setup']) }.to raise_error(SystemExit)
|
|
72
|
+
end
|
|
73
|
+
subject.run!(['--project', '../../../sample'])
|
|
74
|
+
ensure
|
|
75
|
+
Dir.chdir(curr_dir)
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
end # context
|
|
79
|
+
end # describe
|
|
80
|
+
end # module
|