gordon 0.0.21 → 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.
@@ -2,18 +2,38 @@ require 'spec_helper'
2
2
 
3
3
  describe Gordon::CLI do
4
4
  describe 'running a recipe' do
5
- it 'cooks a recipe based on options' do
6
- options = instance_double Gordon::Options
5
+ let(:options) { instance_double Gordon::Options }
6
+ let(:recipe) { instance_double Gordon::Recipe }
7
+ let(:cooker) { instance_double Gordon::Cooker }
8
+ let(:recipes) { [ recipe ] }
9
+
10
+ before :each do
7
11
  expect(options).to receive(:app_source=).with(Dir.pwd)
8
12
  expect(options).to receive(:output_dir=).with(Dir.pwd)
13
+
9
14
  expect(Gordon::Options).to receive(:new).and_return(options)
15
+ end
16
+
17
+ it 'cooks a single recipe based on options' do
18
+ expect(Gordon::Cookbook).to receive(:exists?).and_return(false)
19
+ expect(Gordon::Cookbook).to_not receive(:read_and_merge_with)
10
20
 
11
- recipe = instance_double Gordon::Recipe
12
21
  expect(Gordon::Recipe).to receive(:new).with(options).and_return(recipe)
22
+ expect(Gordon::Cooker).to receive(:new).with(recipes).and_return(cooker)
23
+
24
+ expect(cooker).to receive(:cook)
25
+
26
+ described_class.run
27
+ end
28
+
29
+ it 'cooks a list of recipes based on cookbook file' do
30
+ expect(Gordon::Cookbook).to receive(:exists?).and_return(true)
31
+ expect(Gordon::Cookbook).to receive(:read_and_merge_with).with(options).and_return(recipes)
32
+
33
+ expect(Gordon::Recipe).to_not receive(:new)
34
+ expect(Gordon::Cooker).to receive(:new).with(recipes).and_return(cooker)
13
35
 
14
- cooker = instance_double Gordon::Cooker
15
36
  expect(cooker).to receive(:cook)
16
- expect(Gordon::Cooker).to receive(:new).with(recipe).and_return(cooker)
17
37
 
18
38
  described_class.run
19
39
  end
@@ -24,21 +44,22 @@ describe Gordon::CLI do
24
44
 
25
45
  let(:options_map) do
26
46
  [
27
- [ %w(-N --app-name), "gordon" ],
28
- [ %w(-D --app-description), "a packager" ],
29
- [ %w(-G --app-homepage), "https://github.com/salizzar/gordon" ],
30
- [ %w(-V --app-version), Gordon::VERSION ],
31
- [ %w(-S --app-source), "." ],
32
- [ %w(-T --app-type), "ruby_web_app" ],
33
- [ %w(-X --runtime-name), "ruby" ],
34
- [ %w(-R --runtime-version), "2.2.0" ],
35
- [ %w(-H --http-server-type), "nginx" ],
36
- [ %w(-W --web-server-type), "unicorn" ],
37
- [ %w(-I --init-type), "systemd" ],
38
- [ %w(-P --package-type), "rpm" ],
39
- [ %w(-O --output-dir), "pkg" ],
40
- [ %w(-d --debug), true ],
41
- [ %w(-t --trace), true ],
47
+ [ %w(-N --app-name), "gordon" ],
48
+ [ %w(-D --app-description), "a packager" ],
49
+ [ %w(-G --app-homepage), "https://github.com/salizzar/gordon" ],
50
+ [ %w(-V --app-version), Gordon::VERSION ],
51
+ [ %w(-S --app-source), "." ],
52
+ [ %w(-E --app-source-excludes), %(an path) ],
53
+ [ %w(-T --app-type), "web" ],
54
+ [ %w(-X --runtime-name), "ruby" ],
55
+ [ %w(-R --runtime-version), "2.2.0" ],
56
+ [ %w(-H --http-server-type), "nginx" ],
57
+ [ %w(-W --web-server-type), "unicorn" ],
58
+ [ %w(-I --init-type), "systemd" ],
59
+ [ %w(-P --package-type), "rpm" ],
60
+ [ %w(-O --output-dir), "pkg" ],
61
+ [ %w(-d --debug), true ],
62
+ [ %w(-t --trace), true ],
42
63
  ]
43
64
  end
44
65
 
