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
|
@@ -1,88 +1,88 @@
|
|
|
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/cli/cmd-line'
|
|
9
|
-
|
|
10
|
-
module Cukedep # Open module to get rid of long qualified names
|
|
11
|
-
describe CLI::CmdLine do
|
|
12
|
-
context 'Creation & initialization:' do
|
|
13
|
-
subject { CLI::CmdLine.new }
|
|
14
|
-
|
|
15
|
-
it 'should be created without argument' do
|
|
16
|
-
expect { CLI::CmdLine.new }.not_to raise_error
|
|
17
|
-
end
|
|
18
|
-
end # context
|
|
19
|
-
|
|
20
|
-
context 'Provided services:' do
|
|
21
|
-
def capture_output
|
|
22
|
-
@output = $DEFAULT_OUTPUT
|
|
23
|
-
ostream = StringIO.new('rw')
|
|
24
|
-
$DEFAULT_OUTPUT = ostream
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
def release_output
|
|
28
|
-
$DEFAULT_OUTPUT = @output
|
|
29
|
-
end
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
it 'should accept an empty command-line' do
|
|
33
|
-
expect { subject.parse!([]) }.not_to raise_error
|
|
34
|
-
expect(subject.options).to be_empty
|
|
35
|
-
end
|
|
36
|
-
|
|
37
|
-
it 'should accept the dry-run option' do
|
|
38
|
-
expect { subject.parse!(['--dry-run']) }.not_to raise_error
|
|
39
|
-
expect(subject.options).to eq(dryrun: true)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'should accept the setup option' do
|
|
43
|
-
expect { subject.parse!(['--setup']) }.not_to raise_error
|
|
44
|
-
expect(subject.options).to eq(setup: true)
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
it 'should validate the project option argument' do
|
|
48
|
-
# Case 1: missing project dir argument
|
|
49
|
-
cmd_opts = ['--project']
|
|
50
|
-
err_type = StandardError
|
|
51
|
-
err_msg = <<-MSG_END
|
|
52
|
-
No argument provided with command line option: --project
|
|
53
|
-
To see the command-line syntax, do:
|
|
54
|
-
cukedep --help
|
|
55
|
-
MSG_END
|
|
56
|
-
expect { subject.parse!(cmd_opts) }.to raise_error(err_type)
|
|
57
|
-
|
|
58
|
-
# Case 2: non existing project dir
|
|
59
|
-
cmd_opts = ['--project', 'nowhere']
|
|
60
|
-
err_msg = "Cannot find the directory 'nowhere'."
|
|
61
|
-
expect { subject.parse!(cmd_opts) }.to raise_error(err_type, err_msg)
|
|
62
|
-
|
|
63
|
-
# Case 3: project dir exists
|
|
64
|
-
# cmd_opts = ['--project', '../../../sample']
|
|
65
|
-
# expect { subject.parse!(cmd_opts) }.not_to raise_error
|
|
66
|
-
# expect(subject.options).to eq({ :project => '../../../sample' })
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
it 'should handle the version option' do
|
|
70
|
-
capture_output
|
|
71
|
-
cmd_opts = ['--version']
|
|
72
|
-
expect { subject.parse!(cmd_opts) }.to raise_error(SystemExit)
|
|
73
|
-
expect($DEFAULT_OUTPUT.string).to eq(Cukedep::Version + "\n")
|
|
74
|
-
release_output
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
it 'should handle the help option' do
|
|
78
|
-
capture_output
|
|
79
|
-
cmd_opts = ['--help']
|
|
80
|
-
expect { subject.parse!(cmd_opts) }.to raise_error(SystemExit)
|
|
81
|
-
expect($DEFAULT_OUTPUT.string).to eq(subject.parser.to_s)
|
|
82
|
-
release_output
|
|
83
|
-
end
|
|
84
|
-
end # context
|
|
85
|
-
end # describe
|
|
86
|
-
end # module
|
|
87
|
-
|
|
88
|
-
# End of file
|
|
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/cli/cmd-line'
|
|
9
|
+
|
|
10
|
+
module Cukedep # Open module to get rid of long qualified names
|
|
11
|
+
describe CLI::CmdLine do
|
|
12
|
+
context 'Creation & initialization:' do
|
|
13
|
+
subject { CLI::CmdLine.new }
|
|
14
|
+
|
|
15
|
+
it 'should be created without argument' do
|
|
16
|
+
expect { CLI::CmdLine.new }.not_to raise_error
|
|
17
|
+
end
|
|
18
|
+
end # context
|
|
19
|
+
|
|
20
|
+
context 'Provided services:' do
|
|
21
|
+
def capture_output
|
|
22
|
+
@output = $DEFAULT_OUTPUT
|
|
23
|
+
ostream = StringIO.new('rw')
|
|
24
|
+
$DEFAULT_OUTPUT = ostream
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def release_output
|
|
28
|
+
$DEFAULT_OUTPUT = @output
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
it 'should accept an empty command-line' do
|
|
33
|
+
expect { subject.parse!([]) }.not_to raise_error
|
|
34
|
+
expect(subject.options).to be_empty
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'should accept the dry-run option' do
|
|
38
|
+
expect { subject.parse!(['--dry-run']) }.not_to raise_error
|
|
39
|
+
expect(subject.options).to eq(dryrun: true)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should accept the setup option' do
|
|
43
|
+
expect { subject.parse!(['--setup']) }.not_to raise_error
|
|
44
|
+
expect(subject.options).to eq(setup: true)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
it 'should validate the project option argument' do
|
|
48
|
+
# Case 1: missing project dir argument
|
|
49
|
+
cmd_opts = ['--project']
|
|
50
|
+
err_type = StandardError
|
|
51
|
+
err_msg = <<-MSG_END
|
|
52
|
+
No argument provided with command line option: --project
|
|
53
|
+
To see the command-line syntax, do:
|
|
54
|
+
cukedep --help
|
|
55
|
+
MSG_END
|
|
56
|
+
expect { subject.parse!(cmd_opts) }.to raise_error(err_type)
|
|
57
|
+
|
|
58
|
+
# Case 2: non existing project dir
|
|
59
|
+
cmd_opts = ['--project', 'nowhere']
|
|
60
|
+
err_msg = "Cannot find the directory 'nowhere'."
|
|
61
|
+
expect { subject.parse!(cmd_opts) }.to raise_error(err_type, err_msg)
|
|
62
|
+
|
|
63
|
+
# Case 3: project dir exists
|
|
64
|
+
# cmd_opts = ['--project', '../../../sample']
|
|
65
|
+
# expect { subject.parse!(cmd_opts) }.not_to raise_error
|
|
66
|
+
# expect(subject.options).to eq({ :project => '../../../sample' })
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
it 'should handle the version option' do
|
|
70
|
+
capture_output
|
|
71
|
+
cmd_opts = ['--version']
|
|
72
|
+
expect { subject.parse!(cmd_opts) }.to raise_error(SystemExit)
|
|
73
|
+
expect($DEFAULT_OUTPUT.string).to eq(Cukedep::Version + "\n")
|
|
74
|
+
release_output
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
it 'should handle the help option' do
|
|
78
|
+
capture_output
|
|
79
|
+
cmd_opts = ['--help']
|
|
80
|
+
expect { subject.parse!(cmd_opts) }.to raise_error(SystemExit)
|
|
81
|
+
expect($DEFAULT_OUTPUT.string).to eq(subject.parser.to_s)
|
|
82
|
+
release_output
|
|
83
|
+
end
|
|
84
|
+
end # context
|
|
85
|
+
end # describe
|
|
86
|
+
end # module
|
|
87
|
+
|
|
88
|
+
# End of file
|
|
@@ -1,74 +1,74 @@
|
|
|
1
|
-
# File: cuke-runner_spec.rb
|
|
2
|
-
|
|
3
|
-
require_relative '../spec_helper'
|
|
4
|
-
require_relative '../../lib/cukedep/config'
|
|
5
|
-
|
|
6
|
-
# Load the class under testing
|
|
7
|
-
require_relative '../../lib/cukedep/cuke-runner'
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
module Cukedep # Open module to get rid of long qualified names
|
|
11
|
-
describe CukeRunner do
|
|
12
|
-
let(:project_dir) { '../../sample' }
|
|
13
|
-
let(:base_dir) do
|
|
14
|
-
file_dir = File.dirname(__FILE__)
|
|
15
|
-
file_dir + '/sample_features'
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
subject { CukeRunner.new(base_dir, project_dir, Config.default) }
|
|
19
|
-
|
|
20
|
-
before(:each) do
|
|
21
|
-
@orig_dir = Dir.getwd
|
|
22
|
-
Dir.chdir(File.dirname(__FILE__))
|
|
23
|
-
end
|
|
24
|
-
|
|
25
|
-
after(:each) do
|
|
26
|
-
Dir.chdir(@orig_dir)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
context 'Creation & initialization:' do
|
|
31
|
-
it 'should be created with three arguments' do
|
|
32
|
-
expect { CukeRunner.new(base_dir, project_dir, Config.default) }
|
|
33
|
-
.not_to raise_error
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
it 'should know its work directory' do
|
|
37
|
-
expect(subject.base_dir).to eq(base_dir)
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
it 'should know the project directory' do
|
|
41
|
-
expect(subject.proj_dir).to eq(File.expand_path(project_dir))
|
|
42
|
-
end
|
|
43
|
-
end # context
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
context 'Provided services:' do
|
|
47
|
-
it 'should launch Cucumber when requested' do
|
|
48
|
-
# subject.invoke
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
it "should handle the 'before_all' event" do
|
|
52
|
-
expect { subject.before_all }.not_to raise_error
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should reject a second 'before_all' event" do
|
|
56
|
-
subject.before_all
|
|
57
|
-
err_msg = "expected state was 'Initialized' instead of 'ReadyToRun'."
|
|
58
|
-
expect { subject.before_all }.to raise_error(StandardError, err_msg)
|
|
59
|
-
end
|
|
60
|
-
|
|
61
|
-
it "should handle the 'after_all' event" do
|
|
62
|
-
subject.before_all
|
|
63
|
-
expect { subject.after_all }.not_to raise_error
|
|
64
|
-
end
|
|
65
|
-
|
|
66
|
-
it 'should run the designated feature files' do
|
|
67
|
-
subject.before_all
|
|
68
|
-
# expect {
|
|
69
|
-
subject.run!(['a_few_tests.feature']) # }.not_to raise_error
|
|
70
|
-
end
|
|
71
|
-
end # context
|
|
72
|
-
end # describe
|
|
73
|
-
end # module
|
|
74
|
-
# End of file
|
|
1
|
+
# File: cuke-runner_spec.rb
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
require_relative '../../lib/cukedep/config'
|
|
5
|
+
|
|
6
|
+
# Load the class under testing
|
|
7
|
+
require_relative '../../lib/cukedep/cuke-runner'
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
module Cukedep # Open module to get rid of long qualified names
|
|
11
|
+
describe CukeRunner do
|
|
12
|
+
let(:project_dir) { '../../sample' }
|
|
13
|
+
let(:base_dir) do
|
|
14
|
+
file_dir = File.dirname(__FILE__)
|
|
15
|
+
file_dir + '/sample_features'
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
subject { CukeRunner.new(base_dir, project_dir, Config.default) }
|
|
19
|
+
|
|
20
|
+
before(:each) do
|
|
21
|
+
@orig_dir = Dir.getwd
|
|
22
|
+
Dir.chdir(File.dirname(__FILE__))
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
after(:each) do
|
|
26
|
+
Dir.chdir(@orig_dir)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
context 'Creation & initialization:' do
|
|
31
|
+
it 'should be created with three arguments' do
|
|
32
|
+
expect { CukeRunner.new(base_dir, project_dir, Config.default) }
|
|
33
|
+
.not_to raise_error
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'should know its work directory' do
|
|
37
|
+
expect(subject.base_dir).to eq(base_dir)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
it 'should know the project directory' do
|
|
41
|
+
expect(subject.proj_dir).to eq(File.expand_path(project_dir))
|
|
42
|
+
end
|
|
43
|
+
end # context
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
context 'Provided services:' do
|
|
47
|
+
it 'should launch Cucumber when requested' do
|
|
48
|
+
# subject.invoke
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
it "should handle the 'before_all' event" do
|
|
52
|
+
expect { subject.before_all }.not_to raise_error
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should reject a second 'before_all' event" do
|
|
56
|
+
subject.before_all
|
|
57
|
+
err_msg = "expected state was 'Initialized' instead of 'ReadyToRun'."
|
|
58
|
+
expect { subject.before_all }.to raise_error(StandardError, err_msg)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "should handle the 'after_all' event" do
|
|
62
|
+
subject.before_all
|
|
63
|
+
expect { subject.after_all }.not_to raise_error
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it 'should run the designated feature files' do
|
|
67
|
+
subject.before_all
|
|
68
|
+
# expect {
|
|
69
|
+
subject.run!(['a_few_tests.feature']) # }.not_to raise_error
|
|
70
|
+
end
|
|
71
|
+
end # context
|
|
72
|
+
end # describe
|
|
73
|
+
end # module
|
|
74
|
+
# End of file
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
# File: customization_spec.rb
|
|
2
|
-
|
|
3
|
-
require_relative '../spec_helper'
|
|
4
|
-
|
|
5
|
-
# Load the class under testing
|
|
6
|
-
require_relative '../../lib/cukedep/customization'
|
|
7
|
-
|
|
8
|
-
module Cukedep # Open module to get rid of long qualified names
|
|
9
|
-
describe Customization do
|
|
10
|
-
context 'Provided services:' do
|
|
11
|
-
it 'should load hook handlers' do
|
|
12
|
-
directory = File.join(File.dirname(__FILE__), '/sample_features')
|
|
13
|
-
|
|
14
|
-
expect { subject.build_handlers(directory) }.not_to raise_error
|
|
15
|
-
expect(subject.build_handlers(directory)).not_to be_nil
|
|
16
|
-
handlers = subject.build_handlers(directory)
|
|
17
|
-
expect(handlers[:before_hooks].size).to eq(2)
|
|
18
|
-
expect(handlers[:after_hooks].size).to eq(2)
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it 'should return nil when hook file absent' do
|
|
22
|
-
directory = File.dirname(__FILE__)
|
|
23
|
-
|
|
24
|
-
expect { subject.build_handlers(directory) }.not_to raise_error
|
|
25
|
-
expect(subject.build_handlers(directory)).to be_nil
|
|
26
|
-
end
|
|
27
|
-
end # context
|
|
28
|
-
end # describe
|
|
29
|
-
end # module
|
|
30
|
-
|
|
31
|
-
# End of file
|
|
1
|
+
# File: customization_spec.rb
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
# Load the class under testing
|
|
6
|
+
require_relative '../../lib/cukedep/customization'
|
|
7
|
+
|
|
8
|
+
module Cukedep # Open module to get rid of long qualified names
|
|
9
|
+
describe Customization do
|
|
10
|
+
context 'Provided services:' do
|
|
11
|
+
it 'should load hook handlers' do
|
|
12
|
+
directory = File.join(File.dirname(__FILE__), '/sample_features')
|
|
13
|
+
|
|
14
|
+
expect { subject.build_handlers(directory) }.not_to raise_error
|
|
15
|
+
expect(subject.build_handlers(directory)).not_to be_nil
|
|
16
|
+
handlers = subject.build_handlers(directory)
|
|
17
|
+
expect(handlers[:before_hooks].size).to eq(2)
|
|
18
|
+
expect(handlers[:after_hooks].size).to eq(2)
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'should return nil when hook file absent' do
|
|
22
|
+
directory = File.dirname(__FILE__)
|
|
23
|
+
|
|
24
|
+
expect { subject.build_handlers(directory) }.not_to raise_error
|
|
25
|
+
expect(subject.build_handlers(directory)).to be_nil
|
|
26
|
+
end
|
|
27
|
+
end # context
|
|
28
|
+
end # describe
|
|
29
|
+
end # module
|
|
30
|
+
|
|
31
|
+
# End of file
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
require 'pp'
|
|
2
|
-
|
|
3
|
-
require_relative '../../lib/cukedep/file-action'
|
|
4
|
-
|
|
5
|
-
copy_config = {
|
|
6
|
-
save_patterns: [],
|
|
7
|
-
save_subdir: '',
|
|
8
|
-
delete_patterns: [],
|
|
9
|
-
delete_subdir: '',
|
|
10
|
-
copy_patterns: ['*.txt'],
|
|
11
|
-
copy_subdir: ''
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
pp Dir.pwd
|
|
15
|
-
instance = Cukedep::ActionTriplet.new(copy_config)
|
|
16
|
-
path = 'C:/Ruby193/lib/ruby/site_ruby/Cukedep/spec/cukedep/'
|
|
17
|
-
files_to_copy_dir = path + 'sample_features/files_to_copy'
|
|
18
|
-
|
|
19
|
-
Dir.chdir(files_to_copy_dir)
|
|
20
|
-
pp Dir.pwd
|
|
21
|
-
|
|
22
|
-
proj_dir = path + 'dummy_project'
|
|
23
|
-
instance.run!(Dir.getwd, proj_dir)
|
|
24
|
-
|
|
25
|
-
# Check that the project dir contain the requested files
|
|
26
|
-
Dir.chdir(proj_dir)
|
|
27
|
-
pp Dir.pwd # TODO
|
|
28
|
-
actuals = Dir['*.*']
|
|
29
|
-
pp actuals
|
|
1
|
+
require 'pp'
|
|
2
|
+
|
|
3
|
+
require_relative '../../lib/cukedep/file-action'
|
|
4
|
+
|
|
5
|
+
copy_config = {
|
|
6
|
+
save_patterns: [],
|
|
7
|
+
save_subdir: '',
|
|
8
|
+
delete_patterns: [],
|
|
9
|
+
delete_subdir: '',
|
|
10
|
+
copy_patterns: ['*.txt'],
|
|
11
|
+
copy_subdir: ''
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
pp Dir.pwd
|
|
15
|
+
instance = Cukedep::ActionTriplet.new(copy_config)
|
|
16
|
+
path = 'C:/Ruby193/lib/ruby/site_ruby/Cukedep/spec/cukedep/'
|
|
17
|
+
files_to_copy_dir = path + 'sample_features/files_to_copy'
|
|
18
|
+
|
|
19
|
+
Dir.chdir(files_to_copy_dir)
|
|
20
|
+
pp Dir.pwd
|
|
21
|
+
|
|
22
|
+
proj_dir = path + 'dummy_project'
|
|
23
|
+
instance.run!(Dir.getwd, proj_dir)
|
|
24
|
+
|
|
25
|
+
# Check that the project dir contain the requested files
|
|
26
|
+
Dir.chdir(proj_dir)
|
|
27
|
+
pp Dir.pwd # TODO
|
|
28
|
+
actuals = Dir['*.*']
|
|
29
|
+
pp actuals
|
|
@@ -1,100 +1,100 @@
|
|
|
1
|
-
# File: feature-model_spec.rb
|
|
2
|
-
|
|
3
|
-
require_relative '../spec_helper'
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require_relative 'file-parsing'
|
|
7
|
-
require_relative '../../lib/cukedep/gherkin-listener'
|
|
8
|
-
|
|
9
|
-
# Load the class under testing
|
|
10
|
-
require_relative '../../lib/cukedep/feature-model'
|
|
11
|
-
|
|
12
|
-
module Cukedep # Open module to get rid of long qualified names
|
|
13
|
-
describe FeatureModel do
|
|
14
|
-
# An array of FeatureFile objects created after parsing sample files.
|
|
15
|
-
FeatureFiles = begin
|
|
16
|
-
listener = GherkinListener.new
|
|
17
|
-
extend(FileParsing)
|
|
18
|
-
parse_for(listener) # Method from mixin to parse sample feature files
|
|
19
|
-
listener.feature_files
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
# Default instantiation rule
|
|
23
|
-
subject { FeatureModel.new(FeatureFiles) }
|
|
24
|
-
|
|
25
|
-
context 'Creation and initialization:' do
|
|
26
|
-
it 'should be created with a list of feature files' do
|
|
27
|
-
expect { FeatureModel.new(FeatureFiles) }.not_to raise_error
|
|
28
|
-
end
|
|
29
|
-
|
|
30
|
-
it 'should know its feature file objects' do
|
|
31
|
-
expect(subject.feature_files).to eq(FeatureFiles)
|
|
32
|
-
end
|
|
33
|
-
end # context
|
|
34
|
-
|
|
35
|
-
context 'Provided services:' do
|
|
36
|
-
it 'should list all features without identifiers' do
|
|
37
|
-
unidentified = subject.anonymous_features
|
|
38
|
-
expect(unidentified.size).to eq(1)
|
|
39
|
-
expect(unidentified[0].filepath).to match(/standalone\.feature$/)
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
it 'should retrieve a feature file given its identifier' do
|
|
43
|
-
# Case of a single id argument
|
|
44
|
-
one_id = 'foo'
|
|
45
|
-
found = subject.select_by_ids(one_id)
|
|
46
|
-
expect(found.size).to eq(1)
|
|
47
|
-
expect(found[0].feature.identifier).to eq(one_id)
|
|
48
|
-
|
|
49
|
-
# Case of multiple id arguments
|
|
50
|
-
second_id = 'qux'
|
|
51
|
-
found = subject.select_by_ids(one_id, second_id)
|
|
52
|
-
expect(found.size).to eq(2)
|
|
53
|
-
actual_ids = found.map { |ff| ff.feature.identifier }
|
|
54
|
-
expected_ids = [one_id, second_id]
|
|
55
|
-
expect(actual_ids.sort).to eq(expected_ids.sort)
|
|
56
|
-
|
|
57
|
-
# Case of unknown id
|
|
58
|
-
wrong_id = 'does_not_exist'
|
|
59
|
-
err_type = StandardError
|
|
60
|
-
err_msg = "No feature file with identifier 'does_not_exist'."
|
|
61
|
-
expect { subject.select_by_ids(wrong_id) }
|
|
62
|
-
.to raise_error(err_type, err_msg)
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
it 'should resolve dependency links' do
|
|
67
|
-
mapping = subject.send(:id2features)
|
|
68
|
-
deps = subject.dependency_links
|
|
69
|
-
expect(deps).not_to be_empty
|
|
70
|
-
|
|
71
|
-
# Case of an identified feature without dependencies
|
|
72
|
-
case1 = deps.find { |a_dep| a_dep.dependee == mapping['baz'] }
|
|
73
|
-
expect(case1.dependents).to be_empty
|
|
74
|
-
|
|
75
|
-
# Case of a feature having dependencies
|
|
76
|
-
case2 = deps.find { |a_dep| a_dep.dependee == mapping['foo'] }
|
|
77
|
-
expectations = subject.select_by_ids('bar', 'qux')
|
|
78
|
-
expect(case2.dependents).to eq(expectations)
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
it 'should sort the feature files' do
|
|
82
|
-
sorted_files = subject.sort_features_by_dep
|
|
83
|
-
actual_order = sorted_files.map { |f| f.feature.identifier }
|
|
84
|
-
expected_order = %w(qux baz quux bar foo)
|
|
85
|
-
expect(actual_order).to eq(expected_order)
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
it 'should generate mapping reports' do
|
|
89
|
-
subject.mapping_reports('feature2id.csv', 'id2feature.csv')
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
it 'should generate dependency graph' do
|
|
93
|
-
subject.dependency_links
|
|
94
|
-
subject.draw_dependency_graph('dependencies.dot')
|
|
95
|
-
end
|
|
96
|
-
end # context
|
|
97
|
-
end # describe
|
|
98
|
-
end # module
|
|
99
|
-
|
|
100
|
-
# End of file
|
|
1
|
+
# File: feature-model_spec.rb
|
|
2
|
+
|
|
3
|
+
require_relative '../spec_helper'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
require_relative 'file-parsing'
|
|
7
|
+
require_relative '../../lib/cukedep/gherkin-listener'
|
|
8
|
+
|
|
9
|
+
# Load the class under testing
|
|
10
|
+
require_relative '../../lib/cukedep/feature-model'
|
|
11
|
+
|
|
12
|
+
module Cukedep # Open module to get rid of long qualified names
|
|
13
|
+
describe FeatureModel do
|
|
14
|
+
# An array of FeatureFile objects created after parsing sample files.
|
|
15
|
+
FeatureFiles = begin
|
|
16
|
+
listener = GherkinListener.new
|
|
17
|
+
extend(FileParsing) # Add behaviour from mixin module
|
|
18
|
+
parse_for(listener) # Method from mixin to parse sample feature files
|
|
19
|
+
listener.feature_files
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
# Default instantiation rule
|
|
23
|
+
subject { FeatureModel.new(FeatureFiles) }
|
|
24
|
+
|
|
25
|
+
context 'Creation and initialization:' do
|
|
26
|
+
it 'should be created with a list of feature files' do
|
|
27
|
+
expect { FeatureModel.new(FeatureFiles) }.not_to raise_error
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
it 'should know its feature file objects' do
|
|
31
|
+
expect(subject.feature_files).to eq(FeatureFiles)
|
|
32
|
+
end
|
|
33
|
+
end # context
|
|
34
|
+
|
|
35
|
+
context 'Provided services:' do
|
|
36
|
+
it 'should list all features without identifiers' do
|
|
37
|
+
unidentified = subject.anonymous_features
|
|
38
|
+
expect(unidentified.size).to eq(1)
|
|
39
|
+
expect(unidentified[0].filepath).to match(/standalone\.feature$/)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
it 'should retrieve a feature file given its identifier' do
|
|
43
|
+
# Case of a single id argument
|
|
44
|
+
one_id = 'foo'
|
|
45
|
+
found = subject.select_by_ids(one_id)
|
|
46
|
+
expect(found.size).to eq(1)
|
|
47
|
+
expect(found[0].feature.identifier).to eq(one_id)
|
|
48
|
+
|
|
49
|
+
# Case of multiple id arguments
|
|
50
|
+
second_id = 'qux'
|
|
51
|
+
found = subject.select_by_ids(one_id, second_id)
|
|
52
|
+
expect(found.size).to eq(2)
|
|
53
|
+
actual_ids = found.map { |ff| ff.feature.identifier }
|
|
54
|
+
expected_ids = [one_id, second_id]
|
|
55
|
+
expect(actual_ids.sort).to eq(expected_ids.sort)
|
|
56
|
+
|
|
57
|
+
# Case of unknown id
|
|
58
|
+
wrong_id = 'does_not_exist'
|
|
59
|
+
err_type = StandardError
|
|
60
|
+
err_msg = "No feature file with identifier 'does_not_exist'."
|
|
61
|
+
expect { subject.select_by_ids(wrong_id) }
|
|
62
|
+
.to raise_error(err_type, err_msg)
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
it 'should resolve dependency links' do
|
|
67
|
+
mapping = subject.send(:id2features)
|
|
68
|
+
deps = subject.dependency_links
|
|
69
|
+
expect(deps).not_to be_empty
|
|
70
|
+
|
|
71
|
+
# Case of an identified feature without dependencies
|
|
72
|
+
case1 = deps.find { |a_dep| a_dep.dependee == mapping['baz'] }
|
|
73
|
+
expect(case1.dependents).to be_empty
|
|
74
|
+
|
|
75
|
+
# Case of a feature having dependencies
|
|
76
|
+
case2 = deps.find { |a_dep| a_dep.dependee == mapping['foo'] }
|
|
77
|
+
expectations = subject.select_by_ids('bar', 'qux')
|
|
78
|
+
expect(case2.dependents).to eq(expectations)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
it 'should sort the feature files' do
|
|
82
|
+
sorted_files = subject.sort_features_by_dep
|
|
83
|
+
actual_order = sorted_files.map { |f| f.feature.identifier }
|
|
84
|
+
expected_order = %w(qux baz quux bar foo)
|
|
85
|
+
expect(actual_order).to eq(expected_order)
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it 'should generate mapping reports' do
|
|
89
|
+
subject.mapping_reports('feature2id.csv', 'id2feature.csv')
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it 'should generate dependency graph' do
|
|
93
|
+
subject.dependency_links
|
|
94
|
+
subject.draw_dependency_graph('dependencies.dot')
|
|
95
|
+
end
|
|
96
|
+
end # context
|
|
97
|
+
end # describe
|
|
98
|
+
end # module
|
|
99
|
+
|
|
100
|
+
# End of file
|
|
@@ -8,7 +8,8 @@ require_relative '../../lib/cukedep/feature-rep'
|
|
|
8
8
|
module Cukedep # Open module to get rid of long qualified names
|
|
9
9
|
describe FeatureRep do
|
|
10
10
|
# Tag names as provided by Gherkin parser
|
|
11
|
-
RawTagNames = %w(@some @feature:CO801_foo @depends_on:CO201_bar
|
|
11
|
+
RawTagNames = %w(@some @feature:CO801_foo @depends_on:CO201_bar
|
|
12
|
+
@depends_on:CO001_qux).freeze
|
|
12
13
|
|
|
13
14
|
SampleTagNames = RawTagNames.map { |t| t[1..-1] }
|
|
14
15
|
|