omnibus 1.3.0 → 2.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +4 -1
  3. data/.rubocop.yml +30 -0
  4. data/.travis.yml +14 -3
  5. data/CHANGELOG.md +72 -49
  6. data/Gemfile +8 -5
  7. data/NOTICE +2 -2
  8. data/README.md +65 -7
  9. data/Rakefile +12 -3
  10. data/bin/makeself-header.sh +1 -1
  11. data/bin/makeself.sh +2 -2
  12. data/bin/omnibus +2 -2
  13. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/background.png +0 -0
  14. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/license.html +1 -0
  15. data/functional/fixtures/mac_pkg/files/mac_pkg/Resources/welcome.html +1 -0
  16. data/functional/fixtures/mac_pkg/package-scripts/functional-test-project/postinstall +4 -0
  17. data/functional/packagers/mac_pkg_spec.rb +72 -0
  18. data/lib/omnibus/artifact.rb +11 -13
  19. data/lib/omnibus/build_version.rb +18 -21
  20. data/lib/omnibus/builder.rb +37 -48
  21. data/lib/omnibus/clean_tasks.rb +3 -5
  22. data/lib/omnibus/cli/application.rb +46 -53
  23. data/lib/omnibus/cli/base.rb +16 -19
  24. data/lib/omnibus/cli/build.rb +13 -13
  25. data/lib/omnibus/cli/cache.rb +13 -15
  26. data/lib/omnibus/cli/release.rb +4 -9
  27. data/lib/omnibus/cli.rb +2 -4
  28. data/lib/omnibus/config.rb +43 -23
  29. data/lib/omnibus/exceptions.rb +35 -1
  30. data/lib/omnibus/fetcher.rb +9 -13
  31. data/lib/omnibus/fetchers/git_fetcher.rb +15 -19
  32. data/lib/omnibus/fetchers/net_fetcher.rb +34 -38
  33. data/lib/omnibus/fetchers/path_fetcher.rb +7 -9
  34. data/lib/omnibus/fetchers/s3_cache_fetcher.rb +3 -4
  35. data/lib/omnibus/fetchers.rb +3 -3
  36. data/lib/omnibus/health_check.rb +126 -127
  37. data/lib/omnibus/library.rb +11 -12
  38. data/lib/omnibus/overrides.rb +6 -8
  39. data/lib/omnibus/package_release.rb +20 -22
  40. data/lib/omnibus/packagers/mac_pkg.rb +285 -0
  41. data/lib/omnibus/project.rb +215 -110
  42. data/lib/omnibus/reports.rb +16 -24
  43. data/lib/omnibus/s3_cacher.rb +15 -21
  44. data/lib/omnibus/software.rb +178 -88
  45. data/lib/omnibus/util.rb +25 -13
  46. data/lib/omnibus/version.rb +2 -2
  47. data/lib/omnibus.rb +11 -13
  48. data/omnibus.gemspec +20 -18
  49. data/spec/artifact_spec.rb +55 -52
  50. data/spec/build_version_spec.rb +121 -129
  51. data/spec/config_spec.rb +40 -0
  52. data/spec/data/projects/chefdk.rb +41 -0
  53. data/spec/data/projects/sample.rb +10 -0
  54. data/spec/data/software/erchef.rb +12 -12
  55. data/spec/data/software/zlib.rb +67 -0
  56. data/spec/fetchers/git_fetcher_spec.rb +55 -48
  57. data/spec/fetchers/net_fetcher_spec.rb +72 -78
  58. data/spec/omnibus_spec.rb +59 -0
  59. data/spec/overrides_spec.rb +64 -64
  60. data/spec/package_release_spec.rb +65 -64
  61. data/spec/packagers/mac_pkg_spec.rb +261 -0
  62. data/spec/project_spec.rb +138 -0
  63. data/spec/s3_cacher_spec.rb +9 -10
  64. data/spec/software_spec.rb +71 -50
  65. data/spec/spec_helper.rb +14 -7
  66. metadata +68 -60
  67. data/.rspec +0 -1
  68. data/.yardopts +0 -6
  69. data/spec/software_dirs_spec.rb +0 -34