@@ -0,0 +1,56 @@
1
+ require 'spec_helper'
2
+
3
+ describe Gordon::Cookbook do
4
+ let(:path) { File.join(Dir.pwd, 'gordon.yml') }
5
+
6
+ context 'checking if file exists' do
7
+ it 'returns true when exists' do
8
+ expect(File).to receive(:exists?).with(path).and_return(true)
9
+
10
+ expect(described_class.exists?).to be_truthy
11
+ end
12
+
13
+ it 'returns false otherwise' do
14
+ expect(File).to receive(:exists?).with(path).and_return(false)
15
+
16
+ expect(described_class.exists?).to be_falsey
17
+ end
18
+ end
19
+
20
+ context 'reading and merging with main options' do
21
+ let(:content) do
22
+ %{
23
+ recipes:
24
+ - app_name: gordon
25
+ app_description: some description
26
+ app_homepage: https://github.com/salizzar/gordon
27
+ app_version: <%= 1 + 1 %>.0.0
28
+ app_type: web
29
+ app_source: .
30
+ }
31
+ end
32
+
33
+ let(:result) { ERB.new(content).result }
34
+ let(:yaml) { YAML.load(result) }
35
+
36
+ let(:main_options) { instance_double(Gordon::Options) }
37
+ let(:recipe) { instance_double(Gordon::Recipe) }
38
+ let(:recipes) { [ recipe ] }
39
+
40
+ it 'renders gordon yaml file and returns a list of recipes' do
41
+ expect(File).to receive(:read).with(path).and_return(content)
42
+
43
+ erb = instance_double(ERB)
44
+ expect(erb).to receive(:result).and_return(result)
45
+ expect(ERB).to receive(:new).with(content).and_return(erb)
46
+ expect(YAML).to receive(:load).with(result).and_return(yaml)
47
+
48
+ option = instance_double(Gordon::Options)
49
+ expect(Gordon::Options).to receive(:from).with(main_options, yaml['recipes'].first).and_return(option)
50
+ expect(Gordon::Recipe).to receive(:new).with(option).and_return(recipe)
51
+
52
+ expect(described_class.read_and_merge_with(main_options)).to eq(recipes)
53
+ end
54
+ end
55
+ end
56
+
@@ -3,28 +3,29 @@ require 'spec_helper'
3
3
  describe Gordon::Cooker do
4
4
  let(:options) do
5
5
  attrs = {
6
- app_type: "web",
7
- app_name: "gordon",
8
- app_description: "a packager",
9
- app_homepage: "https://github.com/salizzar/gordon",
10
- app_version: Gordon::VERSION,
11
- app_source: ".",
12
- runtime_name: "ruby",
13
- runtime_version: "2.2.0",
14
- http_server_type: "nginx",
15
- web_server_type: "unicorn",
16
- init_type: "systemd",
17
- package_type: "rpm",
18
- output_dir: "pkg",
19
- debug: true,
20
- trace: true,
6
+ app_type: "web",
7
+ app_name: "gordon",
8
+ app_description: "a packager",
9
+ app_homepage: "https://github.com/salizzar/gordon",
10
+ app_version: Gordon::VERSION,
11
+ app_source: ".",
12
+ app_source_excludes: %w(an path),
13
+ runtime_name: "ruby",
14
+ runtime_version: "2.2.0",
15
+ http_server_type: "nginx",
16
+ web_server_type: "unicorn",
17
+ init_type: "systemd",
18
+ package_type: "rpm",
19
+ output_dir: "pkg",
20
+ debug: true,
21
+ trace: true,
21
22
  }
22
23
 
23
24
  instance_double(Gordon::Options, attrs)
24
25
  end
25
26
 
26
- let(:recipe) do
27
- instance_double(Gordon::Recipe, options: options, application_template_path: '/a/path')
27
+ let(:recipes) do
28
+ [ instance_double(Gordon::Recipe, options: options, application_template_path: '/a/path') ]
28
29
  end
29
30
 
30
31
  let(:env_vars) do
@@ -36,7 +37,7 @@ describe Gordon::Cooker do
36
37
  File.join(described_class::FPM_COOKERY_WORKING_DIR, app_name)
37
38
  end
38
39
 
39
- subject { described_class.new(recipe) }
40
+ subject { described_class.new(recipes) }
40
41
 
41
42
  before :each do
42
43
  allow(subject).to receive(:debug)
@@ -67,7 +68,7 @@ describe Gordon::Cooker do
67
68
  #{File.expand_path(working_path)}
68
69
  --no-deps
69
70
  package
