codestrap 0.1.0
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 +7 -0
- data/.gitignore +20 -0
- data/.travis.yml +4 -0
- data/.yardopts +3 -0
- data/BOILERPLATE.md +151 -0
- data/CODESTRAPFILE.md +28 -0
- data/Gemfile +6 -0
- data/LICENSE.txt +13 -0
- data/README.md +69 -0
- data/Rakefile +51 -0
- data/bin/strap +8 -0
- data/bin/upstrap +8 -0
- data/codestrap.gemspec +37 -0
- data/config/projects/codestrap.rb +22 -0
- data/config/software/codestrap.rb +20 -0
- data/config/software/ruby.rb +247 -0
- data/config/software/zlib.rb +86 -0
- data/features/client.feature +99 -0
- data/features/fixtures/client/home/codestrap/bin/.empty +0 -0
- data/features/fixtures/client/home/codestrap/content/bash.erb +3 -0
- data/features/fixtures/client/home/codestrap/content/gem/dir/file +0 -0
- data/features/fixtures/client/home/codestrap/content/gem/dir/template +3 -0
- data/features/fixtures/client/home/codestrap/content/gem/file +1 -0
- data/features/fixtures/client/home/codestrap/content/gem/template +3 -0
- data/features/fixtures/client/home/codestrap/content/local_remote.erb +1 -0
- data/features/fixtures/client/home/codestrap/content/local_remote/dir/file +0 -0
- data/features/fixtures/client/home/codestrap/content/local_remote/dir/template +3 -0
- data/features/fixtures/client/home/codestrap/content/local_remote/file +1 -0
- data/features/fixtures/client/home/codestrap/content/local_remote/template +3 -0
- data/features/fixtures/client/home/codestrap/objects/local.json +3 -0
- data/features/fixtures/client/output/.empty +0 -0
- data/features/fixtures/client/var/lib/codestrap/bin/.empty +0 -0
- data/features/fixtures/client/var/lib/codestrap/content/bashremote.erb +3 -0
- data/features/fixtures/client/var/lib/codestrap/content/gemremote/dir/file +0 -0
- data/features/fixtures/client/var/lib/codestrap/content/gemremote/dir/template +3 -0
- data/features/fixtures/client/var/lib/codestrap/content/gemremote/file +0 -0
- data/features/fixtures/client/var/lib/codestrap/content/gemremote/template +3 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_local.erb +1 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_local/dir/file +0 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_local/dir/template +3 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_local/file +1 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_local/template +3 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_remote.erb +1 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_remote/dir/file +0 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_remote/dir/template +3 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_remote/file +0 -0
- data/features/fixtures/client/var/lib/codestrap/content/remote_remote/template +3 -0
- data/features/fixtures/client/var/lib/codestrap/objects/remote.json +3 -0
- data/features/fixtures/logging/home/logging/codestrap/bin/stubdirectory/.empty +0 -0
- data/features/fixtures/logging/home/logging/codestrap/bin/stubnotlink +0 -0
- data/features/fixtures/logging/home/logging/codestrap/content/.empty +0 -0
- data/features/fixtures/logging/home/logging/codestrap/objects/.empty +0 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/address.erb +3 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/cell.erb +3 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/email.erb +3 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/mobile.erb +3 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/name.erb +3 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/phone.erb +3 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/puppetmodule/Modulefile +12 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/puppetmodule/README +17 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/puppetmodule/manifests/init.pp +42 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/puppetmodule/spec/spec_helper.rb +18 -0
- data/features/fixtures/server/mixed/var/lib/stub/content/puppetmodule/tests/init.pp +13 -0
- data/features/fixtures/server/mixed/var/lib/stub/objects/contact.json +8 -0
- data/features/fixtures/server/mixed/var/lib/stub/objects/shadow/contact.json +8 -0
- data/features/fixtures/strap/projects/etc/.empty +0 -0
- data/features/fixtures/strap/projects/home/user/dir/bin/.empty +0 -0
- data/features/fixtures/strap/projects/home/user/dir/content/puppetmodule/Modulefile +12 -0
- data/features/fixtures/strap/projects/home/user/dir/content/puppetmodule/README +17 -0
- data/features/fixtures/strap/projects/home/user/dir/content/puppetmodule/manifests/:stub:project.name:/subclass.pp +3 -0
- data/features/fixtures/strap/projects/home/user/dir/content/puppetmodule/manifests/init.pp +42 -0
- data/features/fixtures/strap/projects/home/user/dir/content/puppetmodule/spec/spec_helper.rb +18 -0
- data/features/fixtures/strap/projects/home/user/dir/content/puppetmodule/tests/init.pp +13 -0
- data/features/fixtures/strap/projects/home/user/dir/objects/contact.json +8 -0
- data/features/fixtures/strap/projects/home/user/dir/objects/shadow/contact.json +8 -0
- data/features/fixtures/strap/projects/output/.empty +0 -0
- data/features/fixtures/stub/contact/etc/.empty +0 -0
- data/features/fixtures/stub/contact/home/user/dir/bin/.empty +0 -0
- data/features/fixtures/stub/contact/home/user/dir/content/address.erb +3 -0
- data/features/fixtures/stub/contact/home/user/dir/content/cell.erb +3 -0
- data/features/fixtures/stub/contact/home/user/dir/content/email.erb +3 -0
- data/features/fixtures/stub/contact/home/user/dir/content/mobile.erb +3 -0
- data/features/fixtures/stub/contact/home/user/dir/content/name.erb +3 -0
- data/features/fixtures/stub/contact/home/user/dir/content/phone.erb +3 -0
- data/features/fixtures/stub/contact/home/user/dir/objects/contact.json +8 -0
- data/features/fixtures/stub/contact/home/user/dir/objects/shadow/contact.json +8 -0
- data/features/fixtures/stub/contact/output/.empty +0 -0
- data/features/fixtures/stub/date/etc/.empty +0 -0
- data/features/fixtures/stub/date/home/user/stub/bin/.empty +0 -0
- data/features/fixtures/stub/date/home/user/stub/content/day.erb +3 -0
- data/features/fixtures/stub/date/home/user/stub/content/hour.erb +3 -0
- data/features/fixtures/stub/date/home/user/stub/content/minute.erb +3 -0
- data/features/fixtures/stub/date/home/user/stub/content/month.erb +3 -0
- data/features/fixtures/stub/date/home/user/stub/content/second.erb +3 -0
- data/features/fixtures/stub/date/home/user/stub/content/year.erb +3 -0
- data/features/fixtures/stub/date/home/user/stub/objects/.empty +0 -0
- data/features/fixtures/stub/date/output/.empty +0 -0
- data/features/fixtures/stub/script/etc/.empty +0 -0
- data/features/fixtures/stub/script/home/user/stub/bin/.empty +0 -0
- data/features/fixtures/stub/script/home/user/stub/content/credentials.erb +6 -0
- data/features/fixtures/stub/script/home/user/stub/objects/credentials.rb +11 -0
- data/features/fixtures/stub/script/output/.empty +0 -0
- data/features/logging.feature +39 -0
- data/features/object_scripts.feature +13 -0
- data/features/server.feature +36 -0
- data/features/step_definitions/client_steps.rb +99 -0
- data/features/step_definitions/logging_steps.rb +65 -0
- data/features/step_definitions/object_scripts_steps.rb +26 -0
- data/features/step_definitions/server_steps.rb +112 -0
- data/features/step_definitions/strap_steps.rb +69 -0
- data/features/step_definitions/stub_option_simple_steps.rb +31 -0
- data/features/step_definitions/stub_steps.rb +94 -0
- data/features/strap.feature +34 -0
- data/features/stub.feature +157 -0
- data/features/stub_option_simple.feature +14 -0
- data/features/stub_packages.feature +15 -0
- data/features/support/env.rb +197 -0
- data/lib/codestrap.rb +415 -0
- data/lib/codestrap/cli.rb +76 -0
- data/lib/codestrap/client.rb +179 -0
- data/lib/codestrap/config.rb +199 -0
- data/lib/codestrap/log.rb +56 -0
- data/lib/codestrap/mixin.rb +20 -0
- data/lib/codestrap/namespace.rb +19 -0
- data/lib/codestrap/object/abstract.rb +33 -0
- data/lib/codestrap/object/factory.rb +86 -0
- data/lib/codestrap/object/standard/datetime.rb +24 -0
- data/lib/codestrap/object/standard/files.rb +40 -0
- data/lib/codestrap/object/standard/project.rb +33 -0
- data/lib/codestrap/object/standard/rest.rb +30 -0
- data/lib/codestrap/patch.rb +122 -0
- data/lib/codestrap/server/rest.rb +177 -0
- data/lib/codestrap/server/version.rb +5 -0
- data/lib/codestrap/strap/abstract.rb +135 -0
- data/lib/codestrap/strap/factory.rb +85 -0
- data/lib/codestrap/strap/standard.rb +95 -0
- data/lib/codestrap/stub/abstract.rb +156 -0
- data/lib/codestrap/stub/factory.rb +87 -0
- data/lib/codestrap/stub/standard.rb +23 -0
- data/lib/codestrap/version.rb +3 -0
- data/omnibus.rb +53 -0
- data/package-scripts/codestrap/postinst +25 -0
- data/package-scripts/codestrap/postrm +17 -0
- data/package-scripts/codestrap/preinst +7 -0
- data/package-scripts/codestrap/prerm +15 -0
- data/resources/codestrap/pkg/background.png +0 -0
- data/resources/codestrap/pkg/distribution.xml.erb +22 -0
- data/resources/codestrap/pkg/license.html.erb +202 -0
- data/resources/codestrap/pkg/welcome.html.erb +7 -0
- metadata +466 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
Given(/^a boilerplate path directory "([^"]*)"$/) do |path|
|
|
2
|
+
@testtools.path_reset
|
|
3
|
+
@testtools.path_unshift(path)
|
|
4
|
+
end
|
|
5
|
+
|
|
6
|
+
And(/^a boilerplate fixture (\d+)$/) do |num|
|
|
7
|
+
@fixture_idx = num.to_i
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
And(/^a boilerplate tmp directory$/) do
|
|
11
|
+
unless @strap_tmpdir
|
|
12
|
+
@strap_tmpdir = Dir.mktmpdir
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
And(/^a boilerplate codestrapfile named "([^"]*)" with:$/) do |codestrapfile, text|
|
|
17
|
+
codestrapfile_path = File.join(@strap_tmpdir, codestrapfile)
|
|
18
|
+
unless File.exist? codestrapfile_path
|
|
19
|
+
file = File.new(codestrapfile_path, 'w')
|
|
20
|
+
file.write(text)
|
|
21
|
+
file.close
|
|
22
|
+
end
|
|
23
|
+
ENV['CODESTRAPFILE']=codestrapfile_path
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
And(/^a boilerplate fixtures file named "([^"]*)" with:$/) do |json, text|
|
|
27
|
+
@fixtures = File.join(@strap_tmpdir, json)
|
|
28
|
+
unless File.exist? @fixtures
|
|
29
|
+
file = File.open(@fixtures, 'w')
|
|
30
|
+
file.write(text)
|
|
31
|
+
file.close
|
|
32
|
+
end
|
|
33
|
+
@fixture_hash = YAML.load(File.read(@fixtures))[@fixture_idx]
|
|
34
|
+
@clear = @fixture_hash['clear'] == 'true'
|
|
35
|
+
@command = @fixture_hash['command']
|
|
36
|
+
@output = @fixture_hash['output']
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
When(/^boilerplate generate command is executed$/) do
|
|
40
|
+
capture = Capture::Cli.inline do
|
|
41
|
+
args = %w(strap --generate)
|
|
42
|
+
Codestrap::Core.new(args).execute!
|
|
43
|
+
end
|
|
44
|
+
expect(capture.object_exit.status).to eql(0)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
And(/^boilerplate command is run$/) do
|
|
48
|
+
if @clear
|
|
49
|
+
FileUtils.rm_rf @output
|
|
50
|
+
end
|
|
51
|
+
@capture = Capture::Cli.inline do
|
|
52
|
+
args = [@command, @output]
|
|
53
|
+
Codestrap::Core.new(args).execute!
|
|
54
|
+
end
|
|
55
|
+
expect(File.directory?(@output)).to be_truthy
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
Then(/^boilerplate contains interpolated values$/) do
|
|
59
|
+
Tools::Test.contents(@fixture_hash['test']) do |content, str, bool|
|
|
60
|
+
case bool
|
|
61
|
+
when 'true'
|
|
62
|
+
expect(content).to include(str)
|
|
63
|
+
when 'false'
|
|
64
|
+
expect(content).not_to include(str)
|
|
65
|
+
else
|
|
66
|
+
fail "Expecting boolean got #{bool.to_s}"
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
When(/^the command "(strap)" with option "([^"]+)" is executed/) do |cmd, opt|
|
|
2
|
+
@testtools.path_reset
|
|
3
|
+
@testtools.path_unshift(BINDIR)
|
|
4
|
+
@cap_simple = Capture::Cli.inline do
|
|
5
|
+
args = [cmd, opt]
|
|
6
|
+
Codestrap::Core.new(args).execute!
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
Then(/^the option output is greater then (\d+) bytes$/) do |size|
|
|
11
|
+
expect(@cap_simple.stdout.length).to be > size.to_i
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
And(/^the option option exit status should be (\d+)$/) do |status|
|
|
15
|
+
expect(@cap_simple.object_exit.status.to_i).to eq(status.to_i)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
When(/^the version is requested through the "(.*?)" option \-\-version is provided$/) do |cmd|
|
|
19
|
+
@cap_version = Capture::Cli.new(true, false).inline do
|
|
20
|
+
args = [cmd, '--version']
|
|
21
|
+
Codestrap::Core.new(args).execute!
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
Then(/^the version option exit status is (\d+)$/) do |status|
|
|
26
|
+
expect(@cap_version.object_exit.status).to eq(status.to_i)
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
And(/^a version number is outputed$/) do
|
|
30
|
+
expect(@cap_version.stdout.chomp).to eql(Codestrap::VERSION)
|
|
31
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
Given(/^a stub tmp directory$/) do
|
|
2
|
+
unless @codestrap_tmp
|
|
3
|
+
@codestrap_tmp = Dir.mktmpdir
|
|
4
|
+
end
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
And(/^a stub fixtures file "([^"]*)" with:$/) do |yaml, text|
|
|
8
|
+
@codestrap_fixtures = File.join(@codestrap_tmp, yaml)
|
|
9
|
+
file = File.open(@codestrap_fixtures, 'w')
|
|
10
|
+
file.write(text)
|
|
11
|
+
file.close
|
|
12
|
+
@fixture_hash = YAML.load(text)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
And(/^a stub fixture "([^"]+)"$/) do |command|
|
|
16
|
+
@command = command
|
|
17
|
+
@fixture_cur = @fixture_hash[@command]
|
|
18
|
+
@links = @fixture_cur['links']
|
|
19
|
+
@clear = @fixture_cur['clear']
|
|
20
|
+
@output = @fixture_cur['output']
|
|
21
|
+
@test = @fixture_cur['test']
|
|
22
|
+
sf_content = @fixture_cur['codestrapfile']
|
|
23
|
+
sf_path = File.join(@codestrap_tmp, 'Codestrapfile')
|
|
24
|
+
sf_file = File.open(sf_path, 'w')
|
|
25
|
+
sf_file.write sf_content
|
|
26
|
+
sf_file.close
|
|
27
|
+
ENV['CODESTRAPFILE']=sf_path
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
And(/^stub env variable for PATH$/) do
|
|
31
|
+
@testtools.path_reset
|
|
32
|
+
@testtools.path_unshift(@links)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
#And(/^codestrap env variable CODESTRAP_CONF="([^"]*)"$/) do |codestrapconf|
|
|
36
|
+
# ENV['CODESTRAP_CONF'] = codestrapconf
|
|
37
|
+
#end
|
|
38
|
+
#
|
|
39
|
+
#And(/^codestrap env variable CODESTRAP_ETC="([^"]+)"$/) do |codestrapetc|
|
|
40
|
+
# ENV['CODESTRAP_ETC'] = @codestrapetc = codestrapetc
|
|
41
|
+
#end
|
|
42
|
+
#
|
|
43
|
+
#And(/^codestrap env variable HOME="(codestrap\/contact\/home\/user)"$/) do |home|
|
|
44
|
+
# ENV['HOME'] = @codestraphome = home
|
|
45
|
+
#end
|
|
46
|
+
#
|
|
47
|
+
#And(/^a interpolation template named "([^"]*)"$/) do |templatefile|
|
|
48
|
+
# templatefile =~ /(.erb)$/
|
|
49
|
+
# suffix = $1 if $1
|
|
50
|
+
# @basename = File.basename(templatefile)
|
|
51
|
+
# FileUtils.install File.join(FIXTURES, templatefile), File.join(@codestrapetc, @basename)
|
|
52
|
+
# if suffix
|
|
53
|
+
# @cmd = 'codestrap' + File.basename(templatefile, suffix)
|
|
54
|
+
# else
|
|
55
|
+
# @cmd = 'codestrap' + File.basename(templatefile)
|
|
56
|
+
# end
|
|
57
|
+
#end
|
|
58
|
+
|
|
59
|
+
When(/^generate$/) do
|
|
60
|
+
@cap_generate_interpolate_links = Capture::Cli.inline do
|
|
61
|
+
args = %w(strap --generate)
|
|
62
|
+
Codestrap::Core.new(args).execute!
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
And(/^clear previous files$/) do
|
|
67
|
+
if @clear and File.exist? @output
|
|
68
|
+
File.unlink @output
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
And(/^template is run with output$/) do
|
|
73
|
+
@cap_interpolate_contact_output = Capture::Cli.inline do
|
|
74
|
+
args = [@command, @output]
|
|
75
|
+
Codestrap::Core.new(args).execute!
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
Then(/^contains interpolated values$/) do
|
|
80
|
+
@test.each_pair do |str, bool|
|
|
81
|
+
case bool
|
|
82
|
+
when true
|
|
83
|
+
expect(File.read(@output)).to include(str)
|
|
84
|
+
when false
|
|
85
|
+
expect(File.read(@output)).not_to include(str)
|
|
86
|
+
else
|
|
87
|
+
fail 'Invalid check'
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
And(/^the exit status is (\d+)$/) do |status|
|
|
93
|
+
expect(@cap_interpolate_contact_output.object_exit.status.to_i).to eq(status.to_i)
|
|
94
|
+
end
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
Feature: Supports straps
|
|
2
|
+
As a user I want a command that supports creation
|
|
3
|
+
of a software project structure containing template output
|
|
4
|
+
that has interpolated objects
|
|
5
|
+
|
|
6
|
+
Scenario Outline: create a new project
|
|
7
|
+
Given a boilerplate path directory "strap/projects/home/user/dir/bin"
|
|
8
|
+
And a boilerplate fixture <number>
|
|
9
|
+
And a boilerplate tmp directory
|
|
10
|
+
And a boilerplate codestrapfile named "Codestrapfile" with:
|
|
11
|
+
"""
|
|
12
|
+
Codestrapfile.config do |conf|
|
|
13
|
+
conf.local.base = ['strap/projects/home/user/dir']
|
|
14
|
+
end
|
|
15
|
+
"""
|
|
16
|
+
And a boilerplate fixtures file named "fixtures.yaml" with:
|
|
17
|
+
"""
|
|
18
|
+
---
|
|
19
|
+
- clear: 'true'
|
|
20
|
+
command: strappuppetmodule
|
|
21
|
+
output: strap/projects/output/newpuppet
|
|
22
|
+
test:
|
|
23
|
+
strap/projects/output/newpuppet/Modulefile:
|
|
24
|
+
Michonne: 'true'
|
|
25
|
+
strap/projects/output/newpuppet/manifests/init.pp:
|
|
26
|
+
Michonne: 'true'
|
|
27
|
+
dpgrps@gmail.com: 'true'
|
|
28
|
+
"""
|
|
29
|
+
When boilerplate generate command is executed
|
|
30
|
+
And boilerplate command is run
|
|
31
|
+
Then boilerplate contains interpolated values
|
|
32
|
+
Examples:
|
|
33
|
+
| number |
|
|
34
|
+
| 0 |
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
Feature: Supports stubs
|
|
2
|
+
As a user I want a command that supports file stubs
|
|
3
|
+
of text files
|
|
4
|
+
that contain interpolated objects
|
|
5
|
+
|
|
6
|
+
Scenario Outline: stub creation
|
|
7
|
+
Given a stub tmp directory
|
|
8
|
+
And a stub fixtures file "fixtures.yaml" with:
|
|
9
|
+
"""
|
|
10
|
+
stubaddress:
|
|
11
|
+
clear: true
|
|
12
|
+
links: stub/contact/home/user/dir/bin
|
|
13
|
+
output: stub/contact/output/address
|
|
14
|
+
codestrapfile: |
|
|
15
|
+
Codestrapfile.config do |conf|
|
|
16
|
+
conf.local.base = ['stub/contact/home/user/dir']
|
|
17
|
+
end
|
|
18
|
+
test:
|
|
19
|
+
'10 Downing Street': true
|
|
20
|
+
stubcell:
|
|
21
|
+
clear: true
|
|
22
|
+
links: stub/contact/home/user/dir/bin
|
|
23
|
+
output: stub/contact/output/cell
|
|
24
|
+
codestrapfile: |
|
|
25
|
+
Codestrapfile.config do |conf|
|
|
26
|
+
conf.local.base = ['stub/contact/home/user/dir']
|
|
27
|
+
end
|
|
28
|
+
test:
|
|
29
|
+
'0555 5555 5555': true
|
|
30
|
+
stubemail:
|
|
31
|
+
clear: true
|
|
32
|
+
links: stub/contact/home/user/dir/bin
|
|
33
|
+
output: stub/contact/output/email
|
|
34
|
+
codestrapfile: |
|
|
35
|
+
Codestrapfile.config do |conf|
|
|
36
|
+
conf.local.base = ['stub/contact/home/user/dir']
|
|
37
|
+
end
|
|
38
|
+
test:
|
|
39
|
+
'dpgrps@gmail.com': true
|
|
40
|
+
stubmobile:
|
|
41
|
+
clear: true
|
|
42
|
+
links: stub/contact/home/user/dir/bin
|
|
43
|
+
output: stub/contact/output/mobile
|
|
44
|
+
codestrapfile: |
|
|
45
|
+
Codestrapfile.config do |conf|
|
|
46
|
+
conf.local.base = ['stub/contact/home/user/dir']
|
|
47
|
+
end
|
|
48
|
+
test:
|
|
49
|
+
'0444 4444 4444': true
|
|
50
|
+
stubname:
|
|
51
|
+
clear: true
|
|
52
|
+
links: stub/contact/home/user/dir/bin
|
|
53
|
+
output: stub/contact/output/name
|
|
54
|
+
codestrapfile: |
|
|
55
|
+
Codestrapfile.config do |conf|
|
|
56
|
+
conf.local.base = ['stub/contact/home/user/dir']
|
|
57
|
+
end
|
|
58
|
+
test:
|
|
59
|
+
'Full Name': true
|
|
60
|
+
stubphone:
|
|
61
|
+
clear: true
|
|
62
|
+
links: stub/contact/home/user/dir/bin
|
|
63
|
+
output: stub/contact/output/phone
|
|
64
|
+
codestrapfile: |
|
|
65
|
+
Codestrapfile.config do |conf|
|
|
66
|
+
conf.local.base = ['stub/contact/home/user/dir']
|
|
67
|
+
end
|
|
68
|
+
test:
|
|
69
|
+
'7777 7777': true
|
|
70
|
+
stubyear:
|
|
71
|
+
clear: true
|
|
72
|
+
links: stub/date/home/user/stub/bin
|
|
73
|
+
output: stub/date/output/year
|
|
74
|
+
codestrapfile: |
|
|
75
|
+
Codestrapfile.config do |conf|
|
|
76
|
+
conf.local.base = ['stub/date/home/user/stub']
|
|
77
|
+
end
|
|
78
|
+
test: {}
|
|
79
|
+
stubmonth:
|
|
80
|
+
clear: true
|
|
81
|
+
links: stub/date/home/user/stub/bin
|
|
82
|
+
output: stub/date/output/month
|
|
83
|
+
codestrapfile: |
|
|
84
|
+
Codestrapfile.config do |conf|
|
|
85
|
+
conf.local.base = ['stub/date/home/user/stub']
|
|
86
|
+
end
|
|
87
|
+
test: {}
|
|
88
|
+
stubday:
|
|
89
|
+
clear: true
|
|
90
|
+
links: stub/date/home/user/stub/bin
|
|
91
|
+
output: stub/date/output/day
|
|
92
|
+
codestrapfile: |
|
|
93
|
+
Codestrapfile.config do |conf|
|
|
94
|
+
conf.local.base = ['stub/date/home/user/stub']
|
|
95
|
+
end
|
|
96
|
+
test: {}
|
|
97
|
+
stubhour:
|
|
98
|
+
clear: true
|
|
99
|
+
links: stub/date/home/user/stub/bin
|
|
100
|
+
output: stub/date/output/hour
|
|
101
|
+
codestrapfile: |
|
|
102
|
+
Codestrapfile.config do |conf|
|
|
103
|
+
conf.local.base = ['stub/date/home/user/stub']
|
|
104
|
+
end
|
|
105
|
+
test: {}
|
|
106
|
+
stubminute:
|
|
107
|
+
clear: true
|
|
108
|
+
links: stub/date/home/user/stub/bin
|
|
109
|
+
output: stub/date/output/minute
|
|
110
|
+
codestrapfile: |
|
|
111
|
+
Codestrapfile.config do |conf|
|
|
112
|
+
conf.local.base = ['stub/date/home/user/stub']
|
|
113
|
+
end
|
|
114
|
+
test: {}
|
|
115
|
+
stubsecond:
|
|
116
|
+
clear: true
|
|
117
|
+
links: stub/date/home/user/stub/bin
|
|
118
|
+
output: stub/date/output/second
|
|
119
|
+
codestrapfile: |
|
|
120
|
+
Codestrapfile.config do |conf|
|
|
121
|
+
conf.local.base = ['stub/date/home/user/stub']
|
|
122
|
+
end
|
|
123
|
+
test: {}
|
|
124
|
+
stubcredentials:
|
|
125
|
+
clear: true
|
|
126
|
+
links: stub/script/home/user/stub/bin
|
|
127
|
+
output: stub/script/output/credentials
|
|
128
|
+
codestrapfile: |
|
|
129
|
+
Codestrapfile.config do |conf|
|
|
130
|
+
conf.local.base = ['stub/script/home/user/stub']
|
|
131
|
+
end
|
|
132
|
+
test:
|
|
133
|
+
'noreply@nodomain.com': true
|
|
134
|
+
'secret': true
|
|
135
|
+
"""
|
|
136
|
+
And a stub fixture "<command>"
|
|
137
|
+
And stub env variable for PATH
|
|
138
|
+
When generate
|
|
139
|
+
And clear previous files
|
|
140
|
+
And template is run with output
|
|
141
|
+
Then contains interpolated values
|
|
142
|
+
And the exit status is 0
|
|
143
|
+
Examples:
|
|
144
|
+
| command |
|
|
145
|
+
| stubaddress |
|
|
146
|
+
| stubcell |
|
|
147
|
+
| stubemail |
|
|
148
|
+
| stubmobile |
|
|
149
|
+
| stubname |
|
|
150
|
+
| stubphone |
|
|
151
|
+
| stubyear |
|
|
152
|
+
| stubmonth |
|
|
153
|
+
| stubday |
|
|
154
|
+
| stubhour |
|
|
155
|
+
| stubminute |
|
|
156
|
+
| stubsecond |
|
|
157
|
+
| stubcredentials |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
Feature: strap --help and --version
|
|
2
|
+
Command supports the help and version options
|
|
3
|
+
|
|
4
|
+
Scenario Outline: Simple options
|
|
5
|
+
When the command "strap" with option "<simple_option>" is executed
|
|
6
|
+
Then the option output is greater then 0 bytes
|
|
7
|
+
And the option option exit status should be 0
|
|
8
|
+
Examples: help
|
|
9
|
+
| simple_option |
|
|
10
|
+
| --help |
|
|
11
|
+
| -h |
|
|
12
|
+
| -? |
|
|
13
|
+
| -v |
|
|
14
|
+
| --version |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
Feature: Package management
|
|
2
|
+
As a user, I will utilize a package, codestrap, modules manager for templates
|
|
3
|
+
to download available packages from a package server(s).
|
|
4
|
+
|
|
5
|
+
Scenario Outline: Package management
|
|
6
|
+
Given test "<data>" set
|
|
7
|
+
And environment variables
|
|
8
|
+
When command "<command>" is executed
|
|
9
|
+
And input
|
|
10
|
+
Then a set of are created
|
|
11
|
+
And output has the right contents and format
|
|
12
|
+
And error has the right contents and format
|
|
13
|
+
And exit code has expected values
|
|
14
|
+
Examples:
|
|
15
|
+
| data | command |
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
require 'cucumber'
|
|
2
|
+
require 'find'
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'json'
|
|
5
|
+
require 'rack/test'
|
|
6
|
+
require 'rspec/expectations'
|
|
7
|
+
require 'codestrap'
|
|
8
|
+
require 'codestrap/version'
|
|
9
|
+
require 'codestrap/server/rest'
|
|
10
|
+
require 'stringio'
|
|
11
|
+
require 'tempfile'
|
|
12
|
+
require 'tmpdir'
|
|
13
|
+
require 'webmock/cucumber'
|
|
14
|
+
require 'yaml'
|
|
15
|
+
|
|
16
|
+
ROOT = File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
|
|
17
|
+
FIXTURE_ROOT = File.join(ROOT, 'features', 'fixtures')
|
|
18
|
+
BINDIR = File.join(ROOT, 'bin')
|
|
19
|
+
TMPDIR = File.join(ROOT, 'tmp')
|
|
20
|
+
FIXTURES = %W[stub strap server client logging]
|
|
21
|
+
|
|
22
|
+
$LOAD_PATH.unshift File.join(ROOT, 'lib')
|
|
23
|
+
|
|
24
|
+
Codestrap::Server::Rest.set :environment => :development
|
|
25
|
+
|
|
26
|
+
class MyWorld
|
|
27
|
+
include Rack::Test::Methods
|
|
28
|
+
|
|
29
|
+
def app
|
|
30
|
+
@app = Rack::Builder.new do
|
|
31
|
+
run Codestrap::Server::Rest
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
World do
|
|
37
|
+
MyWorld.new
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
def diff_tree?(left, right)
|
|
41
|
+
left_tree = []
|
|
42
|
+
Dir.chdir(left) do
|
|
43
|
+
left_tree = Dir.glob('**').sort { |a,b| a.length <=> b.length }
|
|
44
|
+
end
|
|
45
|
+
right_tree = []
|
|
46
|
+
Dir.chdir(right) do
|
|
47
|
+
right_tree = Dir.glob('**').sort { |a,b| a.length <=> b.length }
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
if left_tree != right_tree
|
|
51
|
+
return 1
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
left_tree.each do |file|
|
|
55
|
+
left_file = File.join(left, file)
|
|
56
|
+
right_file = File.join(right, file)
|
|
57
|
+
left_stat = File::Stat.new(left_file)
|
|
58
|
+
right_stat = File::Stat.new(right_file)
|
|
59
|
+
if left_stat.ftype != right_stat.ftype
|
|
60
|
+
return 1
|
|
61
|
+
end
|
|
62
|
+
next if left_stat.directory?
|
|
63
|
+
unless FileUtils.compare_file(left_file, right_file)
|
|
64
|
+
return 1
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
0
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Capture cli methods
|
|
72
|
+
module Capture
|
|
73
|
+
class Cli
|
|
74
|
+
# Get & Set
|
|
75
|
+
attr_reader :object_exit
|
|
76
|
+
attr_reader :stdout
|
|
77
|
+
attr_reader :stderr
|
|
78
|
+
|
|
79
|
+
def object_exit= object_exit
|
|
80
|
+
raise TypeError, %q[expecting type SystemExit] unless object_exit.is_a?(SystemExit)
|
|
81
|
+
@object_exit = object_exit
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def initialize(divertstdout=true, divertstderr=false)
|
|
85
|
+
@stdout ||= String.new
|
|
86
|
+
@stderr ||= String.new
|
|
87
|
+
@divertstdout = divertstdout
|
|
88
|
+
@divertsterr = divertstderr
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
def inline
|
|
92
|
+
begin
|
|
93
|
+
if @divertstdout
|
|
94
|
+
@origstdout = $stdout
|
|
95
|
+
$stdout = StringIO.new(@stdout)
|
|
96
|
+
end
|
|
97
|
+
if @divertstderr
|
|
98
|
+
@origstderr = $stderr
|
|
99
|
+
$stderr = StringIO.new(@stderr)
|
|
100
|
+
end
|
|
101
|
+
yield
|
|
102
|
+
rescue SystemExit => e
|
|
103
|
+
self.object_exit = e
|
|
104
|
+
ensure
|
|
105
|
+
$stdout = @origstdout if @divertstdout
|
|
106
|
+
$stderr = @origstderr if @divertsterr
|
|
107
|
+
end
|
|
108
|
+
self
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
def self.inline
|
|
112
|
+
Capture::Cli.new().inline do
|
|
113
|
+
yield
|
|
114
|
+
end
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
module Tools
|
|
120
|
+
class Cli
|
|
121
|
+
def initialize
|
|
122
|
+
@env_original = ENV['PATH']
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
def path_unshift path
|
|
126
|
+
unless ENV['PATH'].split(':').include?(path.to_s)
|
|
127
|
+
ENV['PATH'] = "#{path}:#{ENV['PATH']}"
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
def path_reset
|
|
132
|
+
ENV['PATH'] = @env_original
|
|
133
|
+
end
|
|
134
|
+
end
|
|
135
|
+
class Test
|
|
136
|
+
def self.list_tree(project)
|
|
137
|
+
Find.find(project).map { |dir| dir.gsub(/#{Regexp.escape(project)}/, '') }
|
|
138
|
+
end
|
|
139
|
+
|
|
140
|
+
def self.contents(test_hash)
|
|
141
|
+
test_hash.each_pair do |file, tests|
|
|
142
|
+
content = File.read(File.join(file))
|
|
143
|
+
tests.each_pair do |str, bool|
|
|
144
|
+
yield content, str, bool
|
|
145
|
+
end
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
module JSON
|
|
152
|
+
def self.is_json?(foo)
|
|
153
|
+
begin
|
|
154
|
+
return false unless foo.is_a?(String)
|
|
155
|
+
JSON.parse(foo).all?
|
|
156
|
+
rescue JSON::ParserError
|
|
157
|
+
false
|
|
158
|
+
end
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
Before do
|
|
163
|
+
# Web mock
|
|
164
|
+
WebMock.allow_net_connect!
|
|
165
|
+
stub_request(:any, /127.0.0.1/).to_rack(Codestrap::Server::Rest)
|
|
166
|
+
|
|
167
|
+
# Copy fixures to tmp/
|
|
168
|
+
FIXTURES.each do |dir|
|
|
169
|
+
fixture = File.join(FIXTURE_ROOT, dir)
|
|
170
|
+
newpath = File.join(TMPDIR, dir)
|
|
171
|
+
cmd = File.join(BINDIR, 'strap')
|
|
172
|
+
next unless File.exist? fixture
|
|
173
|
+
FileUtils.cp_r fixture, TMPDIR
|
|
174
|
+
Dir.glob("#{newpath}/**/bin").each do |path|
|
|
175
|
+
stub = File.join(path, 'stub')
|
|
176
|
+
strap = File.join(path, 'strap')
|
|
177
|
+
FileUtils.cp cmd, strap unless File.exist? strap
|
|
178
|
+
FileUtils.ln_s strap, stub unless File.exist? stub
|
|
179
|
+
end
|
|
180
|
+
end
|
|
181
|
+
|
|
182
|
+
# Set path
|
|
183
|
+
@testtools = Tools::Cli.new()
|
|
184
|
+
|
|
185
|
+
# Project temporary directory
|
|
186
|
+
@tmpdir = TMPDIR
|
|
187
|
+
|
|
188
|
+
# Current directory
|
|
189
|
+
@curdir = Dir.getwd
|
|
190
|
+
|
|
191
|
+
# Original environment variable
|
|
192
|
+
Dir.chdir @tmpdir
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
After do
|
|
196
|
+
Dir.chdir @curdir
|
|
197
|
+
end
|