vagrant-tun 0.0.1 → 0.0.2
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.
data/README.md
CHANGED
|
@@ -47,13 +47,13 @@ $ make test
|
|
|
47
47
|
```
|
|
48
48
|
$ make
|
|
49
49
|
rake build
|
|
50
|
-
vagrant-tun 0.0.
|
|
50
|
+
vagrant-tun 0.0.2 built to pkg/vagrant-tun-0.0.2.gem.
|
|
51
51
|
```
|
|
52
52
|
|
|
53
53
|
### Install the built gemfile
|
|
54
54
|
```
|
|
55
55
|
$ make install
|
|
56
56
|
find pkg/ -name '*.gem' | head -n 1 | xargs vagrant plugin install
|
|
57
|
-
Installing the 'pkg/vagrant-tun-0.0.
|
|
58
|
-
Installed the plugin 'vagrant-tun (0.0.
|
|
57
|
+
Installing the 'pkg/vagrant-tun-0.0.2.gem' plugin. This can take a few minutes...
|
|
58
|
+
Installed the plugin 'vagrant-tun (0.0.2)'!
|
|
59
59
|
```
|
data/lib/vagrant-tun/command.rb
CHANGED
data/lib/vagrant-tun/version.rb
CHANGED
data/lib/vagrant-tun.rb
CHANGED
|
@@ -13,8 +13,8 @@ module VagrantTun
|
|
|
13
13
|
Config
|
|
14
14
|
end
|
|
15
15
|
|
|
16
|
-
action_hook(:VagrantTun
|
|
17
|
-
hook.
|
|
16
|
+
action_hook(:VagrantTun) do |hook|
|
|
17
|
+
hook.before(Vagrant::Action::Builtin::Provision, VagrantTun::Command)
|
|
18
18
|
end
|
|
19
19
|
end
|
|
20
20
|
end
|
|
@@ -10,11 +10,7 @@ describe VagrantTun::Command do
|
|
|
10
10
|
let(:env) { { :machine => machine, :ui => ui } }
|
|
11
11
|
|
|
12
12
|
# pretend env contains the Vagrant ui element
|
|
13
|
-
let(:ui)
|
|
14
|
-
double('ui').tap do |ui|
|
|
15
|
-
allow(ui).to receive(:info) { nil }
|
|
16
|
-
end
|
|
17
|
-
end
|
|
13
|
+
let(:ui) { { } }
|
|
18
14
|
|
|
19
15
|
# pretend env[:machine].config.tun.enabled is false
|
|
20
16
|
let(:machine) do
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
# vim: set fileencoding=utf-8
|
|
3
|
+
|
|
4
|
+
require 'spec_helper'
|
|
5
|
+
require "vagrant-tun/command"
|
|
6
|
+
|
|
7
|
+
describe VagrantTun::Command do
|
|
8
|
+
# create a fake app and env to pass into the VagrantTun::Command constructor
|
|
9
|
+
let(:app) { lambda { |env| } }
|
|
10
|
+
let(:env) { { :ui => ui } }
|
|
11
|
+
|
|
12
|
+
# pretend env contains the Vagrant ui element
|
|
13
|
+
let(:ui) do
|
|
14
|
+
double('ui').tap do |ui|
|
|
15
|
+
allow(ui).to receive(:info) { nil }
|
|
16
|
+
allow(ui).to receive(:error) { nil }
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# instantiate class of which a method is to be tested
|
|
21
|
+
subject { described_class.new(app, env) }
|
|
22
|
+
|
|
23
|
+
# the method that we are going to test
|
|
24
|
+
describe "#log_success_or_fail_message" do
|
|
25
|
+
|
|
26
|
+
context "when success is true" do
|
|
27
|
+
it "logs the success message" do
|
|
28
|
+
# Check that the success message was logged
|
|
29
|
+
expect(ui).to receive(:info).once.with("Ensured the TUN module is loaded into the kernel.")
|
|
30
|
+
|
|
31
|
+
# Check that the failure message was not logged
|
|
32
|
+
expect(ui).to receive(:error).never
|
|
33
|
+
|
|
34
|
+
# perform the success call
|
|
35
|
+
subject.log_success_or_fail_message(env, true)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
context "when success is false" do
|
|
40
|
+
it "logs the failure message" do
|
|
41
|
+
# Check that the failure message was logged
|
|
42
|
+
expect(ui).to receive(:error).once.with("Failed to load the TUN/TAP adapter. If you are running a custom kernel make sure you have the tun module enabled.")
|
|
43
|
+
|
|
44
|
+
# Check that the success message was not logged
|
|
45
|
+
expect(ui).to receive(:info).never
|
|
46
|
+
|
|
47
|
+
# perform the failure call
|
|
48
|
+
subject.log_success_or_fail_message(env, false)
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
|
2
|
+
# vim: set fileencoding=utf-8
|
|
3
|
+
|
|
4
|
+
require 'spec_helper'
|
|
5
|
+
require "vagrant-tun/command"
|
|
6
|
+
|
|
7
|
+
describe VagrantTun::Command do
|
|
8
|
+
# create a fake app and env to pass into the VagrantTun::Command constructor
|
|
9
|
+
let(:app) { lambda { |env| } }
|
|
10
|
+
let(:env) { { :machine => machine, :ui => ui } }
|
|
11
|
+
|
|
12
|
+
# pretend env contains the Vagrant ui element
|
|
13
|
+
let(:ui) do
|
|
14
|
+
double('ui').tap do |ui|
|
|
15
|
+
allow(ui).to receive(:info) { nil }
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# pretend env[:machine].action and .communicate can be called
|
|
20
|
+
let(:machine) do
|
|
21
|
+
double('machine').tap do |machine|
|
|
22
|
+
allow(machine).to receive(:action) { action }
|
|
23
|
+
allow(machine).to receive(:communicate) { communicate }
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
let(:action) do
|
|
27
|
+
double('action').tap do |action|
|
|
28
|
+
allow(action).to receive(:reload) { reload }
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
let(:reload) { nil }
|
|
32
|
+
let(:communicate) do
|
|
33
|
+
double('communicate').tap do |communicate|
|
|
34
|
+
allow(communicate).to receive(:ready?) { ready }
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
let(:ready) { true }
|
|
38
|
+
|
|
39
|
+
# Stub all sleeps
|
|
40
|
+
before do
|
|
41
|
+
allow_any_instance_of(Object).to receive(:sleep)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Call the method under test after every 'it'. Similar to setUp in Python TestCase
|
|
45
|
+
after do
|
|
46
|
+
subject.reboot(env)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# instantiate class of which a method is to be tested
|
|
50
|
+
subject { described_class.new(app, env) }
|
|
51
|
+
|
|
52
|
+
# the method that we are going to test
|
|
53
|
+
describe "#reboot" do
|
|
54
|
+
|
|
55
|
+
context "when machine is rebooted" do
|
|
56
|
+
it "logs the reboot message and reboots the machine" do
|
|
57
|
+
# Check that the reboot message was logged
|
|
58
|
+
expect(ui).to receive(:info).once.with("Rebooting because we couldn't load the tun module. Maybe the kernel was updated?")
|
|
59
|
+
|
|
60
|
+
# Check that the reload command was sent
|
|
61
|
+
expect(machine).to receive(:action).once.with(:reload)
|
|
62
|
+
|
|
63
|
+
# Check that we block wait until ready
|
|
64
|
+
expect(communicate).to receive(:ready?).once.and_return(false, false, true)
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: vagrant-tun
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2016-08-
|
|
12
|
+
date: 2016-08-06 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: bundler
|
|
@@ -97,6 +97,8 @@ files:
|
|
|
97
97
|
- spec/unit/command/call_spec.rb
|
|
98
98
|
- spec/unit/command/ensure_tun_available_spec.rb
|
|
99
99
|
- spec/unit/command/iter_verify_adapter_spec.rb
|
|
100
|
+
- spec/unit/command/log_success_or_fail_message_spec.rb
|
|
101
|
+
- spec/unit/command/reboot_spec.rb
|
|
100
102
|
- vagrant-tun.gemspec
|
|
101
103
|
homepage: https://github.com/vdloo/vagrant-tun
|
|
102
104
|
licenses:
|