70
- #{recipe.application_template_path}
71
+ #{recipes[0].application_template_path}
71
72
  }
72
73
 
73
74
  expect(Gordon::Process).to receive(:run).with(package_command.join " ")
@@ -43,16 +43,48 @@ describe Gordon::Cookery::DependencyResolver do
43
43
  end
44
44
  end
45
45
 
46
- context 'given a java standalone app' do
47
- it 'returns all dependencies for web' do
46
+ context 'given a java app' do
47
+ it 'handles Oracle JRE 7 package' do
48
+ allow(env_vars).to receive(:http_server_type).and_return("apache")
49
+ expect(env_vars).to receive(:runtime_name).and_return("oracle-jre")
50
+ allow(env_vars).to receive(:runtime_version).and_return("1.7.0_80")
51
+ allow(env_vars).to receive(:web_server_type).and_return("tomcat")
52
+ expect(env_vars).to receive(:init_type).and_return("")
53
+
54
+ expected = [
55
+ "jre = 1.7.0_80",
56
+ "httpd",
57
+ "tomcat",
58
+ ]
59
+
60
+ expect(subject.resolve_dependencies(env_vars, :centos)).to eq(expected)
61
+ end
62
+
63
+ it 'handles Oracle JRE 8 package' do
64
+ allow(env_vars).to receive(:http_server_type).and_return("apache")
65
+ expect(env_vars).to receive(:runtime_name).and_return("oracle-jre")
66
+ allow(env_vars).to receive(:runtime_version).and_return("1.8.0_45")
67
+ allow(env_vars).to receive(:web_server_type).and_return("tomcat")
68
+ expect(env_vars).to receive(:init_type).and_return("")
69
+
70
+ expected = [
71
+ "jre1.8.0_45",
72
+ "httpd",
73
+ "tomcat",
74
+ ]
75
+
76
+ expect(subject.resolve_dependencies(env_vars, :centos)).to eq(expected)
77
+ end
78
+
79
+ it 'handles Oracle JDK 7 package' do
48
80
  allow(env_vars).to receive(:http_server_type).and_return("apache")
49
- expect(env_vars).to receive(:runtime_name).and_return("java-oracle")
50
- allow(env_vars).to receive(:runtime_version).and_return("1.7.0_60")
81
+ expect(env_vars).to receive(:runtime_name).and_return("oracle-jdk")
82
+ allow(env_vars).to receive(:runtime_version).and_return("1.7.0_80")
51
83
  allow(env_vars).to receive(:web_server_type).and_return("tomcat")
52
84
  expect(env_vars).to receive(:init_type).and_return("")
53
85
 
54
86
  expected = [
55
- "jre = 1.7.0_60",
87
+ "jdk = 1.7.0_80",
56
88
  "httpd",
57
89
  "tomcat",
58
90
  ]
@@ -60,15 +92,15 @@ describe Gordon::Cookery::DependencyResolver do
60
92
  expect(subject.resolve_dependencies(env_vars, :centos)).to eq(expected)
61
93
  end
62
94
 
63
- it 'handles damn Oracle JRE 8 package name' do
95
+ it 'handles Oracle JDK 8 package' do
64
96
  allow(env_vars).to receive(:http_server_type).and_return("apache")
65
- expect(env_vars).to receive(:runtime_name).and_return("java-oracle")
66
- allow(env_vars).to receive(:runtime_version).and_return("1.8.0_25")
97
+ expect(env_vars).to receive(:runtime_name).and_return("oracle-jdk")
98
+ allow(env_vars).to receive(:runtime_version).and_return("1.8.0_45")
67
99
  allow(env_vars).to receive(:web_server_type).and_return("tomcat")
68
100
  expect(env_vars).to receive(:init_type).and_return("")
69
101
 
70
102
  expected = [
71
- "jre1.8.0_25",
103
+ "jdk1.8.0_45",
72
104
  "httpd",
73
105
  "tomcat",
74
106
  ]
@@ -78,8 +110,8 @@ describe Gordon::Cookery::DependencyResolver do
78
110
 
79
111
  it 'handles OpenJDK package name for centos' do
80
112
  allow(env_vars).to receive(:http_server_type).and_return("apache")
81
- expect(env_vars).to receive(:runtime_name).and_return("java-openjdk")
82
- allow(env_vars).to receive(:runtime_version).and_return("1.7.0_60")
113
+ expect(env_vars).to receive(:runtime_name).and_return("openjdk")
114
+ allow(env_vars).to receive(:runtime_version).and_return("1.7.0_80")
83
115
  allow(env_vars).to receive(:web_server_type).and_return("tomcat")
