boxes 2.5.0 → 3.0.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.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.hound.yml +2 -0
  3. data/.rubocop.yml +640 -0
  4. data/.ruby-version +1 -1
  5. data/.travis.yml +0 -2
  6. data/CHANGELOG.md +21 -0
  7. data/Rakefile +17 -22
  8. data/boxes.gemspec +3 -4
  9. data/lib/boxes/command.rb +5 -5
  10. data/lib/boxes/testing.rb +6 -0
  11. data/lib/boxes/testing/command.rb +23 -0
  12. data/lib/boxes/testing/matchers.rb +16 -0
  13. data/lib/boxes/testing/matchers/base_matcher.rb +21 -0
  14. data/lib/boxes/testing/matchers/have_exit_status_matcher.rb +19 -0
  15. data/lib/boxes/testing/matchers/write_to_stdout_matcher.rb +23 -0
  16. data/lib/boxes/version.rb +1 -2
  17. data/scripts/postinstall.sh +2 -2
  18. data/scripts/ruby.sh +7 -7
  19. data/scripts/vmtools.sh +1 -0
  20. data/spec/acceptance/user_builds_box_spec.rb +51 -0
  21. data/spec/acceptance/user_cleans_the_env_spec.rb +15 -0
  22. data/spec/acceptance/user_shows_the_env_spec.rb +49 -0
  23. data/spec/acceptance/user_views_env_help_spec.rb +18 -0
  24. data/spec/acceptance/user_views_help_spec.rb +39 -0
  25. data/spec/acceptance/user_views_version_spec.rb +10 -0
  26. data/spec/acceptance_helper.rb +15 -0
  27. data/spec/boxes/subprocess_spec.rb +4 -1
  28. data/spec/boxes/testing/command_spec.rb +28 -0
  29. data/spec/boxes/testing/matchers/have_exit_status_matcher_spec.rb +33 -0
  30. data/spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb +33 -0
  31. data/spec/support/env.rb +5 -0
  32. data/spec/support/subprocess_command.sh +7 -0
  33. data/spec/support/tmp.rb +17 -0
  34. data/spec/tmp/.gitkeep +0 -0
  35. data/templates/debian/jessie64.erb +2 -2
  36. data/templates/debian/preseed.cfg +5 -1
  37. data/templates/debian/stretch64.erb +60 -0
  38. data/templates/ubuntu/trusty64.erb +2 -2
  39. data/templates/ubuntu/xenial64.erb +2 -2
  40. metadata +45 -33
  41. data/features/boxes.feature +0 -8
  42. data/features/build.feature +0 -16
  43. data/features/env.feature +0 -18
  44. data/features/support/env.rb +0 -1
  45. data/spec/support/subprocess_command.rb +0 -7
  46. data/templates/ubuntu/wily64.erb +0 -64
@@ -0,0 +1,39 @@
1
+ require "acceptance_helper"
2
+
3
+ RSpec.describe "User views help" do
4
+ describe "boxes" do
5
+ it "describes the tool" do
6
+ run_command("boxes")
7
+
8
+ expect(response).to have_exit_status(0)
9
+ expect(response.stdout).to include(
10
+ "A command line tool that takes the complexity out of " \
11
+ "building Vagrant boxes.",
12
+ )
13
+ end
14
+
15
+ it "shows available subcommands" do
16
+ run_command("boxes")
17
+
18
+ expect(response).to have_exit_status(0)
19
+ expect(response.stdout).to include(
20
+ "+ build Build boxes",
21
+ )
22
+ expect(response.stdout).to include(
23
+ "+ env Manage the build environment",
24
+ )
25
+ end
26
+
27
+ it "shows available options" do
28
+ run_command("boxes")
29
+
30
+ expect(response).to have_exit_status(0)
31
+ expect(response.stdout).to include(
32
+ "--version Show the version of the tool",
33
+ )
34
+ expect(response.stdout).to include(
35
+ "--help Show help banner of specified command",
36
+ )
37
+ end
38
+ end
39
+ end
@@ -0,0 +1,10 @@
1
+ require "acceptance_helper"
2
+
3
+ RSpec.describe "User views version" do
4
+ it "successfully lists it's version" do
5
+ run_command("boxes --version")
6
+
7
+ expect(response).to have_exit_status(0)
8
+ expect(response).to write_to_stdout("#{Boxes::VERSION}\n")
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ require "boxes/testing"
2
+
3
+ require "support/env"
4
+ require "support/tmp"
5
+
6
+ RSpec.configure do |config|
7
+ include Boxes::Testing::Matchers
8
+ include Boxes::Testing::Command
9
+
10
+ config.around(:each) do |example|
11
+ Dir.chdir("spec/tmp") do
12
+ example.run
13
+ end
14
+ end
15
+ end
@@ -1,7 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe Boxes::Subprocess do
4
- let(:command) { "spec/support/subprocess_command.rb" }
4
+ let(:command) do
5
+ File.expand_path("../../support/subprocess_command.sh", __FILE__).
6
+ shellescape
7
+ end
5
8
 