@@ -1,86 +1,94 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Omnibus::GitFetcher do
4
- let(:shell_out) {
4
+ let(:shell_out) do
5
5
  shell_out = double('Mixlib::ShellOut')
6
6
  stub_const('Mixlib::ShellOut', shell_out)
7
7
  shell_out
8
- }
9
- let(:software) {
10
- double('software').tap { |s|
11
- s.stub :name => 'project',
12
- :source => { :git => 'git@example.com:test/project.git' },
13
- :version => '0.0.1',
14
- :project_dir => '/tmp/project'
15
- }
16
- }
8
+ end
9
+ let(:software) do
10
+ double('software').tap do |s|
11
+ s.stub name: 'project',
12
+ source: { git: 'git@example.com:test/project.git' },
13
+ version: '0.0.1',
14
+ project_dir: '/tmp/project'
15
+ end
16
+ end
17
+
17
18
  def expect_git_clone_and_ls_remote
18
19
  expect_git_clone
19
20
  expect_git_ls_remote
20
21
  end
22
+
21
23
  def expect_git_clone
22
24
  double('git_clone').tap do |g|
23
- shell_out.should_receive(:new)
24
- .with('git clone git@example.com:test/project.git /tmp/project', :live_stream => STDOUT)
25
+ expect(shell_out).to receive(:new)
26
+ .with('git clone git@example.com:test/project.git /tmp/project', live_stream: STDOUT)
25
27
  .ordered
26
28
  .and_return(g)
27
- g.should_receive(:run_command).ordered
28
- g.should_receive(:error!).ordered
29
+ expect(g).to receive(:run_command).ordered
30
+ expect(g).to receive(:error!).ordered
29
31
  end
30
32
  end
33
+
31
34
  def expect_git_ls_remote
32
35
  double('git_ls_remote').tap do |g|
33
- shell_out.should_receive(:new)
34
- .with('git ls-remote origin 0.0.1*', :live_stream => STDOUT, :cwd => '/tmp/project')
36
+ expect(shell_out).to receive(:new)
37
+ .with('git ls-remote origin 0.0.1*', live_stream: STDOUT, cwd: '/tmp/project')
35
38
  .ordered
36
39
  .and_return(g)
37
- g.should_receive(:run_command).ordered
38
- g.should_receive(:error!).ordered
39
- g.stub(:stdout => git_ls_remote_out)
40
+ expect(g).to receive(:run_command).ordered
41
+ expect(g).to receive(:error!).ordered
42
+ g.stub(stdout: git_ls_remote_out)
40
43
  end
41
44
  end
42
- describe "#fetch" do
43
- context "when the project is not cloned yet" do
44
- before {
45
+
46
+ describe '#fetch' do
47
+ context 'when the project is not cloned yet' do
48
+ before do
45
49
  File.stub(:exist?).with('/tmp/project/.git').and_return(false)
46
- }
47
- context "when the source repository is accessible" do
48
- subject {
50
+ end
51
+
52
+ context 'when the source repository is accessible' do
53
+ subject do
49
54
  Omnibus::GitFetcher.new software
50
- }
51
- context "when the ref exists" do
52
- let(:git_ls_remote_out) {
55
+ end
56
+
57
+ context 'when the ref exists' do
58
+ let(:git_ls_remote_out) do
53
59
  'a2ed66c01f42514bcab77fd628149eccb4ecee28 refs/tags/0.0.1'
54
- }
60
+ end
61
+
55
62
  it 'should clone the Git repository and then check out the commit' do
56
63
  1.times { expect_git_clone_and_ls_remote }
57
64
  double('git_checkout').tap do |g|
58
- shell_out.should_receive(:new)
59
- .with('git checkout a2ed66c01f42514bcab77fd628149eccb4ecee28', :live_stream => STDOUT, :cwd => '/tmp/project')
65
+ expect(shell_out).to receive(:new)
66
+ .with('git checkout a2ed66c01f42514bcab77fd628149eccb4ecee28', live_stream: STDOUT, cwd: '/tmp/project')
60
67
  .ordered
61
68
  .and_return(g)
62
- g.should_receive(:run_command).ordered
63
- g.should_receive(:error!).ordered
69
+ expect(g).to receive(:run_command).ordered
70
+ expect(g).to receive(:error!).ordered
64
71
  end
65
72
 
66
73
  expect { subject.fetch }.to_not raise_error
67
74
  end
68
75
  end
69
- context "when the ref does not exist" do
70
- let(:git_ls_remote_out) {
71
- ''
72
- }
76
+
77
+ context 'when the ref does not exist' do
78
+ let(:git_ls_remote_out) { '' }
79
+
73
80
  it 'should clone the Git repository and then fail while retrying 3 times' do