84
116
  expect(env_vars).to receive(:init_type).and_return("")
85
117
 
@@ -92,10 +124,10 @@ describe Gordon::Cookery::DependencyResolver do
92
124
  expect(subject.resolve_dependencies(env_vars, :centos)).to eq(expected)
93
125
  end
94
126
 
95
- it 'assigns java-oracle to OpenJDK for debian' do
127
+ it 'assigns oracle-jre to OpenJDK for debian' do
96
128
  allow(env_vars).to receive(:http_server_type).and_return("apache")
97
- expect(env_vars).to receive(:runtime_name).and_return("java-oracle")
98
- allow(env_vars).to receive(:runtime_version).and_return("1.7.0_60")
129
+ expect(env_vars).to receive(:runtime_name).and_return("oracle-jre")
130
+ allow(env_vars).to receive(:runtime_version).and_return("1.7.0_80")
99
131
  allow(env_vars).to receive(:web_server_type).and_return("tomcat")
100
132
  expect(env_vars).to receive(:init_type).and_return("")
101
133
 
@@ -110,8 +142,8 @@ describe Gordon::Cookery::DependencyResolver do
110
142
 
111
143
  it 'handles OpenJDK package name for debian' do
112
144
  allow(env_vars).to receive(:http_server_type).and_return("apache")
113
- expect(env_vars).to receive(:runtime_name).and_return("java-openjdk")
114
- allow(env_vars).to receive(:runtime_version).and_return("1.7.0_60")
145
+ expect(env_vars).to receive(:runtime_name).and_return("openjdk")
146
+ allow(env_vars).to receive(:runtime_version).and_return("1.7.0_80")
115
147
  allow(env_vars).to receive(:web_server_type).and_return("tomcat")
116
148
  expect(env_vars).to receive(:init_type).and_return("")
117
149
 
@@ -9,7 +9,8 @@ describe Gordon::Cookery::HttpServer do
9
9
 
10
10
  let(:app_name) { "gordon" }
11
11
  let(:http_server_type) { :apache }
12
- let(:env_vars) { double Gordon::EnvVars, app_name: app_name, http_server_type: http_server_type }
12
+ let(:attributes) { { app_name: app_name, app_source_excludes: %w(something), http_server_type: http_server_type } }
13
+ let(:env_vars) { double Gordon::EnvVars, attributes }
13
14
  let(:skeleton) { Gordon::Skeleton::Types::Apache.new }
14
15
  let(:all_files) { %w(index.php pimp_my_system.php) }
15
16
  let(:blacklist) { %w(.git) }
@@ -20,7 +21,7 @@ describe Gordon::Cookery::HttpServer do
20
21
 
21
22
  describe 'installing files' do
22
23
  it 'install files based on http server path' do
23
- expect(subject).to receive(:all_files_except_blacklisted).with(blacklist).and_return(all_files)
24
+ expect(subject).to receive(:all_files_except_blacklisted).with(blacklist, attributes[:app_source_excludes]).and_return(all_files)
24
25
 
25
26
  installer = double 'a path helper'
26
27
  expect(subject).to receive(:root).with(skeleton.path).and_return(installer)
@@ -7,11 +7,12 @@ describe Gordon::Cookery::Standalone do
7
7
  end.new
8
8
  end
9
9
 
10
- let(:app_name) { "gordon" }
11
- let(:env_vars) { instance_double Gordon::EnvVars, app_name: app_name }
12
- let(:skeleton) { Gordon::Skeleton::Types::Misc.new }
13
- let(:all_files) { %w(.bundle app config lib .ruby-version .ruby-gemset) }
14
- let(:blacklist) { %w(.git) }
10
+ let(:app_name) { "gordon" }
11
+ let(:attributes) { { app_name: app_name, app_source_excludes: %w(something) } }
12
+ let(:env_vars) { instance_double Gordon::EnvVars, attributes }
13
+ let(:skeleton) { Gordon::Skeleton::Types::Misc.new }
14
+ let(:all_files) { %w(.bundle app config lib .ruby-version .ruby-gemset) }
15
+ let(:blacklist) { %w(.git) }
15
16
 
16
17
  before :each do
17
18
  expect(Gordon::Skeleton::Types::Misc).to receive(:new).and_return(skeleton)