6
9
  it 'runs a command and yields a block' do
7
10
  expect { |b| Boxes::Subprocess.run(command, &b) }.to yield_control
@@ -0,0 +1,28 @@
1
+ require "spec_helper"
2
+ require "boxes/testing/command"
3
+
4
+ RSpec.describe Boxes::Testing::Command do
5
+ include described_class
6
+
7
+ describe "#run_command" do
8
+ context "with output" do
9
+ it "returns the result of stdout" do
10
+ run_command("echo 'Hello World!'")
11
+
12
+ expect(response).to have_attributes(cmd: "echo 'Hello World!'",
13
+ stdout: "Hello World!\n",
14
+ exit_status: 0)
15
+ end
16
+ end
17
+
18
+ context "with an exit status" do
19
+ it "returns the custom exit code" do
20
+ run_command("exit 1")
21
+
22
+ expect(response).to have_attributes(cmd: "exit 1",
23
+ stdout: "",
24
+ exit_status: 1)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,33 @@
1
+ require "spec_helper"
2
+ require "boxes/testing"
3
+
4
+ RSpec.describe Boxes::Testing::Matchers::HaveExitStatusMatcher do
5
+ context "when an exit status matches" do
6
+ it "passes" do
7
+ expected = mock_command(status: 10)
8
+
9
+ instance = described_class.new(10)
10
+ outcome = instance.matches?(expected)
11
+
12
+ expect(outcome).to be(true)
13
+ end
14
+ end
15
+
16
+ context "when an exit status is different" do
17
+ it "fails with a message" do
18
+ expected = mock_command(cmd: "cmd", status: 10)
19
+
20
+ instance = described_class.new(0)
21
+ outcome = instance.matches?(expected)
22
+
23
+ expect(outcome).to be(false)
24
+ expect(instance.failure_message).to eq(
25
+ "expected that `cmd` would exit with 0",
26
+ )
27
+ end
28
+ end
29
+
30
+ def mock_command(cmd: nil, status: nil)
31
+ double("Command::Response", cmd: cmd, exit_status: status)
32
+ end
33
+ end
@@ -0,0 +1,33 @@
1
+ require "spec_helper"
2
+ require "boxes/testing"
3
+
4
+ RSpec.describe Boxes::Testing::Matchers::WriteToStdoutMatcher do
5
+ context "when the output matches" do
6
+ it "passes" do
7
+ expected = mock_command(stdout: "Hello World!\n")
8
+
9
+ instance = described_class.new("Hello World!\n")
10
+ outcome = instance.matches?(expected)
11
+
12
+ expect(outcome).to be(true)
13
+ end
14
+ end
15
+
16
+ context "when the output is different" do
17
+ it "fails with a message" do
18
+ expected = mock_command(stdout: "Hello!\n")
19
+
20
+ instance = described_class.new("Hello World!\n")
21
+ outcome = instance.matches?(expected)
22
+
23
+ expect(outcome).to be(false)
24
+ expect(instance.failure_message).to eq(
25
+ "expected that 'Hello!\\n' would be Hello World!\\n",
26
+ )
27
+ end
28
+ end
29
+
30
+ def mock_command(cmd: nil, stdout: nil)
31
+ double("Command::Response", cmd: cmd, stdout: stdout)
32
+ end
33
+ end
@@ -0,0 +1,5 @@
1
+ require "climate_control"
2
+
3
+ def with_modified_env(options, &block)
4
+ ClimateControl.modify(options, &block)
5
+ end
@@ -0,0 +1,7 @@
1
+ #!/bin/sh
2
+
3
+ echo "A happy output."
4
+
5
+ >&2 echo "An unhappy output."
6
+
7
+ exit 5
@@ -0,0 +1,17 @@
1
+ require "pathname"
2
+ require "securerandom"
3
+ require "tmpdir"
4
+ require "fileutils"
5
+
6
+ def tmpdir
7
+ @tmp_dir ||= begin
8
+ system_tmp = Dir.tmpdir
9
+ random_hash = SecureRandom.hex(10)
10
+
11
+ Pathname.new(system_tmp).join("boxes-#{random_hash}")
12
+ end
13
+ end
14
+
15
+ def mktmpdir
16
+ FileUtils.mkdir_p(tmpdir)
17
+ end
data/spec/tmp/.gitkeep ADDED
File without changes
@@ -25,8 +25,8 @@
25
25
  <%- end -%>