74
- 4.times {
75
- expect_git_clone
76
- 4.times {
77
- expect_git_ls_remote
78
- }
79
- }
80
- Omnibus::Fetcher::ErrorReporter.any_instance
81
- .should_receive(:explain).with(%q|Failed to find any commits for the ref '0.0.1'|)
82
- subject.should_receive(:log).with(%r|git ls-remote failed|).at_least(1).times
83
- subject.should_receive(:log).with(%r|git clone/fetch failed|).at_least(1).times
81
+ 4.times do
82
+ expect_git_clone
83
+ 4.times do
84
+ expect_git_ls_remote
85
+ end
86
+ end
87
+
88
+ expect_any_instance_of(Omnibus::Fetcher::ErrorReporter).to receive(:explain)
89
+ .with(%q|Failed to find any commits for the ref '0.0.1'|)
90
+ expect(subject).to receive(:log).with(/git ls\-remote failed/).at_least(1).times
91
+ expect(subject).to receive(:log).with(/git clone\/fetch failed/).at_least(1).times
84
92
  # Prevent sleeping to run the spec fast
85
93
  subject.stub(:sleep)
86
94
  expect { subject.fetch }.to raise_error(/Could not parse SHA reference/)
@@ -90,4 +98,3 @@ describe Omnibus::GitFetcher do
90
98
  end
91
99
  end
92
100
  end
93
-
@@ -1,61 +1,56 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Omnibus::NetFetcher do
4
- it "should download and uncompress zip files" do
4
+ it 'should download and uncompress zip files' do
5
5
  software_mock = double('software')
6
- software_mock.stub :project_file => 'file.zip',
7
- :name => 'file',
8
- :source => '/tmp/out',
9
- :checksum => 'abc123',
10
- :source_uri => 'http://example.com/file.zip',
11
- :source_dir => '/tmp/out',
12
- :project_dir => '/tmp/project'
6
+ software_mock.stub project_file: 'file.zip',
7
+ name: 'file',
8
+ source: '/tmp/out',
9
+ checksum: 'abc123',
10
+ source_uri: 'http://example.com/file.zip',
11
+ source_dir: '/tmp/out',
12
+ project_dir: '/tmp/project'
13
13
  net_fetcher = Omnibus::NetFetcher.new software_mock
14
- net_fetcher.extract_cmd.should == 'unzip file.zip -d /tmp/out'
14
+ expect(net_fetcher.extract_cmd).to eq('unzip file.zip -d /tmp/out')
15
15
  end
16
- it "should download and uncompress .tar.xz files" do
16
+ it 'should download and uncompress .tar.xz files' do
17
17
  software_mock = double('software')
18
- software_mock.stub :project_file => 'file.tar.xz',
19
- :name => 'file',
20
- :source => '/tmp/out',
21
- :checksum => 'abc123',
22
- :source_uri => 'http://example.com/file.tar.xz',
23
- :source_dir => '/tmp/out',
24
- :project_dir => '/tmp/project'
18
+ software_mock.stub project_file: 'file.tar.xz',
19
+ name: 'file',
20
+ source: '/tmp/out',
21
+ checksum: 'abc123',
22
+ source_uri: 'http://example.com/file.tar.xz',
23
+ source_dir: '/tmp/out',
24
+ project_dir: '/tmp/project'
25
25
  net_fetcher = Omnibus::NetFetcher.new software_mock
26
- net_fetcher.extract_cmd.should == 'xz -dc file.tar.xz | ( cd /tmp/out && tar -xf - )'
26
+ expect(net_fetcher.extract_cmd).to eq('xz -dc file.tar.xz | ( cd /tmp/out && tar -xf - )')
27
27
  end
28
- it "should download and uncompress .txz files" do
28
+ it 'should download and uncompress .txz files' do
29
29
  software_mock = double('software')
30
- software_mock.stub :project_file => 'file.txz',
31
- :name => 'file',
32
- :source => '/tmp/out',
33
- :checksum => 'abc123',
34
- :source_uri => 'http://example.com/file.txz',
35
- :source_dir => '/tmp/out',
36
- :project_dir => '/tmp/project'
30
+ software_mock.stub project_file: 'file.txz',
31
+ name: 'file',
32
+ source: '/tmp/out',
33
+ checksum: 'abc123',
34
+ source_uri: 'http://example.com/file.txz',
35
+ source_dir: '/tmp/out',
36
+ project_dir: '/tmp/project'
37
37
  net_fetcher = Omnibus::NetFetcher.new software_mock
