cukedep 0.2.00 → 0.2.01
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +7 -6
- data/CHANGELOG.md +5 -0
- data/LICENSE.txt +1 -1
- data/lib/cukedep/application.rb +1 -0
- data/lib/cukedep/constants.rb +1 -1
- data/lib/cukedep/cuke-runner.rb +2 -0
- data/lib/cukedep/feature-model.rb +2 -1
- data/lib/cukedep/feature-rep.rb +2 -2
- data/lib/cukedep/file-action.rb +3 -0
- data/lib/cukedep/gherkin-listener.rb +2 -1
- data/spec/cukedep/sample_features/cukedep.rake +206 -0
- data/spec/cukedep/sample_features/dependencies.dot +38 -0
- data/spec/cukedep/sample_features/feature2id.csv +7 -0
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8df9ae99acb44ec0ddbbf761a13d131361559fd3
|
4
|
+
data.tar.gz: 4ad352817632f67e814eb34ceb14f9e532866a1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a642d448f5e7a69e277dc463fd7affbab93ffdcb7d11fd237b8c63c5858605e840d9b59ecfb5a31281388c87519ea5da516860d83797ec4f2546c0dbacb5c8e0
|
7
|
+
data.tar.gz: 13b58ce0c44de5ae490803a91fd25ad57f817021d072e5c64b2a2dfbf534ab86264db6041fe996668b9f11ae2ba6ee196024e1d8c0fed6f8fad276051fab510b
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
### 0.2.01 / 2019-01-03
|
2
|
+
* [CHANGE] File `.travis.yml` updated with newest Ruby versions (from 2.2.x up to 2.6.0)
|
3
|
+
* [CHANGE] File `cukedep.gemspec`: As gherkin 6 is codebreaking, the dependency rule towards `gherkin` now requires version 5.x.x
|
4
|
+
* [CHANGE] Code re-formatted to please Rubocop 0.62.0
|
5
|
+
|
1
6
|
### 0.2.00 / 2018-05-21
|
2
7
|
Version number bumped.
|
3
8
|
* [CHANGE] Version numbers in dependencies
|
data/LICENSE.txt
CHANGED
data/lib/cukedep/application.rb
CHANGED
data/lib/cukedep/constants.rb
CHANGED
data/lib/cukedep/cuke-runner.rb
CHANGED
@@ -137,6 +137,7 @@ module Cukedep # This module is used as a namespace
|
|
137
137
|
|
138
138
|
def expected_state(aState)
|
139
139
|
return if state == aState
|
140
|
+
|
140
141
|
msg = "expected state was '#{aState}' instead of '#{state}'."
|
141
142
|
raise StandardError, msg
|
142
143
|
end
|
@@ -183,6 +184,7 @@ module Cukedep # This module is used as a namespace
|
|
183
184
|
|
184
185
|
kode = handlers[hook_kind.to_sym][scope.to_sym]
|
185
186
|
return if kode.nil?
|
187
|
+
|
186
188
|
safe_args = args.map { |one_arg| one_arg.dup.freeze }
|
187
189
|
kode.call(*safe_args)
|
188
190
|
end
|
@@ -8,7 +8,7 @@ require 'pathname'
|
|
8
8
|
module Cukedep # This module is used as a namespace
|
9
9
|
# The internal representation of a set of feature files.
|
10
10
|
# Dependencies: use topological sort
|
11
|
-
# TSort module http://ruby-doc.org/stdlib-
|
11
|
+
# TSort module http://ruby-doc.org/stdlib-2.6/libdoc/tsort/rdoc/index.html
|
12
12
|
# See also: Is this topological sort in Ruby flawed?
|
13
13
|
class FeatureModel
|
14
14
|
FeatureDependencies = Struct.new(:dependee, :dependents)
|
@@ -65,6 +65,7 @@ class FeatureModel
|
|
65
65
|
if found_feature.nil?
|
66
66
|
raise StandardError, "No feature file with identifier '#{an_id}'."
|
67
67
|
end
|
68
|
+
|
68
69
|
sub_result << found_feature
|
69
70
|
end
|
70
71
|
|
data/lib/cukedep/feature-rep.rb
CHANGED
@@ -4,10 +4,10 @@ module Cukedep # This module is used as a namespace
|
|
4
4
|
# A FeatureRep is the internal representation of a Gherkin feature.
|
5
5
|
class FeatureRep
|
6
6
|
# Constant that specifies how feature identifier tags should begin
|
7
|
-
FeatureIdPrefix = /^feature
|
7
|
+
FeatureIdPrefix = /^feature:/.freeze
|
8
8
|
|
9
9
|
# Constant that specifies how dependency tags should begin
|
10
|
-
DependencyPrefix = /^depends_on
|
10
|
+
DependencyPrefix = /^depends_on:/.freeze
|
11
11
|
|
12
12
|
# The sorted list of all tags of the feature.
|
13
13
|
# The @ prefix is stripped from each tag text.
|
data/lib/cukedep/file-action.rb
CHANGED
@@ -36,6 +36,7 @@ module Cukedep # This module is used as a namespace
|
|
36
36
|
def validate_file_patterns(filePatterns)
|
37
37
|
err_msg = 'Expecting a list of file patterns'
|
38
38
|
raise StandardError, err_msg unless filePatterns.is_a?(Array)
|
39
|
+
|
39
40
|
filePatterns.each do |file_patt|
|
40
41
|
err_msg = "Invalid value in list of file patterns: #{file_patt}"
|
41
42
|
raise StandardError, err_msg unless file_patt.is_a?(String)
|
@@ -84,6 +85,7 @@ module Cukedep # This module is used as a namespace
|
|
84
85
|
|
85
86
|
def run!(targetDir)
|
86
87
|
return if patterns.empty?
|
88
|
+
|
87
89
|
orig_dir = Dir.getwd # Store current work directory
|
88
90
|
# pp orig_dir
|
89
91
|
|
@@ -114,6 +116,7 @@ module Cukedep # This module is used as a namespace
|
|
114
116
|
class CopyAction < FileAction
|
115
117
|
def run!(sourceDir, targetDir)
|
116
118
|
return if patterns.empty?
|
119
|
+
|
117
120
|
orig_dir = Dir.getwd # Store current work directory
|
118
121
|
|
119
122
|
begin
|
@@ -51,9 +51,10 @@ module Cukedep # This module is used as a namespace
|
|
51
51
|
end
|
52
52
|
|
53
53
|
# Catch all method
|
54
|
-
def method_missing(message, *
|
54
|
+
def method_missing(message, *args)
|
55
55
|
puts caller(1, 5).join("\n")
|
56
56
|
puts "Method #{message} is not implemented (yet)."
|
57
|
+
super(message, args)
|
57
58
|
end
|
58
59
|
end # class
|
59
60
|
end # module
|
@@ -0,0 +1,206 @@
|
|
1
|
+
# File: cukedep.rake
|
2
|
+
# Generated by Cukedep 0.2.01 on 03/01/2019 09:17:30
|
3
|
+
|
4
|
+
require 'rake'
|
5
|
+
|
6
|
+
|
7
|
+
# Use development codebase
|
8
|
+
require_relative '../../../lib/cukedep/file-action'
|
9
|
+
|
10
|
+
|
11
|
+
# Run Cucumber via specialized Rake task
|
12
|
+
require 'cucumber/rake/task'
|
13
|
+
# UGLY workaround for bug in Cucumber's rake task
|
14
|
+
if Gem::VERSION[0].to_i >= 2 && Cucumber::VERSION <= '1.3.2'
|
15
|
+
# Monkey-patch a buggy method
|
16
|
+
module Cucumber
|
17
|
+
module Rake
|
18
|
+
module Task
|
19
|
+
class ForkedCucumberRunner
|
20
|
+
def gem_available?(gemname)
|
21
|
+
if Gem::VERSION[0].to_i >= 2
|
22
|
+
gem_available_new_rubygems?(gemname)
|
23
|
+
else
|
24
|
+
gem_available_old_rubygems?(gemname)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end # class
|
31
|
+
end
|
32
|
+
|
33
|
+
# Create a task called cucumber
|
34
|
+
Cucumber::Rake::Task.new do |_|
|
35
|
+
end
|
36
|
+
|
37
|
+
#######################################
|
38
|
+
# Retrieving state at end of Cukedep::Application#run! method
|
39
|
+
#######################################
|
40
|
+
|
41
|
+
# Constant holding the location of the original feature files
|
42
|
+
SOURCE_DIR = 'C:/Ruby22-x64/lib/ruby/site_ruby/Cukedep/spec/cukedep/sample_features'.freeze
|
43
|
+
|
44
|
+
# Constant holding the location of the Cucumber project
|
45
|
+
CUKE_PROJECT = 'C:/Ruby22-x64/lib/ruby/site_ruby/Cukedep/sample'.freeze
|
46
|
+
|
47
|
+
# The list of all "legacy" feature file
|
48
|
+
# (feature files without the @feature: tag)
|
49
|
+
AllUnidentifiedFeatures = [
|
50
|
+
'standalone.feature'
|
51
|
+
].freeze
|
52
|
+
|
53
|
+
# The list of all encountered feature ids
|
54
|
+
AllFeatureIdentifiers = %I[
|
55
|
+
qux
|
56
|
+
quux
|
57
|
+
corge
|
58
|
+
foo
|
59
|
+
baz
|
60
|
+
bar
|
61
|
+
].freeze
|
62
|
+
|
63
|
+
def run_builtin_actions(anEvent)
|
64
|
+
actions = Cukedep::ActionTriplet.builtin(anEvent)
|
65
|
+
actions.run!(SOURCE_DIR, CUKE_PROJECT) unless actions.nil?
|
66
|
+
end
|
67
|
+
|
68
|
+
# Helper method. Calculate the filepath of a file with given name
|
69
|
+
# if it is located in the source dir.
|
70
|
+
def source_path_of(aFilename)
|
71
|
+
SOURCE_DIR + '/' + aFilename
|
72
|
+
end
|
73
|
+
|
74
|
+
# Helper method. Calculate the filepath of a file with given name
|
75
|
+
# if it is located in the project features dir.
|
76
|
+
def project_path_of(aFilename)
|
77
|
+
CUKE_PROJECT + '/features/' + aFilename
|
78
|
+
end
|
79
|
+
|
80
|
+
# Helper method. Given the name of files in the source dir, copy them
|
81
|
+
# into the project dir.
|
82
|
+
def copy_to_project(filenames)
|
83
|
+
filenames.each do |fname|
|
84
|
+
source_path = source_path_of(fname)
|
85
|
+
dest_path = project_path_of(fname)
|
86
|
+
FileUtils.copy_file(source_path, dest_path)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
# Helper method. Given the name of files in the features dir of the project,
|
91
|
+
# copy them into the source dir.
|
92
|
+
def copy_from_project(*filenames)
|
93
|
+
filenames.each do |fname|
|
94
|
+
source_path = project_path_of(fname)
|
95
|
+
dest_path = source_path_of(fname)
|
96
|
+
FileUtils.copy_file(source_path, dest_path)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Helper method. Delete all the files in the
|
101
|
+
# the project's features dir that match one of
|
102
|
+
# the file name pattern
|
103
|
+
def clean_project_dir(fname_patterns)
|
104
|
+
curr_dir = Dir.getwd
|
105
|
+
begin
|
106
|
+
Dir.chdir(CUKE_PROJECT + '/features')
|
107
|
+
fname_patterns.each do |patt|
|
108
|
+
filenames = Dir.glob(patt)
|
109
|
+
filenames.each { |fn| FileUtils.remove_file(fn) }
|
110
|
+
end
|
111
|
+
ensure # Always restore previous working dir.
|
112
|
+
Dir.chdir(curr_dir)
|
113
|
+
end
|
114
|
+
end
|
115
|
+
|
116
|
+
# Helper method. Invoke Cucumber with the given project root dir.
|
117
|
+
# Assumption: all features files to execute are placed
|
118
|
+
# in the appropriate folder.
|
119
|
+
def invoke_cuke(projectDir)
|
120
|
+
curr_dir = Dir.getwd
|
121
|
+
Dir.chdir(projectDir)
|
122
|
+
begin
|
123
|
+
do_cuke = Rake::Task[:cucumber]
|
124
|
+
do_cuke.reenable
|
125
|
+
do_cuke.invoke
|
126
|
+
ensure
|
127
|
+
Dir.chdir(curr_dir)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def process_files(filenames)
|
132
|
+
run_builtin_actions(:before_each)
|
133
|
+
copy_to_project(filenames)
|
134
|
+
invoke_cuke(CUKE_PROJECT)
|
135
|
+
run_builtin_actions(:after_each)
|
136
|
+
# del_from_project(filenames)
|
137
|
+
end
|
138
|
+
|
139
|
+
def process_a_feature(filename)
|
140
|
+
process_files([filename])
|
141
|
+
end
|
142
|
+
|
143
|
+
# Default rake task is also top-level task
|
144
|
+
task default: :run_all_features
|
145
|
+
|
146
|
+
desc 'Run all features'
|
147
|
+
task run_all_features: %I[before_all all_features after_all] do
|
148
|
+
end
|
149
|
+
|
150
|
+
desc 'Before all'
|
151
|
+
task :before_all do
|
152
|
+
run_builtin_actions(:before_all)
|
153
|
+
end
|
154
|
+
|
155
|
+
desc 'After_all'
|
156
|
+
task :after_all do
|
157
|
+
run_builtin_actions(:after_all)
|
158
|
+
end
|
159
|
+
|
160
|
+
task :unidentified do
|
161
|
+
process_files(AllUnidentifiedFeatures)
|
162
|
+
end
|
163
|
+
|
164
|
+
# Tasks for feature files involved in dependencies
|
165
|
+
|
166
|
+
|
167
|
+
desc 'qux: run a_few_tests.feature'
|
168
|
+
task :qux do
|
169
|
+
process_a_feature('a_few_tests.feature')
|
170
|
+
end
|
171
|
+
|
172
|
+
|
173
|
+
desc 'quux: run more_tests.feature'
|
174
|
+
task :quux do
|
175
|
+
process_a_feature('more_tests.feature')
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
desc 'corge: run other_tests.feature'
|
180
|
+
task corge: %I[foo] do
|
181
|
+
process_a_feature('other_tests.feature')
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
desc 'foo: run some_tests.feature'
|
186
|
+
task foo: %I[bar qux] do
|
187
|
+
process_a_feature('some_tests.feature')
|
188
|
+
end
|
189
|
+
|
190
|
+
|
191
|
+
desc 'baz: run still_other_tests.feature'
|
192
|
+
task :baz do
|
193
|
+
process_a_feature('still_other_tests.feature')
|
194
|
+
end
|
195
|
+
|
196
|
+
|
197
|
+
desc 'bar: run yet_other_tests.feature'
|
198
|
+
task bar: %I[baz qux quux] do
|
199
|
+
process_a_feature('yet_other_tests.feature')
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
task all_features: ([:unidentified] + AllFeatureIdentifiers) do
|
204
|
+
end
|
205
|
+
|
206
|
+
# End of file
|
@@ -0,0 +1,38 @@
|
|
1
|
+
// Graph of dependencies of feature files in directory:
|
2
|
+
// 'C:/Ruby22-x64/lib/ruby/site_ruby/Cukedep/spec/cukedep/sample_features'
|
3
|
+
// This file uses the DOT syntax, a free utility from the Graphviz toolset.
|
4
|
+
// Graphviz is available at: www.graphviz.org
|
5
|
+
// File generated on Thu Jan 3 09:17:30 2019.
|
6
|
+
|
7
|
+
digraph g {
|
8
|
+
size = "7, 11"; // Dimensions in inches...
|
9
|
+
center = true;
|
10
|
+
rankdir = BT; // Draw from bottom to top
|
11
|
+
label = "\nDependency graph of 'C:/Ruby22-x64/lib/ruby/site_ruby/Cukedep/spec/cukedep/sample_features'";
|
12
|
+
|
13
|
+
// Nodes represent feature files
|
14
|
+
subgraph island {
|
15
|
+
node [shape = box, style=filled, color=lightgray];
|
16
|
+
node_4 [label = "standalone"];
|
17
|
+
label = "Isolated features";
|
18
|
+
}
|
19
|
+
|
20
|
+
subgraph dependencies {
|
21
|
+
node [shape = box, fillcolor = none];
|
22
|
+
node_0 [label = "a_few_tests -- qux"];
|
23
|
+
node_1 [label = "more_tests -- quux"];
|
24
|
+
node_2 [label = "other_tests -- corge"];
|
25
|
+
node_3 [label = "some_tests -- foo"];
|
26
|
+
node_5 [label = "still_other_tests -- baz"];
|
27
|
+
node_6 [label = "yet_other_tests -- bar"];
|
28
|
+
label = "Dependencies";
|
29
|
+
}
|
30
|
+
|
31
|
+
// The edges represent dependencies
|
32
|
+
node_2 -> node_3;
|
33
|
+
node_3 -> node_6;
|
34
|
+
node_3 -> node_0;
|
35
|
+
node_6 -> node_5;
|
36
|
+
node_6 -> node_0;
|
37
|
+
node_6 -> node_1;
|
38
|
+
} // End of graph
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cukedep
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.01
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dimitri Geshef
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-01-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cucumber
|
@@ -37,9 +37,9 @@ dependencies:
|
|
37
37
|
- - "~>"
|
38
38
|
- !ruby/object:Gem::Version
|
39
39
|
version: '5.0'
|
40
|
-
- - "
|
40
|
+
- - "<"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version:
|
42
|
+
version: 6.0.0
|
43
43
|
type: :runtime
|
44
44
|
prerelease: false
|
45
45
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -47,9 +47,9 @@ dependencies:
|
|
47
47
|
- - "~>"
|
48
48
|
- !ruby/object:Gem::Version
|
49
49
|
version: '5.0'
|
50
|
-
- - "
|
50
|
+
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version:
|
52
|
+
version: 6.0.0
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: rake
|
55
55
|
requirement: !ruby/object:Gem::Requirement
|
@@ -180,7 +180,10 @@ files:
|
|
180
180
|
- spec/cukedep/gherkin-listener_spec.rb
|
181
181
|
- spec/cukedep/hook-dsl_spec.rb
|
182
182
|
- spec/cukedep/sample_features/a_few_tests.feature
|
183
|
+
- spec/cukedep/sample_features/cukedep.rake
|
183
184
|
- spec/cukedep/sample_features/cukedep_hooks.rb
|
185
|
+
- spec/cukedep/sample_features/dependencies.dot
|
186
|
+
- spec/cukedep/sample_features/feature2id.csv
|
184
187
|
- spec/cukedep/sample_features/files_to_copy/README.md
|
185
188
|
- spec/cukedep/sample_features/files_to_copy/file1.txt
|
186
189
|
- spec/cukedep/sample_features/files_to_copy/file2.txt
|