26
26
  "headless": true,
27
27
 
28
- "iso_url": "http://cdimage.debian.org/debian-cd/8.6.0/amd64/iso-cd/debian-8.6.0-amd64-netinst.iso",
29
- "iso_checksum": "9479c5c2df72ae3878116c43fb42eefae53d1fe363ce514a6afc8289064b9f5f",
28
+ "iso_url": "http://debian.ethz.ch/debian-cd/8.8.0/amd64/iso-cd/debian-8.8.0-amd64-netinst.iso",
29
+ "iso_checksum": "2c07ff8cc766767610566297b8729740f923735e790c8e78b718fb93923b448e",
30
30
  "iso_checksum_type": "sha256",
31
31
 
32
32
  "ssh_username": "vagrant",
@@ -49,10 +49,14 @@ d-i user-setup/encrypt-home boolean false
49
49
  # packages
50
50
  tasksel tasksel/first multiselect standard
51
51
  #d-i pkgsel/install-language-support boolean false
52
- d-i pkgsel/include string openssh-server nfs-common curl ntp acpid sudo bzip2 rsync git ca-certificates
52
+ d-i pkgsel/include string openssh-server nfs-common curl ntp acpid sudo \
53
+ bzip2 rsync git ca-certificates net-tools
53
54
  d-i pkgsel/upgrade select full-upgrade
54
55
  d-i pkgsel/update-policy select none
55
56
  d-i popularity-contest/participate boolean false
57
+ d-i preseed/late_command string sed -i '/^deb cdrom:/s/^/#/' /target/etc/apt/sources.list
58
+ apt-cdrom-setup apt-setup/cdrom/set-first boolean false
59
+ apt-mirror-setup apt-setup/use_mirror boolean true
56
60
  postfix postfix/main_mailer_type select No configuration
57
61
 
58
62
  # boot loader
@@ -0,0 +1,60 @@
1
+ {
2
+ "provisioners": [
3
+ {
4
+ "type": "shell",
5
+ "scripts": [
6
+ "scripts/postinstall.sh",
7
+ "scripts/vmtools.sh",
8
+ <%- @scripts.each do |script| -%>
9
+ "scripts/<%= script %>",
10
+ <%- end -%>
11
+ "scripts/purge.sh"
12
+ ],
13
+ "execute_command": "echo 'vagrant' | {{ .Vars }} sudo -E -S bash '{{ .Path }}'"
14
+ }
15
+ ],
16
+ "builders": [
17
+ {
18
+ "name": "<%= @name %>",
19
+ "type": "<%= @provider %>-iso",
20
+ <%- if @provider == "vmware" -%>
21
+ "guest_os_type": "debian8-64",
22
+ "tools_upload_flavor": "linux",
23
+ <%- else -%>
24
+ "guest_os_type": "Debian_64",
25
+ <%- end -%>
26
+ "headless": true,
27
+
28
+ "iso_url": "https://cdimage.debian.org/debian-cd/current/amd64/iso-cd/debian-9.3.0-amd64-netinst.iso",
29
+ "iso_checksum": "83480be837710a76fd4e75a6573ca110e06f5a7589d2d3852bdb0f45749800b3",
30
+ "iso_checksum_type": "sha256",
31
+
32
+ "ssh_username": "vagrant",
33
+ "ssh_password": "vagrant",
34
+ "ssh_timeout": "15m",
35
+
36
+ "http_directory": "templates/debian",
37
+
38
+ "boot_command": [
39
+ "<esc><wait>",
40
+ "install ",
41
+ "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ",
42
+ "debian-installer=en_US auto=true locale=en_US kbd-chooser/method=us ",
43
+ "netcfg/get_hostname={{ .Name }} ",
44
+ "netcfg/get_domain=vagrantup.com ",
45
+ "fb=false debconf/frontend=noninteractive ",
46
+ "console-setup/ask_detect=false console-keymaps-at/keymap=us ",
47
+ "keyboard-configuration/xkb-keymap=us ",
48
+ "<enter>"
49
+ ],
50
+
51
+ "shutdown_command": "echo 'shutdown -h now' > shutdown.sh; echo 'vagrant'|sudo -S sh 'shutdown.sh'"
52
+ }
53
+ ],
54
+
55
+ "post-processors": [
56
+ {
57
+ "type": "vagrant"
58
+ }
59
+ ]
60
+ }
@@ -26,8 +26,8 @@
26
26
  <%- end -%>