38
- net_fetcher.extract_cmd.should == 'xz -dc file.txz | ( cd /tmp/out && tar -xf - )'
38
+ expect(net_fetcher.extract_cmd).to eq('xz -dc file.txz | ( cd /tmp/out && tar -xf - )')
39
39
  end
40
40
 
41
- describe "http_proxy helper" do
41
+ describe 'http_proxy helper' do
42
42
  before(:each) do
43
43
  software_mock = double('software')
44
- software_mock.stub(:project_file => 'file.txz',
45
- :name => 'file',
46
- :source => '/tmp/out',
47
- :checksum => 'abc123',
48
- :source_uri => 'http://example.com/file.txz',
49
- :source_dir => '/tmp/out',
50
- :project_dir => '/tmp/project')
44
+ software_mock.stub project_file: 'file.txz',
45
+ name: 'file',
46
+ source: '/tmp/out',
47
+ checksum: 'abc123',
48
+ source_uri: 'http://example.com/file.txz',
49
+ source_dir: '/tmp/out',
50
+ project_dir: '/tmp/project'
51
51
  @net_fetcher = Omnibus::NetFetcher.new(software_mock)
52
- env_vars = ['HTTP_PROXY',
53
- 'HTTP_PROXY_USER',
54
- 'HTTP_PROXY_PASS',
55
- 'http_proxy',
56
- 'http_proxy_user',
57
- 'http_proxy_pass']
58
- @orig_env = env_vars.inject({}) do |h, var|
52
+ env_vars = %w(HTTP_PROXY HTTP_PROXY_USER HTTP_PROXY_PASS http_proxy http_proxy_user http_proxy_pass)
53
+ @orig_env = env_vars.reduce({}) do |h, var|
59
54
  h[var] = ENV.delete(var)
60
55
  h
61
56
  end
@@ -66,60 +61,59 @@ describe Omnibus::NetFetcher do
66
61
  @orig_env.each { |var, val| ENV[var] = val }
67
62
  end
68
63
 
69
- describe "get_env handles upper and lower case env vars" do
70
- it "lower via upper" do
71
- ENV['lower'] = "abc"
72
- @net_fetcher.get_env('LOWER').should == "abc"
73
- @net_fetcher.get_env('lower').should == "abc"
64
+ describe 'get_env handles upper and lower case env vars' do
65
+ it 'lower via upper' do
66
+ ENV['lower'] = 'abc'
67
+ expect(@net_fetcher.get_env('LOWER')).to eq('abc')
68
+ expect(@net_fetcher.get_env('lower')).to eq('abc')
74
69
  end
75
70
 
76
- it "upper via lower" do
77
- ENV['UPPER'] = "abc"
78
- @net_fetcher.get_env('upper').should == "abc"
79
- @net_fetcher.get_env('UPPER').should == "abc"
71
+ it 'upper via lower' do
72
+ ENV['UPPER'] = 'abc'
73
+ expect(@net_fetcher.get_env('upper')).to eq('abc')
74
+ expect(@net_fetcher.get_env('UPPER')).to eq('abc')
80
75
  end
81
76
  end
82
77
 
83
- it "should return nil when no proxy is set in env" do
84
- @net_fetcher.http_proxy.should be_nil
78
+ it 'should return nil when no proxy is set in env' do
79
+ expect(@net_fetcher.http_proxy).to be_nil
85
80
  end
86
81
 
87
- it "should return a URI object when HTTP_PROXY is set" do
88
- ENV['HTTP_PROXY'] = "http://my.proxy"
89
- @net_fetcher.http_proxy.should == URI.parse("http://my.proxy")
82
+ it 'should return a URI object when HTTP_PROXY is set' do
83
+ ENV['HTTP_PROXY'] = 'http://my.proxy'
84
+ expect(@net_fetcher.http_proxy).to eq(URI.parse('http://my.proxy'))
90
85
  end
91
86
 
