cukedep 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.rspec +1 -0
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/.simplecov +7 -0
- data/.travis.yml +15 -0
- data/.yardopts +6 -0
- data/CHANGELOG.md +3 -0
- data/Gemfile +12 -0
- data/LICENSE.txt +19 -0
- data/README.md +64 -0
- data/Rakefile +32 -0
- data/bin/cukedep +14 -0
- data/cucumber.yml +10 -0
- data/lib/cukedep.rb +9 -0
- data/lib/cukedep/application.rb +112 -0
- data/lib/cukedep/cli/application.rb +0 -0
- data/lib/cukedep/cli/cmd-line.rb +115 -0
- data/lib/cukedep/config.rb +31 -0
- data/lib/cukedep/constants.rb +29 -0
- data/lib/cukedep/feature-model.rb +285 -0
- data/lib/cukedep/feature-rep.rb +49 -0
- data/lib/cukedep/gherkin-listener.rb +98 -0
- data/lib/macros4cuke.rb +8 -0
- data/sample/features/step_definitions/steps.rb +105 -0
- data/sample/features/support/env.rb +12 -0
- data/sample/model/model.rb +216 -0
- data/spec/cukedep/application_spec.rb +81 -0
- data/spec/cukedep/cli/cmd-line_spec.rb +91 -0
- data/spec/cukedep/feature-model_spec.rb +103 -0
- data/spec/cukedep/feature-rep_spec.rb +53 -0
- data/spec/cukedep/file-parsing.rb +40 -0
- data/spec/cukedep/gherkin-listener_spec.rb +59 -0
- data/spec/cukedep/sample_features/a_few_tests.feature +24 -0
- data/spec/cukedep/sample_features/more_tests.feature +24 -0
- data/spec/cukedep/sample_features/other_tests.feature +15 -0
- data/spec/cukedep/sample_features/some_tests.feature +13 -0
- data/spec/cukedep/sample_features/standalone.feature +19 -0
- data/spec/cukedep/sample_features/still_other_tests.feature +24 -0
- data/spec/cukedep/sample_features/yet_other_tests.feature +19 -0
- data/spec/spec_helper.rb +18 -0
- data/templates/rake.erb +163 -0
- metadata +165 -0
checksums.yaml
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
---
|
2
|
+
!binary "U0hBMQ==":
|
3
|
+
metadata.gz: !binary |-
|
4
|
+
NWY3NmMwOGE1YjM3MzVmNjA3YzFhYzlhMGE3ZmMwNTNiYzZhYjA1NQ==
|
5
|
+
data.tar.gz: !binary |-
|
6
|
+
MjI3ZDE2ZGY3NGU0ZDQxM2FjNjY2Mzk4OTZiMDg4NGE0M2RhNjdiYQ==
|
7
|
+
!binary "U0hBNTEy":
|
8
|
+
metadata.gz: !binary |-
|
9
|
+
NjQxZGZjZDNlMDU1MzRlZDhlZWI2NGYzNjJiYWZmNWRlZDFiMzRhMWQ3YmVh
|
10
|
+
NzllMWI4OGUxMWU1ZGIxNzU5ZjJkNmJiNWMzN2ZjZTlmMTBkN2UxYTIxYzRk
|
11
|
+
YjRjZDlhMzdkNDRmOWY4N2MwZGEyOTVhOTA5NTIyZjJhYWM3ZWM=
|
12
|
+
data.tar.gz: !binary |-
|
13
|
+
ODllMDNmNmNlMzIwZTZmNDFmM2FkYTMyMDhhYmRjNDg4Nzg3NjY4Zjc4NjUw
|
14
|
+
NGFlOTAwMTc5MGY2ZjFlNzllMjMwMzQxN2U0ZWExMjgyYjhkMjBiMzI0YTg5
|
15
|
+
YjMyZThjMmJiNGY1YTBiMDQ0MWQ5NWUxZDE4MGI1YmYxYzdkNTk=
|
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--backtrace
|
data/.ruby-gemset
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
cukedep
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.9.3
|
data/.simplecov
ADDED
data/.travis.yml
ADDED
data/.yardopts
ADDED
data/CHANGELOG.md
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
# Prevent Bundler to load the dependencies from our .gemspec file
|
3
|
+
|
4
|
+
gem "gherkin", [">=" "1.0.0"]
|
5
|
+
gem "cucumber", [">= 0.5.0"]
|
6
|
+
gem "rake", [">= 0.8.0" ]
|
7
|
+
|
8
|
+
group :development do
|
9
|
+
gem "rake", ">= 0.8.0"
|
10
|
+
gem "rspec", ">= 2.11.0"
|
11
|
+
gem "simplecov", ">= 0.5.0"
|
12
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
Copyright (c) 2013 Dimitri Geshef
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
9
|
+
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
12
|
+
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
Cukedep
|
2
|
+
===========
|
3
|
+
[![Build Status](https://travis-ci.org/famished-tiger/cukedep.png?branch=master)](https://travis-ci.org/famished-tiger/cukedep)
|
4
|
+
|
5
|
+
_Handle dependencies between feature file._
|
6
|
+
[Homepage](https://github.com/famished-tiger/cukedep)
|
7
|
+
|
8
|
+
__Cukedep__ is a command-line utility that helps to run feature files in the proper sequence.
|
9
|
+
|
10
|
+
### Highlights ###
|
11
|
+
* Simple syntax to specify dependencies
|
12
|
+
* Generates dependency reports (in CSV format)
|
13
|
+
* Generates dependency diagram (in DOT format),
|
14
|
+
* Generates a Rake file.
|
15
|
+
|
16
|
+
|
17
|
+
### Installation ###
|
18
|
+
The installation of the cukedep gem is fairly standard:
|
19
|
+
```bash
|
20
|
+
$[sudo] gem install cukedep
|
21
|
+
```
|
22
|
+
|
23
|
+
To check the installation, open a shell/command window
|
24
|
+
and type the command-line:
|
25
|
+
```bash
|
26
|
+
$[sudo] cukedep --version
|
27
|
+
```
|
28
|
+
|
29
|
+
You should see the version of cukedep gem.
|
30
|
+
|
31
|
+
|
32
|
+
### Synopsis ###
|
33
|
+
To get a first taste of how cukedep works, install it first.
|
34
|
+
Then go to the root dir of the cukedep gem, then open a shell/command window
|
35
|
+
and type the command-line:
|
36
|
+
```bash
|
37
|
+
$[sudo] rake
|
38
|
+
```
|
39
|
+
|
40
|
+
You will see tests running and Cucumber executing a number of feature files.
|
41
|
+
|
42
|
+
To learn more what's happening, go to the ```pec/sample_features``` dir
|
43
|
+
You will notice a number of feature files for a sample application.
|
44
|
+
Stay in that folder and type the following command-line:
|
45
|
+
```bash
|
46
|
+
$[sudo] cukedep --project ../../../sample --dry-run
|
47
|
+
```
|
48
|
+
|
49
|
+
You instructed cukedep to do the following:
|
50
|
+
* Read (parse) all the feature files in the current dir.
|
51
|
+
* Resolve the dependencies between the feature files (based on specific Gherkin @tags).
|
52
|
+
* Generate a number of dependency reports and drawing.
|
53
|
+
* Generate a rake file that will execute the feature files in the proper sequence for
|
54
|
+
the project located at the relative path ```../../../sample```
|
55
|
+
|
56
|
+
To generate all the above files and run the feature files with Cucumber,
|
57
|
+
then retry the command line without the --dry-run option:
|
58
|
+
```bash
|
59
|
+
$[sudo] cukedep --project ../../../sample --dry-run
|
60
|
+
```
|
61
|
+
|
62
|
+
Copyright
|
63
|
+
---------
|
64
|
+
Copyright (c) 2013, Dimitri Geshef. Cukedep is released under the MIT License see [LICENSE.txt](https://github.com/famished-tiger/Cukedep/blob/master/LICENSE.txt) for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require_relative './lib/cukedep/constants'
|
3
|
+
|
4
|
+
namespace :gem do
|
5
|
+
|
6
|
+
desc 'Push the gem to rubygems.org'
|
7
|
+
task :push do
|
8
|
+
system("gem push cukedep-#{Cukedep::Version}.gem")
|
9
|
+
end
|
10
|
+
|
11
|
+
end # namespace
|
12
|
+
|
13
|
+
# Testing-specific tasks
|
14
|
+
|
15
|
+
|
16
|
+
# RSpec as testing tool
|
17
|
+
require 'rspec/core/rake_task'
|
18
|
+
desc 'Run RSpec'
|
19
|
+
RSpec::Core::RakeTask.new do |spec|
|
20
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
# Combine RSpec tests
|
25
|
+
desc 'Run tests, with RSpec'
|
26
|
+
task :test => [:spec]
|
27
|
+
|
28
|
+
|
29
|
+
# Default rake task
|
30
|
+
task :default => :test
|
31
|
+
|
32
|
+
# End of file
|
data/bin/cukedep
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# File: cukedep
|
3
|
+
# The 'executable' of the Cukedep utility.
|
4
|
+
|
5
|
+
mydir = File.dirname(__FILE__)
|
6
|
+
lib_dir = mydir + '/../lib'
|
7
|
+
$LOAD_PATH.unshift lib_dir unless $:.include?(lib_dir)
|
8
|
+
|
9
|
+
require 'cukedep' # Load the Cukedep::Application class
|
10
|
+
|
11
|
+
# The application's entry point
|
12
|
+
app = Cukedep::Application.new
|
13
|
+
app.start!(ARGV)
|
14
|
+
# End of file
|
data/cucumber.yml
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
default: --strict -v -b --format progress features
|
2
|
+
html: --strict -v -b --format html --out result.html features
|
3
|
+
pdf: --strict -v -b --format pdf --out result.pdf features
|
4
|
+
stepdefs: --strict -v -b --format stepdefs --out stepdefs.txt features
|
5
|
+
rerun: --strict -v -b --format rerun --out rerun.txt features
|
6
|
+
tag_cloud: --strict -v -b --format tag_cloud --out tag_cloud.txt features
|
7
|
+
usage: --strict -v -b --format usage --out usage.txt features
|
8
|
+
|
9
|
+
|
10
|
+
|
data/lib/cukedep.rb
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
# File: application.rb
|
2
|
+
|
3
|
+
require 'yaml'
|
4
|
+
require 'gherkin/parser/parser'
|
5
|
+
|
6
|
+
require_relative 'cli/cmd-line'
|
7
|
+
require_relative 'config'
|
8
|
+
require_relative 'gherkin-listener'
|
9
|
+
require_relative 'feature-model'
|
10
|
+
|
11
|
+
module Cukedep # Module used as a namespace
|
12
|
+
|
13
|
+
# Runner for the Cukedep application
|
14
|
+
class Application
|
15
|
+
attr_reader(:proj_dir)
|
16
|
+
public
|
17
|
+
|
18
|
+
# Entry point for the application object.
|
19
|
+
def start!(theCmdLineArgs)
|
20
|
+
options = options_from(theCmdLineArgs)
|
21
|
+
create_default_cfg() if options[:setup]
|
22
|
+
config = load_cfg()
|
23
|
+
|
24
|
+
# Complain if no project dir is specified
|
25
|
+
if config.proj_dir.nil? || config.proj_dir.empty?
|
26
|
+
if options[:project]
|
27
|
+
@proj_dir = options[:project]
|
28
|
+
else
|
29
|
+
fail(StandardError, "No project dir specified via 'Cukedep::YMLFilename' nor via --project option.")
|
30
|
+
end
|
31
|
+
else
|
32
|
+
@proj_dir = config.proj_dir
|
33
|
+
end
|
34
|
+
|
35
|
+
feature_files = parse_features()
|
36
|
+
|
37
|
+
model = FeatureModel.new(feature_files)
|
38
|
+
generate_files(model)
|
39
|
+
unless options[:"dry-run"]
|
40
|
+
rake_cmd = "rake -f cukedep.rake"
|
41
|
+
system(rake_cmd)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
# Retrieve the user-entered command-line options
|
47
|
+
def options_from(theCmdLineArgs)
|
48
|
+
cli = CLI::CmdLine.new
|
49
|
+
options = cli.parse!(theCmdLineArgs.dup)
|
50
|
+
end
|
51
|
+
|
52
|
+
# Create a local copy of the .cukedep.yml file, then
|
53
|
+
# stop the application.
|
54
|
+
def create_default_cfg()
|
55
|
+
if File.exist?(Cukedep::YMLFilename)
|
56
|
+
puts "OK to overwrite file #{Cukedep::YMLFilename}."
|
57
|
+
puts '(Y/N)?'
|
58
|
+
answer = $stdin.gets()
|
59
|
+
exit if answer =~ /^\s*[Nn]\s*$/
|
60
|
+
end
|
61
|
+
File::open(Cukedep::YMLFilename, 'w') { |f| YAML.dump(Config.default, f) }
|
62
|
+
exit
|
63
|
+
end
|
64
|
+
|
65
|
+
# Read the .cukedep.yml file in the current working directory
|
66
|
+
def load_cfg()
|
67
|
+
if File.exist?(Cukedep::YMLFilename)
|
68
|
+
YAML::load_file(Cukedep::YMLFilename)
|
69
|
+
else
|
70
|
+
Config.default
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Parse the feature files
|
75
|
+
def parse_features()
|
76
|
+
# Create a Gherkin listener
|
77
|
+
listener = Cukedep::GherkinListener.new
|
78
|
+
|
79
|
+
# Create a Gherkin parser
|
80
|
+
parser = Gherkin::Parser::Parser.new(listener)
|
81
|
+
|
82
|
+
# List all the .feature files
|
83
|
+
filenames = Dir.glob('*.feature')
|
84
|
+
puts "\nParsing:"
|
85
|
+
|
86
|
+
# Parse them
|
87
|
+
filenames.each do |fname|
|
88
|
+
puts " #{fname}"
|
89
|
+
File::open(fname, 'r') { |f| parser.parse(f.read, fname, 0) }
|
90
|
+
end
|
91
|
+
|
92
|
+
return listener.feature_files
|
93
|
+
end
|
94
|
+
|
95
|
+
|
96
|
+
def generate_files(aModel)
|
97
|
+
# Sort the feature files by dependency order.
|
98
|
+
aModel.sort_features_by_dep()
|
99
|
+
|
100
|
+
puts "\nGenerating:"
|
101
|
+
|
102
|
+
# Generate CSV files detailing the feature to identifier mapping
|
103
|
+
# and vise versa
|
104
|
+
aModel.mapping_reports('feature2id.csv', 'id2feature.csv', true)
|
105
|
+
aModel.draw_dependency_graph('dependencies.dot', true)
|
106
|
+
aModel.generate_rake_tasks('cukedep.rake', proj_dir)
|
107
|
+
end
|
108
|
+
end # class
|
109
|
+
|
110
|
+
end # module
|
111
|
+
|
112
|
+
# End of file
|
File without changes
|
@@ -0,0 +1,115 @@
|
|
1
|
+
# File: cli.rb
|
2
|
+
|
3
|
+
# Access the OptionParser library from the standard Ruby library
|
4
|
+
require 'optparse'
|
5
|
+
require 'pathname'
|
6
|
+
|
7
|
+
require_relative '../constants'
|
8
|
+
|
9
|
+
module Cukedep # This module is used as a namespace
|
10
|
+
|
11
|
+
# Module dedicated to the command-line interface
|
12
|
+
module CLI
|
13
|
+
|
14
|
+
|
15
|
+
# Manages the application command-line interface (CLI).
|
16
|
+
# It is merely a thin wrapper around the OptionParser library.
|
17
|
+
# Responsibilities:
|
18
|
+
#- Specify the command-line syntax,
|
19
|
+
#- Return the result of the command-line parsing
|
20
|
+
class CmdLine
|
21
|
+
# A Hash with the result of the command-line parse.
|
22
|
+
attr_reader(:options)
|
23
|
+
|
24
|
+
# OptionParser object
|
25
|
+
attr_reader(:parser)
|
26
|
+
|
27
|
+
# Constructor.
|
28
|
+
def initialize()
|
29
|
+
@options = { }
|
30
|
+
|
31
|
+
@parser = OptionParser.new do |opts|
|
32
|
+
opts.banner = <<-EOS
|
33
|
+
Usage: cukedep [options]
|
34
|
+
The command-line options are:
|
35
|
+
EOS
|
36
|
+
|
37
|
+
# No argument. Check
|
38
|
+
dry_txt = 'Check the feature file dependencies without running the feature files.'
|
39
|
+
opts.on(nil, '--dry-run', dry_txt) do
|
40
|
+
options[:"dry-run"] = true
|
41
|
+
end
|
42
|
+
|
43
|
+
# No argument. Create .cukedep.yml file
|
44
|
+
setup_txt = 'Create a default .cukedep.yml file in current dir.'
|
45
|
+
opts.on(nil, '--setup', setup_txt) do
|
46
|
+
options[:setup] = true
|
47
|
+
end
|
48
|
+
|
49
|
+
# Mandatory argument
|
50
|
+
msg = 'Run the Cucumber project at given path with features from current dir.'
|
51
|
+
opts.on('--project PROJ_PATH', msg) do |project_path|
|
52
|
+
options[:project] = validated_project(project_path)
|
53
|
+
end
|
54
|
+
|
55
|
+
# No argument, shows at tail. This will print an options summary.
|
56
|
+
opts.on_tail('-h', '--help', 'Show this message') do
|
57
|
+
puts opts
|
58
|
+
options[:help] = true
|
59
|
+
end
|
60
|
+
|
61
|
+
opts.on_tail('--version', 'Show application version number') do
|
62
|
+
puts Cukedep::Version
|
63
|
+
options[:version] = true
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
public
|
70
|
+
# Perform the command-line parsing
|
71
|
+
def parse!(theCmdLineArgs)
|
72
|
+
begin
|
73
|
+
parser.parse!(theCmdLineArgs)
|
74
|
+
rescue OptionParser::MissingArgument => exc
|
75
|
+
err_msg = ''
|
76
|
+
exc.args.each do |arg|
|
77
|
+
err_msg << "No argument provided with command line option: #{arg}\n"
|
78
|
+
end
|
79
|
+
err_msg << 'To see the command-line syntax, do:\ncukedep --help'
|
80
|
+
fail(StandardError, err_msg)
|
81
|
+
end
|
82
|
+
|
83
|
+
# Some options stop the application
|
84
|
+
exit if options[:version] || options[:help]
|
85
|
+
|
86
|
+
return options
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
def validated_project(theProjectPath)
|
91
|
+
unless Dir.exist?(theProjectPath)
|
92
|
+
fail StandardError, "Cannot find the directory '#{theProjectPath}'."
|
93
|
+
end
|
94
|
+
|
95
|
+
# If current dir is /features and project dir is parent of it
|
96
|
+
# then we have an error
|
97
|
+
current_path = Pathname.getwd()
|
98
|
+
if current_path.to_s =~ /features$/
|
99
|
+
if current_path.parent == Pathname.new(theProjectPath)
|
100
|
+
msg = "Original feature file may not be in 'features' subdir of project dir."
|
101
|
+
fail StandardError, msg
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
|
106
|
+
return theProjectPath
|
107
|
+
end
|
108
|
+
|
109
|
+
end # class
|
110
|
+
|
111
|
+
end # module
|
112
|
+
|
113
|
+
end # module
|
114
|
+
|
115
|
+
# End of file
|