cukedep 0.0.8 → 0.1.03

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +8 -8
  2. data/CHANGELOG.md +26 -0
  3. data/bin/cukedep +1 -1
  4. data/lib/cukedep/application.rb +7 -7
  5. data/lib/cukedep/config.rb +64 -7
  6. data/lib/cukedep/constants.rb +5 -1
  7. data/lib/cukedep/cuke-runner.rb +202 -0
  8. data/lib/cukedep/customization.rb +35 -0
  9. data/lib/cukedep/feature-rep.rb +2 -2
  10. data/lib/cukedep/file-action.rb +211 -0
  11. data/lib/cukedep/hook-dsl.rb +80 -0
  12. data/lib/cukedep/sandbox.rb +21 -0
  13. data/sample/cucumber.yml +4 -0
  14. data/sample/model/catalogue.yml +13 -0
  15. data/sample/model/members.yml +13 -0
  16. data/sample/model/model.rb +2 -2
  17. data/sample/model/rentals.yml +4 -0
  18. data/sample/model/users.yml +7 -0
  19. data/sample/result.html +472 -0
  20. data/spec/cukedep/application_spec.rb +8 -8
  21. data/spec/cukedep/cuke-runner_spec.rb +80 -0
  22. data/spec/cukedep/customization_spec.rb +36 -0
  23. data/spec/cukedep/file-action_spec.rb +374 -0
  24. data/spec/cukedep/gherkin-facade_spec.rb +54 -0
  25. data/spec/cukedep/hook-dsl_spec.rb +185 -0
  26. data/spec/cukedep/sample_features/cukedep.rake +204 -0
  27. data/spec/cukedep/sample_features/cukedep_hooks.rb +30 -0
  28. data/spec/cukedep/sample_features/dependencies.dot +38 -0
  29. data/spec/cukedep/sample_features/feature2id.csv +7 -0
  30. data/spec/cukedep/sample_features/files_to_copy/README.md +12 -0
  31. data/spec/cukedep/sample_features/files_to_copy/file1.txt +5 -0
  32. data/spec/cukedep/sample_features/files_to_copy/file2.txt +5 -0
  33. data/spec/cukedep/sample_features/files_to_copy/file3.txt +9 -0
  34. data/spec/spec_helper.rb +1 -0
  35. data/templates/rake.erb +184 -160
  36. metadata +26 -2
@@ -0,0 +1,38 @@
1
+ // Graph of dependencies of feature files in directory:
2
+ // 'C:/Ruby193/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 Wed Nov 27 23:12:50 2013.
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:/Ruby193/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
@@ -0,0 +1,7 @@
1
+ identifier,feature file
2
+ qux,a_few_tests.feature
3
+ quux,more_tests.feature
4
+ corge,other_tests.feature
5
+ foo,some_tests.feature
6
+ baz,still_other_tests.feature
7
+ bar,yet_other_tests.feature
@@ -0,0 +1,12 @@
1
+ == README.md
2
+ Besides this file, the directory contains
3
+ three sample text files:
4
+ - file1.txt
5
+ - file2.txt
6
+ - file3.txt
7
+
8
+
9
+ They contain random text generated from a 'Ipsum lorem' text generator.
10
+
11
+ All these files are used for testing purposes.
12
+
@@ -0,0 +1,5 @@
1
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Aenean accumsan nulla urna, ut luctus tellus
2
+ sollicitudin id. Aliquam ut ipsum ut neque malesuada sagittis et at nisi. In hac habitasse platea dictumst. In
3
+ hac habitasse platea dictumst. Vestibulum vulputate elit quis mattis malesuada. Etiam rutrum porttitor orci, vel
4
+ fringilla sapien mattis rhoncus. Pellentesque nec porttitor lorem. Aliquam erat volutpat. Nullam ut dui vitae
5
+ velit fermentum fermentum. Nulla nisi urna, vulputate a vehicula sed, rhoncus ut ipsum.
@@ -0,0 +1,5 @@
1
+ Aenean quis lectus sed dui suscipit egestas. Proin eleifend venenatis odio a iaculis. Nam lobortis fermentum
2
+ mauris, id adipiscing elit iaculis vitae. Curabitur sed placerat risus, tristique fringilla nisi. Pellentesque
3
+ congue ante ligula, sed tempor nisi laoreet nec. Proin rhoncus pretium dui sed mattis. Nulla at nisl interdum,
4
+ luctus dolor eget, venenatis lorem. Pellentesque laoreet aliquet pulvinar. Suspendisse id augue at mauris
5
+ euismod dignissim nec vitae dolor.
@@ -0,0 +1,9 @@
1
+ Sed eu ligula quis quam sollicitudin cursus. Aenean porta lacinia lectus id laoreet. Donec semper pellentesque
2
+ dui nec tristique. Pellentesque at lacus commodo, volutpat urna ut, sollicitudin tellus. Phasellus elementum
3
+ auctor adipiscing. Aenean leo nibh, hendrerit vitae vehicula ut, molestie non leo. Vestibulum libero nisi,
4
+ consequat ac orci in, condimentum dignissim massa. Suspendisse id justo nec magna mattis posuere eu sed felis.
5
+ Fusce aliquam facilisis odio, congue vulputate sem. Vivamus ultrices est non porttitor mattis. Nam dignissim
6
+ egestas nisi sit amet fringilla. Maecenas scelerisque sit amet nunc vel elementum. Proin fermentum, justo
7
+ egestas euismod ornare, lorem ipsum rhoncus diam, sit amet suscipit metus orci at dui. Mauris suscipit, urna id
8
+ tempor tempor, augue augue suscipit nunc, eget mattis mi sem id metus. Fusce eu ipsum sapien. Nullam vitae
9
+ volutpat lorem.
@@ -12,6 +12,7 @@ RSpec.configure do |config|
12
12
  # Disable the `should` syntax...