92
- it "sets user and pass from env when set" do
93
- ENV['HTTP_PROXY'] = "my.proxy"
94
- ENV['HTTP_PROXY_USER'] = "alex"
95
- ENV['HTTP_PROXY_PASS'] = "sesame"
96
- @net_fetcher.http_proxy.should == URI.parse("http://alex:sesame@my.proxy")
87
+ it 'sets user and pass from env when set' do
88
+ ENV['HTTP_PROXY'] = 'my.proxy'
89
+ ENV['HTTP_PROXY_USER'] = 'alex'
90
+ ENV['HTTP_PROXY_PASS'] = 'sesame'
91
+ expect(@net_fetcher.http_proxy).to eq(URI.parse('http://alex:sesame@my.proxy'))
97
92
  end
98
93
 
99
- it "uses user and pass in URL before those in env" do
100
- ENV['HTTP_PROXY'] = "sally:peanut@my.proxy"
101
- ENV['HTTP_PROXY_USER'] = "alex"
102
- ENV['HTTP_PROXY_PASS'] = "sesame"
103
- @net_fetcher.http_proxy.should == URI.parse("http://sally:peanut@my.proxy")
94
+ it 'uses user and pass in URL before those in env' do
95
+ ENV['HTTP_PROXY'] = 'sally:peanut@my.proxy'
96
+ ENV['HTTP_PROXY_USER'] = 'alex'
97
+ ENV['HTTP_PROXY_PASS'] = 'sesame'
98
+ expect(@net_fetcher.http_proxy).to eq(URI.parse('http://sally:peanut@my.proxy'))
104
99
  end
105
100
 
106
101
  it "proxies if host doesn't match exclude list" do
107
- ENV['NO_PROXY'] = "google.com,www.buz.org"
108
- a_url = URI.parse("http://should.proxy.com/123")
109
- @net_fetcher.excluded_from_proxy?(a_url.host).should be_false
102
+ ENV['NO_PROXY'] = 'google.com,www.buz.org'
103
+ a_url = URI.parse('http://should.proxy.com/123')
104
+ expect(@net_fetcher.excluded_from_proxy?(a_url.host)).to be_false
110
105
 
111
- b_url = URI.parse("http://buz.org/123")
112
- @net_fetcher.excluded_from_proxy?(b_url.host).should be_false
106
+ b_url = URI.parse('http://buz.org/123')
107
+ expect(@net_fetcher.excluded_from_proxy?(b_url.host)).to be_false
113
108
  end
114
109
 
115
- it "does not proxy if host matches exclude list" do
116
- ENV['NO_PROXY'] = "google.com,www.buz.org"
117
- a_url = URI.parse("http://google.com/hello")
118
- @net_fetcher.excluded_from_proxy?(a_url.host).should be_true
110
+ it 'does not proxy if host matches exclude list' do
111
+ ENV['NO_PROXY'] = 'google.com,www.buz.org'
112
+ a_url = URI.parse('http://google.com/hello')
113
+ expect(@net_fetcher.excluded_from_proxy?(a_url.host)).to be_true
119
114
 
120
- b_url = URI.parse("http://www.buz.org/123")
121
- @net_fetcher.excluded_from_proxy?(b_url.host).should be_true
115
+ b_url = URI.parse('http://www.buz.org/123')
116
+ expect(@net_fetcher.excluded_from_proxy?(b_url.host)).to be_true
122
117
  end
123
118
  end
124
119
  end