@@ -19,7 +20,7 @@ describe Gordon::Cookery::Standalone do
19
20
 
20
21
  describe 'installing files' do
21
22
  it 'install all files based on misc skeleton' do
22
- expect(subject).to receive(:all_files_except_blacklisted).with(blacklist).and_return(all_files)
23
+ expect(subject).to receive(:all_files_except_blacklisted).with(blacklist, attributes[:app_source_excludes]).and_return(all_files)
23
24
 
24
25
  installer = double 'a path helper'
25
26
  expect(subject).to receive(:root).with(skeleton.path(app_name)).and_return(installer)
@@ -9,7 +9,8 @@ describe Gordon::Cookery::WebServer do
9
9
 
10
10
  let(:app_name) { "gordon" }
11
11
  let(:web_server_type) { :tomcat }
12
- let(:env_vars) { double Gordon::EnvVars, app_name: app_name, web_server_type: web_server_type }
12
+ let(:attributes) { { app_name: app_name, app_source_excludes: %w(something), web_server_type: web_server_type } }
13
+ let(:env_vars) { double Gordon::EnvVars, attributes }
13
14
  let(:skeleton) { Gordon::Skeleton::Types::Tomcat.new }
14
15
  let(:all_files) { %w(gordon.war) }
15
16
  let(:blacklist) { %w(gordon.class) }
@@ -20,7 +21,7 @@ describe Gordon::Cookery::WebServer do
20
21
 
21
22
  describe 'installing web server files' do
22
23
  it 'install files based on web server path' do
23
- expect(subject).to receive(:all_files_except_blacklisted).with(blacklist).and_return(all_files)
24
+ expect(subject).to receive(:all_files_except_blacklisted).with(blacklist, attributes[:app_source_excludes]).and_return(all_files)
24
25
 
25
26
  installer = double 'a path helper'
26
27
  expect(subject).to receive(:root).with(skeleton.path).and_return(installer)
@@ -3,17 +3,18 @@ require 'spec_helper'
3
3
  describe Gordon::EnvVars do
4
4
  let(:attributes) do
5
5
  {
6
- app_type: "web",
7
- app_name: "xirubiru",
8
- app_description: "a nice description",
9
- app_homepage: "http://some.github.repo",
10
- app_version: "2.0.0",
11
- app_source: ".",
12
- runtime_name: "ruby",
13
- runtime_version: "2.2.0",
14
- http_server_type: "nginx",
15
- web_server_type: "tomcat",
16
- init_type: "systemd",
6
+ app_type: "web",
7
+ app_name: "xirubiru",
8
+ app_description: "a nice description",
9
+ app_homepage: "http://some.github.repo",
10
+ app_version: "2.0.0",
11
+ app_source: ".",
12
+ app_source_excludes: %w(one two three),
13
+ runtime_name: "ruby",
14
+ runtime_version: "2.2.0",
15
+ http_server_type: "nginx",
16
+ web_server_type: "tomcat",
17
+ init_type: "systemd",
17
18
  }
18
19
  end
19
20
 
@@ -28,6 +29,7 @@ describe Gordon::EnvVars do
28
29
  "GORDON_APP_HOMEPAGE='#{options.app_homepage}'",
29
30
  "GORDON_APP_VERSION='#{options.app_version}'",
30
31
  "GORDON_APP_SOURCE='#{File.expand_path(options.app_source)}'",
32
+ "GORDON_APP_SOURCE_EXCLUDES='#{options.app_source_excludes.map{ |path| File.expand_path(path) }.join(",") }'",
31
33
  "GORDON_RUNTIME_NAME='#{options.runtime_name}'",
32
34
  "GORDON_RUNTIME_VERSION='#{options.runtime_version}'",
33
35
  "GORDON_HTTP_SERVER_TYPE='#{options.http_server_type}'",
@@ -42,24 +44,27 @@ describe Gordon::EnvVars do
42
44
  describe 'loading from environment' do
43
45
  it 'returns a instance with all specified values' do