27
27
  "headless": true,
28
28
 
29
- "iso_url": "http://releases.ubuntu.com/trusty/ubuntu-14.04.4-server-amd64.iso",
30
- "iso_checksum": "07e4bb5569814eab41fafac882ba127893e3ff0bdb7ec931c9b2d040e3e94e7a",
29
+ "iso_url": "http://releases.ubuntu.com/trusty/ubuntu-14.04.5-server-amd64.iso",
30
+ "iso_checksum": "dde07d37647a1d2d9247e33f14e91acb10445a97578384896b4e1d985f754cc1",
31
31
  "iso_checksum_type": "sha256",
32
32
 
33
33
  "ssh_username": "vagrant",
@@ -26,8 +26,8 @@
26
26
  <%- end -%>
27
27
  "headless": true,
28
28
 
29
- "iso_url": "http://releases.ubuntu.com/xenial/ubuntu-16.04-server-amd64.iso",
30
- "iso_checksum": "b8b172cbdf04f5ff8adc8c2c1b4007ccf66f00fc6a324a6da6eba67de71746f6",
29
+ "iso_url": "http://releases.ubuntu.com/xenial/ubuntu-16.04.3-server-amd64.iso",
30
+ "iso_checksum": "a06cd926f5855d4f21fb4bc9978a35312f815fbda0d0ef7fdc846861f4fc4600",
31
31
  "iso_checksum_type": "sha256",
32
32
 
33
33
  "ssh_username": "vagrant",
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: boxes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Charlton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-01-20 00:00:00.000000000 Z
11
+ date: 2018-02-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: claide
@@ -53,7 +53,7 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: rake
56
+ name: climate_control
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - ">="
@@ -67,21 +67,7 @@ dependencies:
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
69
  - !ruby/object:Gem::Dependency
70
- name: rspec
71
- requirement: !ruby/object:Gem::Requirement
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- version: '0'
76
- type: :development
77
- prerelease: false
78
- version_requirements: !ruby/object:Gem::Requirement
79
- requirements:
80
- - - ">="
81
- - !ruby/object:Gem::Version
82
- version: '0'
83
- - !ruby/object:Gem::Dependency
84
- name: cucumber
70
+ name: fakefs
85
71
  requirement: !ruby/object:Gem::Requirement
86
72
  requirements:
87
73
  - - ">="
@@ -95,7 +81,7 @@ dependencies:
95
81
  - !ruby/object:Gem::Version
96
82
  version: '0'
97
83
  - !ruby/object:Gem::Dependency
98
- name: aruba
84
+ name: pry
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - ">="
@@ -109,7 +95,7 @@ dependencies:
109
95
  - !ruby/object:Gem::Version
110
96
  version: '0'
111
97
  - !ruby/object:Gem::Dependency
112
- name: fakefs
98
+ name: rake
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - ">="
@@ -123,7 +109,7 @@ dependencies:
123
109
  - !ruby/object:Gem::Version
124
110
  version: '0'
125
111
  - !ruby/object:Gem::Dependency
126
- name: pry
112
+ name: rspec
127
113
  requirement: !ruby/object:Gem::Requirement
128
114
  requirements:
129
115
  - - ">="
@@ -150,6 +136,8 @@ extensions: []
150
136
  extra_rdoc_files: []
151
137
  files:
152
138
  - ".gitignore"
139
+ - ".hound.yml"
140
+ - ".rubocop.yml"
153
141
  - ".ruby-version"
154
142
  - ".travis.yml"
155
143
  - CHANGELOG.md
@@ -159,10 +147,6 @@ files:
159
147
  - Rakefile
160
148
  - bin/boxes
161
149
  - boxes.gemspec
162
- - features/boxes.feature
163
- - features/build.feature
164
- - features/env.feature
165
- - features/support/env.rb
166
150
  - lib/boxes.rb
167
151
  - lib/boxes/builder.rb
168
152
  - lib/boxes/command.rb