125
-
@@ -0,0 +1,59 @@
1
+ require 'omnibus'
2
+ require 'spec_helper'
3
+
4
+ describe Omnibus do
5
+ # evil class variables
6
+ before :each do
7
+ Omnibus.class_eval { @omnibus_software_root = nil }
8
+ Omnibus.class_eval { @software_dirs = nil }
9
+ end
10
+
11
+ after :each do
12
+ Omnibus.class_eval { @omnibus_software_root = nil }
13
+ Omnibus.class_eval { @software_dirs = nil }
14
+ end
15
+
16
+ describe '::omnibus_software_root' do
17
+ it 'reads the software_gem out of Omnibus::Config.software_gem' do
18
+ spec_array = [double(Gem::Specification, gem_dir: '/data')]
19
+ expect(Omnibus::Config).to receive(:software_gem)
20
+ .and_return('my-omnibus-software-gem')
21
+ expect(Gem::Specification).to receive(:find_all_by_name)
22
+ .with('my-omnibus-software-gem')
23
+ .and_return(spec_array)
24
+
25
+ Omnibus.omnibus_software_root
26
+ end
27
+
28
+ it 'uses the omnibus-software gem as the default' do
29
+ spec_array = [double(Gem::Specification, gem_dir: '/data')]
30
+ expect(Gem::Specification).to receive(:find_all_by_name)
31
+ .with('omnibus-software')
32
+ .and_return(spec_array)
33
+
34
+ Omnibus.omnibus_software_root
35
+ end
36
+ end
37
+
38
+ describe '#software_dirs' do
39
+ context 'omnibus_software_root not nil' do
40
+ before do
41
+ Omnibus.stub(:omnibus_software_root) { './data' }
42
+ end
43
+
44
+ it 'will include list of software from omnibus-software gem' do
45
+ expect(Omnibus.software_dirs.length).to eq(2)
46
+ end
47
+ end
48
+
49
+ context 'omnibus_software_root nil' do
50
+ before do
51
+ Omnibus.stub(:omnibus_software_root) { nil }
52
+ end
53
+
54
+ it 'will not include list of software from omnibus-software gem' do
55
+ expect(Omnibus.software_dirs.length).to eq(1)
56
+ end
57
+ end
58
+ end
59
+ end
@@ -2,113 +2,113 @@ require 'omnibus/overrides'
2
2
  require 'spec_helper'
3
3
 
4
4
  describe Omnibus::Overrides do
5
- describe "#parse_file" do
5
+ describe '#parse_file' do
6
6
 
7
- let(:overrides){Omnibus::Overrides.parse_file(file)}
8
- subject{overrides}
7
+ let(:overrides) { Omnibus::Overrides.parse_file(file) }
8
+ subject { overrides }
9
9
 
10
- context "with a valid overrides file" do
11
- let(:file){ overrides_path("good") }
10
+ context 'with a valid overrides file' do
11
+ let(:file) { overrides_path('good') }
12
12
 
13
- its(:size){should eq(5)}
14
- its(["foo"]){should eq("1.2.3")}
15
- its(["bar"]){should eq("0.0.1")}
16
- its(["baz"]){should eq("deadbeefdeadbeefdeadbeefdeadbeef")}
17
- its(["spunky"]){should eq("master")}
18
- its(["monkey"]){should eq("release")}
13
+ its(:size) { should eq(5) }
14
+ its(['foo']) { should eq('1.2.3') }
15
+ its(['bar']) { should eq('0.0.1') }
16
+ its(['baz']) { should eq('deadbeefdeadbeefdeadbeefdeadbeef') }
17
+ its(['spunky']) { should eq('master') }
18
+ its(['monkey']) { should eq('release') }
19
19
  end
20
20
 
21
- context "with an overrides file that contains a bad line" do
22
- let(:file){ overrides_path("bad_line")}
23
-
24
- it "fails" do
25
- expect{ overrides }.to raise_error(ArgumentError, "Invalid overrides line: 'THIS IS A BAD LINE'")
21
+ context 'with an overrides file that contains a bad line' do
22
+ let(:file) { overrides_path('bad_line') }
23
+
24
+ it 'fails' do
25
+ expect { overrides }.to raise_error(ArgumentError, "Invalid overrides line: 'THIS IS A BAD LINE'")
26
26
  end
27
27
  end
28
28
 
29
- context "with an overrides file that contains duplicates" do
30
- let(:file){ overrides_path("with_dupes") }
31
- let(:duplicated_package){"erchef"}
32
- it "fails" do
33
- expect{ overrides }.to raise_error(ArgumentError, "Multiple overrides present for '#{duplicated_package}' in overrides file #{file}!")
29
+ context 'with an overrides file that contains duplicates' do
30
+ let(:file) { overrides_path('with_dupes') }
31
+ let(:duplicated_package) { 'erchef' }
32
+ it 'fails' do
33
+ expect { overrides }.to raise_error(ArgumentError, "Multiple overrides present for '#{duplicated_package}' in overrides file #{file}!")
34
34
  end
35
35
  end
36
36
 
37
37
  context "when passed 'nil'" do
38
- let(:file){nil}
39
- it{should be_nil}
38
+ let(:file) { nil }
39
+ it { should be_nil }
40
40
  end
41
- end #parse_file
41
+ end # parse_file
42
42
 
43
- describe "#resolve_override_file" do
43
+ describe '#resolve_override_file' do
44
44
  before :each do