44
46
  env = {
45
- 'GORDON_APP_TYPE' => options.app_type,
46
- 'GORDON_APP_NAME' => options.app_name,
47
- 'GORDON_APP_DESCRIPTION' => options.app_description,
48
- 'GORDON_APP_HOMEPAGE' => options.app_homepage,
49
- 'GORDON_APP_VERSION' => options.app_version,
50
- 'GORDON_APP_SOURCE' => options.app_source,
51
- 'GORDON_RUNTIME_NAME' => options.runtime_name,
52
- 'GORDON_RUNTIME_VERSION' => options.runtime_version,
53
- 'GORDON_HTTP_SERVER_TYPE' => options.http_server_type,
54
- 'GORDON_WEB_SERVER_TYPE' => options.web_server_type,
55
- 'GORDON_INIT_TYPE' => options.init_type,
47
+ 'GORDON_APP_TYPE' => options.app_type,
48
+ 'GORDON_APP_NAME' => options.app_name,
49
+ 'GORDON_APP_DESCRIPTION' => options.app_description,
50
+ 'GORDON_APP_HOMEPAGE' => options.app_homepage,
51
+ 'GORDON_APP_VERSION' => options.app_version,
52
+ 'GORDON_APP_SOURCE' => options.app_source,
53
+ 'GORDON_APP_SOURCE_EXCLUDES' => options.app_source_excludes.join(","),
54
+ 'GORDON_RUNTIME_NAME' => options.runtime_name,
55
+ 'GORDON_RUNTIME_VERSION' => options.runtime_version,
56
+ 'GORDON_HTTP_SERVER_TYPE' => options.http_server_type,
57
+ 'GORDON_WEB_SERVER_TYPE' => options.web_server_type,
58
+ 'GORDON_INIT_TYPE' => options.init_type,
56
59
  }
57
60
 
58
61
  env.each_pair { |k, v| expect(ENV).to receive(:[]).with(k).and_return(v.to_s) }
59
62
 
60
63
  described_class.load.tap do |env_vars|
61
64
  env.each_pair do |k, v|
62
- expect(env_vars.send(k.gsub(/GORDON_/, '').downcase)).to eq(v.to_s)
65
+ expected = k == 'GORDON_APP_SOURCE_EXCLUDES' ? options.app_source_excludes : v.to_s
66
+
67
+ expect(env_vars.send(k.gsub(/GORDON_/, '').downcase)).to eq(expected)
63
68
  end
64
69
  end
65
70
  end
@@ -1,8 +1,74 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Gordon::Options do
4
- describe 'mapping default accessors' do
5
- pending
4
+ let(:main_option_attributes) do
5
+ {
6
+ app_name: 'a-test',
7
+ app_description: 'a description',
8
+ app_homepage: 'https://github.com/salizzar/gordon',
9
+ app_version: Gordon::VERSION,
10
+ app_source: '.',
11
+ app_source_excludes: %w(something),
12
+ app_type: 'web',
13
+ runtime_name: 'ruby',
14
+ runtime_version: '2.2.2',
15
+ http_server_type: 'nginx',
16
+ web_server_type: nil,
17
+ init_type: 'systemd',
18
+ package_type: 'rpm',
19
+ output_dir: 'pkg',
20
+ debug: false,
21
+ trace: true,
22
+ }
23
+ end
24
+
25
+ let(:recipe) do
26
+ {
27
+ 'app_name' => 'xirubiru',
28
+ 'app_description' => 'another description',
29
+ 'app_homepage' => 'https://github.com/salizzar/xirubiru',
30
+ 'app_version' => '1.0.1',
31
+ 'app_source' => '/tmp',
32
+ 'app_source_excludes' => %w(something),
33
+ 'app_type' => 'standalone',
34
+ 'runtime_name' => 'ruby',
35
+ 'runtime_version' => '2.2.1',
36
+ 'http_server_type' => nil,
37
+ 'web_server_type' => nil,
38
+ 'init_type' => 'systemd',
39
+ 'package_type' => 'rpm',
40
+ 'output_dir' => 'pkg',
41
+ 'debug' => true,
42
+ 'trace' => false,
43
+ }
44
+ end
45
+
46
+ let(:main_options) { instance_double(described_class, main_option_attributes) }
47
+
48
+ describe 'returning instance based on main options and a recipe' do
49
+ it 'priorizes main options instead of recipe' do
50
+ instance = described_class.from(main_options, recipe)
51
+
52
+ main_option_attributes.delete_if do |(k, _)|
53
+ [ :app_source, :app_source_excludes ].include?(k)
54
+ end.each do |(k, v)|
55
+ expect(instance.send(k)).to eq(v)
56
+ end
57
+ end
58
+
59
+ it 'priorizes app source from recipe instead of main option' do
60
+ instance = described_class.from(main_options, recipe)
61
+
62
+ expect(instance.app_source).to eq(recipe['app_source'])
63
+ end
64
+
65
+ it 'merges app source excludes values from main options and recipes' do
66
+ instance = described_class.from(main_options, recipe)
67
+
68
+ expected = (main_option_attributes[:app_source_excludes].to_a + recipe['app_source_excludes'].to_a).flatten
69
+
70
+ expect(instance.app_source_excludes).to eq(expected)
71
+ end
6
72
  end
7
73
  end
8
74
 
@@ -18,7 +18,7 @@ describe Gordon::Process do
18
18
  it 'raises error if call returns one' do
19
19
  expect(Process).to receive(:wait2).with(pid).and_return([ pid, 1 ])
20
20
 
21
- expect{ described_class.run(command) }.to raise_error
21
+ expect{ described_class.run(command) }.to raise_error(SystemCallError)
22
22
  end
23
23
  end
24
24
  end
data/spec/spec_helper.rb CHANGED
@@ -1 +1,8 @@
1
+ require 'simplecov'
2
+
3
+ SimpleCov.start do
4
+ add_filter 'spec'
5
+ end
6
+
1
7
  require 'gordon'
8
+
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gordon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.21
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Marcelo Pinheiro
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-03 00:00:00.000000000 Z
11
+ date: 2015-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -38,6 +38,34 @@ dependencies:
38
38
  - - ">="
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: byebug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: simplecov
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
41
69
  - !ruby/object:Gem::Dependency
42
70
  name: fpm-cookery
43
71
  requirement: !ruby/object:Gem::Requirement
@@ -85,11 +113,13 @@ files:
85
113
  - gordon.gemspec
86
114
  - lib/gordon.rb
87
115
  - lib/gordon/application/factory.rb
116
+ - lib/gordon/application/templates/java_standalone_app.rb
88
117
  - lib/gordon/application/templates/java_web_app.rb
89
118
  - lib/gordon/application/templates/ruby_standalone_app.rb
90
119
  - lib/gordon/application/templates/ruby_web_app.rb
91
120
  - lib/gordon/application/types.rb
92
121
  - lib/gordon/cli.rb
122
+ - lib/gordon/cookbook.rb
93
123
  - lib/gordon/cooker.rb
94
124
  - lib/gordon/cookery/application_user.rb
95
125
  - lib/gordon/cookery/common.rb
@@ -112,11 +142,13 @@ files:
112
142
  - lib/gordon/skeleton/types.rb
113
143
  - lib/gordon/version.rb
114
144
  - spec/gordon/application/factory_spec.rb
145
+ - spec/gordon/application/templates/java_standalone_app_spec.rb
115
146
  - spec/gordon/application/templates/java_web_app_spec.rb
116
147
  - spec/gordon/application/templates/ruby_standalone_app_spec.rb
117
148
  - spec/gordon/application/templates/ruby_web_app_spec.rb
118
149
  - spec/gordon/application/types_spec.rb
119
150
  - spec/gordon/cli_spec.rb
151
+ - spec/gordon/cookbook_spec.rb
120
152
  - spec/gordon/cooker_spec.rb
121
153
  - spec/gordon/cookery/application_user_spec.rb
122
154
  - spec/gordon/cookery/common_spec.rb
@@ -156,17 +188,19 @@ required_rubygems_version: !ruby/object:Gem::Requirement
156
188
  version: '0'
157
189
  requirements: []
158
190
  rubyforge_project:
159
- rubygems_version: 2.4.6
191
+ rubygems_version: 2.4.8
160
192
  signing_key:
161
193
  specification_version: 4
162
194
  summary: A tool to create application OS packages
163
195
  test_files:
164
196
  - spec/gordon/application/factory_spec.rb
197
+ - spec/gordon/application/templates/java_standalone_app_spec.rb
165
198
  - spec/gordon/application/templates/java_web_app_spec.rb
166
199
  - spec/gordon/application/templates/ruby_standalone_app_spec.rb
167
200
  - spec/gordon/application/templates/ruby_web_app_spec.rb
168
201
  - spec/gordon/application/types_spec.rb
169
202
  - spec/gordon/cli_spec.rb
203
+ - spec/gordon/cookbook_spec.rb
170
204
  - spec/gordon/cooker_spec.rb
171
205
  - spec/gordon/cookery/application_user_spec.rb
172
206
  - spec/gordon/cookery/common_spec.rb