@@ -173,6 +157,12 @@ files:
173
157
  - lib/boxes/errors.rb
174
158
  - lib/boxes/subprocess.rb
175
159
  - lib/boxes/template.rb
160
+ - lib/boxes/testing.rb
161
+ - lib/boxes/testing/command.rb
162
+ - lib/boxes/testing/matchers.rb
163
+ - lib/boxes/testing/matchers/base_matcher.rb
164
+ - lib/boxes/testing/matchers/have_exit_status_matcher.rb
165
+ - lib/boxes/testing/matchers/write_to_stdout_matcher.rb
176
166
  - lib/boxes/version.rb
177
167
  - scripts/ansible.sh
178
168
  - scripts/chef.sh
@@ -183,20 +173,33 @@ files:
183
173
  - scripts/purge.sh
184
174
  - scripts/ruby.sh
185
175
  - scripts/vmtools.sh
176
+ - spec/acceptance/user_builds_box_spec.rb
177
+ - spec/acceptance/user_cleans_the_env_spec.rb
178
+ - spec/acceptance/user_shows_the_env_spec.rb
179
+ - spec/acceptance/user_views_env_help_spec.rb
180
+ - spec/acceptance/user_views_help_spec.rb
181
+ - spec/acceptance/user_views_version_spec.rb
182
+ - spec/acceptance_helper.rb
186
183
  - spec/boxes/builder_spec.rb
187
184
  - spec/boxes/config_spec.rb
188
185
  - spec/boxes/environment_spec.rb
189
186
  - spec/boxes/subprocess_spec.rb
190
187
  - spec/boxes/template_spec.rb
188
+ - spec/boxes/testing/command_spec.rb
189
+ - spec/boxes/testing/matchers/have_exit_status_matcher_spec.rb
190
+ - spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
191
191
  - spec/spec_helper.rb
192
- - spec/support/subprocess_command.rb
192
+ - spec/support/env.rb
193
+ - spec/support/subprocess_command.sh
194
+ - spec/support/tmp.rb
195
+ - spec/tmp/.gitkeep
193
196
  - templates/debian/jessie64.erb
194
197
  - templates/debian/preseed.cfg
198
+ - templates/debian/stretch64.erb
195
199
  - templates/debian/wheezy64.erb
196
200
  - templates/ubuntu/precise64.erb
197
201
  - templates/ubuntu/preseed.cfg
198
202
  - templates/ubuntu/trusty64.erb
199
- - templates/ubuntu/wily64.erb
200
203
  - templates/ubuntu/xenial64.erb
201
204
  homepage: https://github.com/nickcharlton/boxes
202
205
  licenses:
@@ -218,19 +221,28 @@ required_rubygems_version: !ruby/object:Gem::Requirement
218
221
  version: '0'
219
222
  requirements: []
220
223
  rubyforge_project:
221
- rubygems_version: 2.5.1
224
+ rubygems_version: 2.6.13
222
225
  signing_key:
223
226
  specification_version: 4
224
227
  summary: A command line tool to take the complexity out of building Vagrant boxes.
225
228
  test_files:
226
- - features/boxes.feature
227
- - features/build.feature
228
- - features/env.feature
229
- - features/support/env.rb
229
+ - spec/acceptance/user_builds_box_spec.rb
230
+ - spec/acceptance/user_cleans_the_env_spec.rb
231
+ - spec/acceptance/user_shows_the_env_spec.rb
232
+ - spec/acceptance/user_views_env_help_spec.rb
233
+ - spec/acceptance/user_views_help_spec.rb
234
+ - spec/acceptance/user_views_version_spec.rb
235
+ - spec/acceptance_helper.rb
230
236
  - spec/boxes/builder_spec.rb
231
237
  - spec/boxes/config_spec.rb
232
238
  - spec/boxes/environment_spec.rb
233
239
  - spec/boxes/subprocess_spec.rb
234
240
  - spec/boxes/template_spec.rb
241
+ - spec/boxes/testing/command_spec.rb
242
+ - spec/boxes/testing/matchers/have_exit_status_matcher_spec.rb
243
+ - spec/boxes/testing/matchers/write_to_stdout_matcher_spec.rb
235
244
  - spec/spec_helper.rb
236
- - spec/support/subprocess_command.rb
245
+ - spec/support/env.rb
246
+ - spec/support/subprocess_command.sh
247
+ - spec/support/tmp.rb
248
+ - spec/tmp/.gitkeep