45
45
  @original = ENV['OMNIBUS_OVERRIDE_FILE']
46
46
  ENV['OMNIBUS_OVERRIDE_FILE'] = env_override_file
47
47
  end
48
-
48
+
49
49
  after :each do
50
50
  ENV['OMNIBUS_OVERRIDE_FILE'] = @original
51
51
  end
52
-
53
- subject{ Omnibus::Overrides.resolve_override_file }
54
-
55
- context "with no environment variable set" do
56
- let(:env_override_file){nil}
52
+
53
+ subject { Omnibus::Overrides.resolve_override_file }
54
+
55
+ context 'with no environment variable set' do
56
+ let(:env_override_file) { nil }
57
57
 
58
58
  before :each do
59
- stub_const("Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME", new_default_file)
59
+ stub_const('Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME', new_default_file)
60
+ end
61
+
62
+ context 'and a non-existent overrides file' do
63
+ let(:new_default_file) { '/this/file/totally/does/not/exist.txt' }
64
+ it { should be_nil }
60
65
  end
61
-
62
- context "and a non-existent overrides file" do
63
- let(:new_default_file){ "/this/file/totally/does/not/exist.txt" }
64
- it{should be_nil}
66
+
67
+ context 'with an existing overrides file' do
68
+ let(:path) { overrides_path('good') }
69
+ let(:new_default_file) { path }
70
+ it { should eq(path) }
65
71
  end
66
-
67
- context "with an existing overrides file" do
68
- let(:path){overrides_path("good")}
69
- let(:new_default_file){ path }
70
- it{should eq(path)}
71
- end
72
72
  end # no environment variable
73
73
 
74
- context "with OMNIBUS_OVERRIDE_FILE environment variable set" do
75
- context "to an existing file" do
76
- let(:path){ overrides_path("good") }
77
- let(:env_override_file){ path }
78
- it{should eq(path)}
74
+ context 'with OMNIBUS_OVERRIDE_FILE environment variable set' do
75
+ context 'to an existing file' do
76
+ let(:path) { overrides_path('good') }
77
+ let(:env_override_file) { path }
78
+ it { should eq(path) }
79
79
  end
80
80
 
81
- context "to a non-existent file" do
82
- let(:env_override_file){ "/this/file/totally/does/not/exist.txt"}
83
- it{should be_nil}
81
+ context 'to a non-existent file' do
82
+ let(:env_override_file) { '/this/file/totally/does/not/exist.txt' }
83
+ it { should be_nil }
84
84
  end
85
85
 
86
- context "to a non-existent file, but with an existing DEFAULT_OVERRIDE_FILE_NAME file" do
87
- let(:env_override_file){ "/this/file/totally/does/not/exist.txt"}
88
- let(:new_default_file){overrides_path("good")}
86
+ context 'to a non-existent file, but with an existing DEFAULT_OVERRIDE_FILE_NAME file' do
87
+ let(:env_override_file) { '/this/file/totally/does/not/exist.txt' }
88
+ let(:new_default_file) { overrides_path('good') }
89
89
 
90
90
  it "should still return 'nil', because environment variable has priority" do
91
- stub_const("Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME", new_default_file)
91
+ stub_const('Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME', new_default_file)
92
+
93
+ expect(File.exist?(Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME)).to be_true
94
+ expect(ENV['OMNIBUS_OVERRIDE_FILE']).to_not be_nil
92
95
 
93
- File.exist?(Omnibus::Overrides::DEFAULT_OVERRIDE_FILE_NAME).should be_true
94
- ENV['OMNIBUS_OVERRIDE_FILE'].should_not be_nil
95
-
96
- subject.should be_nil
96
+ expect(subject).to be_nil
97
97
  end
98
98
  end
99
99
  end
100
100
  end
101
101
 
102
- describe "#overrides" do
103
- context "when an overrides file cannot be found" do
102
+ describe '#overrides' do
103
+ context 'when an overrides file cannot be found' do
104
104
  before :each do
105
105
  Omnibus::Overrides.stub(:resolve_override_file).and_return(nil)
106
106
  end
107
-
108
- it "returns an empty hash" do
109
- Omnibus::Overrides.overrides.should eq({})
107
+
108
+ it 'returns an empty hash' do
109
+ expect(Omnibus::Overrides.overrides).to eq({})
110
110
  end
111
111
  end
112
112
  end
113
-
113
+
114
114
  end