13
13
  c.syntax = :expect
14
14
  end
15
+ config.full_backtrace = true
15
16
  end
16
17
 
17
18
 
@@ -1,161 +1,185 @@
1
- # File: <%=rakefile%>
2
- # Generated by Cukedep <%=Cukedep::Version%> on <%=Time.now.strftime('%d/%m/%Y %H:%M:%S')%>
3
-
4
- require 'rake'
5
-
6
- # Run Cucumber via specialized Rake task
7
- require 'cucumber/rake/task'
8
- # UGLY workaround for bug in Cucumber's rake task
9
- if Gem::VERSION[0].to_i >= 2 && Cucumber::VERSION <= '1.3.2'
10
- # Monkey-patch a buggy method
11
- class Cucumber::Rake::Task::ForkedCucumberRunner
12
- def gem_available?(gemname)
13
- if Gem::VERSION[0].to_i >= 2
14
- gem_available_new_rubygems?(gemname)
15
- else
16
- gem_available_old_rubygems?(gemname)
17
- end
18
- end
19
- end # class
20
- end
21
-
22
- # Create a task called cucumber
23
- Cucumber::Rake::Task.new do |t|
24
- end
25
-
26
-
27
- # Constant holding the location of the original feature files
28
- SOURCE_DIR = '<%=source_dir%>'
29
-
30
- # Constant holding the location of the project
31
- CUKE_PROJECT = '<%=proj_dir%>'
32
-
33
- # Helper method. Calculate the filepath of a file with given name
34
- # if it is located in the source dir.
35
- def source_path_of(aFilename)
36
- SOURCE_DIR + '/' + aFilename
37
- end
38
-
39
- # Helper method. Calculate the filepath of a file with given name
40
- # if it is located in the project featurers dir.
41
- def project_path_of(aFilename)
42
- CUKE_PROJECT + '/features/' + aFilename
43
- end
44
-
45
- # Helper method. Given the name of files in the source dir, copy them
46
- # into the project dir.
47
- def copy_to_project(filenames)
48
- filenames.each do |fname|
49
- source_path = source_path_of(fname)
50
- dest_path = project_path_of(fname)
51
- FileUtils.copy_file(source_path, dest_path)
52
- end
53
- end
54
-
55
-
56
- # Helper method. Given the name of files in the features dir of the project,
57
- # copy them into the source dir.
58
- def copy_from_project(*filenames)
59
- filenames.each do |fname|
60
- source_path = project_path_of(fname)
61
- dest_path = source_path_of(fname)
62
- FileUtils.copy_file(source_path, dest_path)
63
- end
64
- end
65
-
66
- def del_from_project(filenames)
67
- filenames.each do |fname|
68
- dest_path = project_path_of(fname)
69
- FileUtils.remove_file(dest_path)
70
- end
71
- end
72
-
73
- # Helper method. Delete all the files in the
74
- # the project's features dir that match one of
75
- # the file name pattern
76
- def clean_project_dir(fname_patterns)
77
- curr_dir = Dir.getwd()
78
- begin
79
- Dir.chdir(CUKE_PROJECT + '/features')
80
- fname_patterns.each do |patt|
81
- filenames = Dir.glob(patt)
82
- filenames.each { |fn| FileUtils.remove_file(fn) }
83
- end
84
- ensure #Always restore previous working dir.
85
- Dir.chdir(curr_dir)
86
- end
87
- end
88
-
89
-
90
- def process_files(filenames)
91
- copy_to_project(filenames)
92
- curr_dir = Dir.getwd()
93
- Dir.chdir(CUKE_PROJECT)
94
- begin
95
- do_cuke = Rake::Task[:cucumber]
96
- do_cuke.reenable
97
- do_cuke.invoke
98
- ensure
99
- Dir.chdir(curr_dir)
100
- end
101
- del_from_project(filenames)
102
- end
103
-
104
- def process_a_feature(filename)
105
- process_files([filename])
106
- end
107
-
108
-
109
- AllUnidentifiedFeatures = [<%anonymous_list = anonymous.map { |name| "'#{name}'"}%>
110
- <%=anonymous_list.join(",\n ")%>
111
- ]
112
-
113
-
114
- AllFeatureIdentifiers = [ <%identifier_list = feature_ids.map {|f_id| ":#{f_id}"}%>
115
- <%=identifier_list.join(",\n ")%>
116
- ]
117
-
118
- # Default rake task is also top-level task
119
- task :default => :run_all_features
120
-
121
-
122
- desc 'Run all features'
123
- task :run_all_features => [:before_all, :all_features, :after_all] do
124
- ; # Do nothing
125
- end
126
-
127
-
128
- # Remove feature files from a cuke project
129
- task :dir_cleanup do
130
- clean_project_dir(['*.feature'])
131
- end
132
-
133
-
134
-
135
- desc 'Before all'
136
- task :before_all => [:dir_cleanup] do
137
- ; # Do nothing
138
- end
139
-
140
- desc 'After_all'
141
- task :after_all do
142
- ; # Do nothing
143
- end
144
-
145
-
146
- task :unidentified do
147
- process_files(AllUnidentifiedFeatures)
148
- end
149
-
150
- # Tasks for feature files involved in dependencies
151
- <%deps.each do |dep|%>
152
- <%dep_list = dep.dependents.map { |ff| ":#{ff.feature.identifier}" } %>
153
- task :<%=dep.dependee.feature.identifier%> <%= dep_list.empty? ? '' : %Q|=> [#{dep_list.join(', ') }]| %> do
154
- process_a_feature('<%=dep.dependee.basename%>')
155
- end
156
- <%end%>
157
-
158
- task :all_features => ([:unidentified] + AllFeatureIdentifiers) do
159
- end
160
-
1
+ # File: <%=rakefile%>
2
+ # Generated by Cukedep <%=Cukedep::Version%> on <%=Time.now.strftime('%d/%m/%Y %H:%M:%S')%>
3
+
4
+ require 'rake'
5
+
6
+ <%require 'pathname'
7
+ # In case of development version, use classes from the project direct
8
+ # Otherwise rely on code from gem.
9
+ rake_dir = Pathname.new(Dir.getwd)
10
+ cukedep_dir = Pathname.new(Cukedep::RootDir).realdirpath
11
+ development_env = nil # Will be true iff w. dir is child of Cukedep project dir.
12
+ rake_dir.ascend do |a_parent|
13
+ development_env = true if a_parent.realdirpath == cukedep_dir
14
+ end
15
+ if development_env
16
+ rel_path = cukedep_dir.relative_path_from(rake_dir)%>
17
+ # Use development codebase
18
+ require_relative '<%=rel_path.to_s + '/lib/cukedep/file-action'%>'
19
+ <% else%>
20
+ require 'cukedep/file-action'
21
+ <% end%>
22
+
23
+ # Run Cucumber via specialized Rake task
24
+ require 'cucumber/rake/task'
25
+ # UGLY workaround for bug in Cucumber's rake task
26
+ if Gem::VERSION[0].to_i >= 2 && Cucumber::VERSION <= '1.3.2'
27
+ # Monkey-patch a buggy method
28
+ class Cucumber::Rake::Task::ForkedCucumberRunner
29
+ def gem_available?(gemname)
30
+ if Gem::VERSION[0].to_i >= 2
31
+ gem_available_new_rubygems?(gemname)
32
+ else
33
+ gem_available_old_rubygems?(gemname)
34
+ end
35
+ end
36
+ end # class
37
+ end
38
+
39
+ # Create a task called cucumber
40
+ Cucumber::Rake::Task.new do |t|
41
+ end
42
+
43
+ #######################################
44
+ # Retrieving state at end of Cukedep::Application#run! method
45
+ #######################################
46
+
47
+ # Constant holding the location of the original feature files
48
+ SOURCE_DIR = '<%=source_dir%>'
49
+
50
+ # Constant holding the location of the Cucumber project
51
+ CUKE_PROJECT = '<%=proj_dir%>'
52
+
53
+ # The list of all "legacy" feature file (feature files without the @feature: tag)
54
+ AllUnidentifiedFeatures = [<%anonymous_list = anonymous.map { |name| "'#{name}'"}%>
55
+ <%=anonymous_list.join(",\n ")%>
56
+ ]
57
+
58
+ # The list of all encountered feature ids
59
+ AllFeatureIdentifiers = [ <%identifier_list = feature_ids.map {|f_id| ":#{f_id}"}%>
60
+ <%=identifier_list.join(",\n ")%>
61
+ ]
62
+
63
+
64
+ def run_builtin_actions(anEvent)
65
+ actions = Cukedep::ActionTriplet.builtin(anEvent)
66
+ actions.run!(SOURCE_DIR, CUKE_PROJECT) unless actions.nil?
67
+ end
68
+
69
+ # Helper method. Calculate the filepath of a file with given name
70
+ # if it is located in the source dir.
71
+ def source_path_of(aFilename)
72
+ SOURCE_DIR + '/' + aFilename
73
+ end
74
+
75
+ # Helper method. Calculate the filepath of a file with given name
76
+ # if it is located in the project features dir.
77
+ def project_path_of(aFilename)
78
+ CUKE_PROJECT + '/features/' + aFilename
79
+ end
80
+
81
+ # Helper method. Given the name of files in the source dir, copy them
82
+ # into the project dir.
83
+ def copy_to_project(filenames)
84
+ filenames.each do |fname|
85
+ source_path = source_path_of(fname)
86
+ dest_path = project_path_of(fname)
87
+ FileUtils.copy_file(source_path, dest_path)
88
+ end
89
+ end
90
+
91
+
92
+ # Helper method. Given the name of files in the features dir of the project,
93
+ # copy them into the source dir.
94
+ def copy_from_project(*filenames)
95
+ filenames.each do |fname|
96
+ source_path = project_path_of(fname)
97
+ dest_path = source_path_of(fname)
98
+ FileUtils.copy_file(source_path, dest_path)
99
+ end
100
+ end
101
+
102
+ # Helper method. Delete all the files in the
103
+ # the project's features dir that match one of
104
+ # the file name pattern
105
+ def clean_project_dir(fname_patterns)
106
+ curr_dir = Dir.getwd()
107
+ begin
108
+ Dir.chdir(CUKE_PROJECT + '/features')
109
+ fname_patterns.each do |patt|
110
+ filenames = Dir.glob(patt)
111
+ filenames.each { |fn| FileUtils.remove_file(fn) }
112
+ end
113
+ ensure #Always restore previous working dir.
114
+ Dir.chdir(curr_dir)
115
+ end
116
+ end
117
+
118
+
119
+ # Helper method. Invoke Cucumber with the given project root dir.
120
+ # Assumption: all features files to execute are placed
121
+ # in the appropriate folder.
122
+ def invoke_cuke(projectDir)
123
+ curr_dir = Dir.getwd()
124
+ Dir.chdir(projectDir)
125
+ begin
126
+ do_cuke = Rake::Task[:cucumber]
127
+ do_cuke.reenable
128
+ do_cuke.invoke
129
+ ensure
130
+ Dir.chdir(curr_dir)
131
+ end
132
+ end
133
+
134
+
135
+ def process_files(filenames)
136
+ run_builtin_actions(:before_each)
137
+ copy_to_project(filenames)
138
+ invoke_cuke(CUKE_PROJECT)
139
+ run_builtin_actions(:after_each)
140
+ #del_from_project(filenames)
141
+ end
142
+
143
+ def process_a_feature(filename)
144
+ process_files([filename])
145
+ end
146
+
147
+
148
+ # Default rake task is also top-level task
149
+ task :default => :run_all_features
150
+
151
+
152
+ desc 'Run all features'
153
+ task :run_all_features => [:before_all, :all_features, :after_all] do
154
+ ; # Do nothing
155
+ end
156
+
157
+
158
+ desc 'Before all'
159
+ task :before_all do
160
+ run_builtin_actions(:before_all)
161
+ end
162
+
163
+ desc 'After_all'
164
+ task :after_all do
165
+ run_builtin_actions(:after_all)
166
+ end
167
+
168
+
169
+ task :unidentified do
170
+ process_files(AllUnidentifiedFeatures)
171
+ end
172
+
173
+ # Tasks for feature files involved in dependencies
174
+ <%deps.each do |dep|%>
175
+ <%dep_list = dep.dependents.map { |ff| ":#{ff.feature.identifier}" } %>
176
+ desc "<%=dep.dependee.feature.identifier%>: run <%=dep.dependee.basename%>"
177
+ task :<%=dep.dependee.feature.identifier%> <%= dep_list.empty? ? '' : %Q|=> [#{dep_list.join(', ') }]| %> do
178
+ process_a_feature('<%=dep.dependee.basename%>')
179
+ end
180
+ <%end%>
181
+
182
+ task :all_features => ([:unidentified] + AllFeatureIdentifiers) do
183
+ end
184
+
161
185
  # End of file
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.0.8
4
+ version: 0.1.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: 2013-10-31 00:00:00.000000000 Z
11
+ date: 2013-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -120,27 +120,51 @@ files:
120
120
  - lib/cukedep/cli/cmd-line.rb
121
121
  - lib/cukedep/config.rb
122
122
  - lib/cukedep/constants.rb
123
+ - lib/cukedep/cuke-runner.rb
124
+ - lib/cukedep/customization.rb
123
125
  - lib/cukedep/feature-model.rb
124
126
  - lib/cukedep/feature-rep.rb
127
+ - lib/cukedep/file-action.rb
125
128
  - lib/cukedep/gherkin-facade.rb
126
129
  - lib/cukedep/gherkin-listener.rb
130
+ - lib/cukedep/hook-dsl.rb
131
+ - lib/cukedep/sandbox.rb
132
+ - sample/cucumber.yml
127
133
  - sample/features/step_definitions/steps.rb
128
134
  - sample/features/support/env.rb
135
+ - sample/model/catalogue.yml
136
+ - sample/model/members.yml
129
137
  - sample/model/model.rb
138
+ - sample/model/rentals.yml
139
+ - sample/model/users.yml
140
+ - sample/result.html
130
141
  - spec/cukedep/application_spec.rb
131
142
  - spec/cukedep/cli/cmd-line_spec.rb
143
+ - spec/cukedep/cuke-runner_spec.rb
144
+ - spec/cukedep/customization_spec.rb
132
145
  - spec/cukedep/feature-model_spec.rb
133
146
  - spec/cukedep/feature-rep_spec.rb
147
+ - spec/cukedep/file-action_spec.rb
134
148
  - spec/cukedep/file-parsing.rb
149
+ - spec/cukedep/gherkin-facade_spec.rb
135
150
  - spec/cukedep/gherkin-listener_spec.rb
151
+ - spec/cukedep/hook-dsl_spec.rb
152
+ - spec/cukedep/sample_features/cukedep_hooks.rb
136
153
  - spec/spec_helper.rb
137
154
  - spec/cukedep/sample_features/a_few_tests.feature
155
+ - spec/cukedep/sample_features/cukedep.rake
156
+ - spec/cukedep/sample_features/dependencies.dot
157
+ - spec/cukedep/sample_features/feature2id.csv
138
158
  - spec/cukedep/sample_features/more_tests.feature
139
159
  - spec/cukedep/sample_features/other_tests.feature
140
160
  - spec/cukedep/sample_features/some_tests.feature
141
161
  - spec/cukedep/sample_features/standalone.feature
142
162
  - spec/cukedep/sample_features/still_other_tests.feature
143
163
  - spec/cukedep/sample_features/yet_other_tests.feature
164
+ - spec/cukedep/sample_features/files_to_copy/file1.txt
165
+ - spec/cukedep/sample_features/files_to_copy/file2.txt
166
+ - spec/cukedep/sample_features/files_to_copy/file3.txt
167
+ - spec/cukedep/sample_features/files_to_copy/README.md
144
168
  - templates/rake.erb
145
169
  homepage: https://github.com/famished-tiger/Cukedep
146
170
  licenses: