derelict_m 0.6.2a
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.cane +2 -0
- data/.coveralls.yml +1 -0
- data/.gitignore +18 -0
- data/.travis.yml +16 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +99 -0
- data/Rakefile +22 -0
- data/derelict.gemspec +63 -0
- data/lib/derelict.rb +74 -0
- data/lib/derelict/box.rb +29 -0
- data/lib/derelict/box/manager.rb +111 -0
- data/lib/derelict/box/not_found.rb +16 -0
- data/lib/derelict/connection.rb +84 -0
- data/lib/derelict/connection/invalid.rb +14 -0
- data/lib/derelict/connection/not_found.rb +13 -0
- data/lib/derelict/exception.rb +6 -0
- data/lib/derelict/exception/optional_reason.rb +32 -0
- data/lib/derelict/executer.rb +237 -0
- data/lib/derelict/instance.rb +147 -0
- data/lib/derelict/instance/command_failed.rb +30 -0
- data/lib/derelict/instance/invalid.rb +14 -0
- data/lib/derelict/instance/missing_binary.rb +13 -0
- data/lib/derelict/instance/non_directory.rb +13 -0
- data/lib/derelict/instance/not_found.rb +13 -0
- data/lib/derelict/parser.rb +27 -0
- data/lib/derelict/parser/box_list.rb +53 -0
- data/lib/derelict/parser/box_list/invalid_format.rb +16 -0
- data/lib/derelict/parser/plugin_list.rb +63 -0
- data/lib/derelict/parser/plugin_list/invalid_format.rb +16 -0
- data/lib/derelict/parser/plugin_list/needs_reinstall.rb +22 -0
- data/lib/derelict/parser/status.rb +90 -0
- data/lib/derelict/parser/status/invalid_format.rb +16 -0
- data/lib/derelict/parser/version.rb +28 -0
- data/lib/derelict/parser/version/invalid_format.rb +16 -0
- data/lib/derelict/plugin.rb +29 -0
- data/lib/derelict/plugin/manager.rb +107 -0
- data/lib/derelict/plugin/not_found.rb +14 -0
- data/lib/derelict/utils.rb +11 -0
- data/lib/derelict/utils/logger.rb +59 -0
- data/lib/derelict/utils/logger/array_outputter.rb +43 -0
- data/lib/derelict/utils/logger/invalid_type.rb +15 -0
- data/lib/derelict/utils/logger/raw_formatter.rb +12 -0
- data/lib/derelict/version.rb +3 -0
- data/lib/derelict/virtual_machine.rb +190 -0
- data/lib/derelict/virtual_machine/invalid.rb +14 -0
- data/lib/derelict/virtual_machine/not_found.rb +18 -0
- data/spec/coverage_helper.rb +19 -0
- data/spec/derelict/box/manager_spec.rb +171 -0
- data/spec/derelict/box/not_found_spec.rb +13 -0
- data/spec/derelict/box_spec.rb +37 -0
- data/spec/derelict/connection/invalid_spec.rb +16 -0
- data/spec/derelict/connection/not_found_spec.rb +13 -0
- data/spec/derelict/connection_spec.rb +107 -0
- data/spec/derelict/exception/optional_reason_spec.rb +41 -0
- data/spec/derelict/exception_spec.rb +11 -0
- data/spec/derelict/executer_spec.rb +129 -0
- data/spec/derelict/instance/command_failed_spec.rb +40 -0
- data/spec/derelict/instance/invalid_spec.rb +16 -0
- data/spec/derelict/instance/missing_binary_spec.rb +13 -0
- data/spec/derelict/instance/non_directory_spec.rb +13 -0
- data/spec/derelict/instance/not_found_spec.rb +13 -0
- data/spec/derelict/instance_spec.rb +258 -0
- data/spec/derelict/parser/box_list/invalid_format_spec.rb +16 -0
- data/spec/derelict/parser/box_list_spec.rb +64 -0
- data/spec/derelict/parser/plugin_list/invalid_format_spec.rb +16 -0
- data/spec/derelict/parser/plugin_list/needs_reinstall_spec.rb +13 -0
- data/spec/derelict/parser/plugin_list_spec.rb +82 -0
- data/spec/derelict/parser/status/invalid_format_spec.rb +16 -0
- data/spec/derelict/parser/status_spec.rb +214 -0
- data/spec/derelict/parser/version/invalid_format_spec.rb +16 -0
- data/spec/derelict/parser/version_spec.rb +42 -0
- data/spec/derelict/parser_spec.rb +24 -0
- data/spec/derelict/plugin/manager_spec.rb +208 -0
- data/spec/derelict/plugin/not_found_spec.rb +13 -0
- data/spec/derelict/plugin_spec.rb +37 -0
- data/spec/derelict/utils/logger/array_outputter_spec.rb +40 -0
- data/spec/derelict/utils/logger/invalid_type_spec.rb +13 -0
- data/spec/derelict/utils/logger/raw_formatter_spec.rb +17 -0
- data/spec/derelict/utils/logger_spec.rb +35 -0
- data/spec/derelict/virtual_machine/invalid_spec.rb +16 -0
- data/spec/derelict/virtual_machine/not_found_spec.rb +34 -0
- data/spec/derelict/virtual_machine_spec.rb +356 -0
- data/spec/derelict_spec.rb +50 -0
- data/spec/spec_helper.rb +32 -0
- data/spec/support/log_context.rb +36 -0
- metadata +332 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
module Derelict
|
2
|
+
class VirtualMachine
|
3
|
+
# Represents an invalid virtual machine, which Derelict can't use
|
4
|
+
class Invalid < ::Derelict::Exception
|
5
|
+
include Derelict::Exception::OptionalReason
|
6
|
+
|
7
|
+
private
|
8
|
+
# Retrieves the default error message
|
9
|
+
def default_message
|
10
|
+
"Invalid Derelict virtual machine"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Derelict
|
2
|
+
class VirtualMachine
|
3
|
+
# The requested virtual machine isn't defined in the Vagrantfile
|
4
|
+
class NotFound < Invalid
|
5
|
+
# Initializes a new instance of this exception for a given name
|
6
|
+
#
|
7
|
+
# * name: The requested name of the virtual machine
|
8
|
+
# * connection: The Derelict connection used for this VM
|
9
|
+
def initialize(name, connection = nil)
|
10
|
+
if connection.respond_to? :path
|
11
|
+
super "Virtual machine #{name} not found in #{connection.path}"
|
12
|
+
else
|
13
|
+
super "Virtual machine #{name} not found"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
if ENV['TRAVIS']
|
2
|
+
# Running on Travis CI: initialize Coveralls to submit coverage data
|
3
|
+
require "coveralls"
|
4
|
+
Coveralls.wear!
|
5
|
+
else
|
6
|
+
# Not running on Travis CI: Run SimpleCov locally for coverage data
|
7
|
+
# Since SimpleCov requires Ruby 1.9+, only include it if we're
|
8
|
+
# running on a compatible version.
|
9
|
+
version_major = RbConfig::CONFIG["MAJOR"].to_i
|
10
|
+
version_minor = RbConfig::CONFIG["MINOR"].to_i
|
11
|
+
if version_major >= 2 or (version_major == 1 and version_minor >= 9)
|
12
|
+
require "simplecov"
|
13
|
+
SimpleCov.start do
|
14
|
+
add_filter "/spec/"
|
15
|
+
add_filter "/vendor/"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,171 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Box::Manager do
|
4
|
+
let(:instance) { double("instance", :description => "test instance") }
|
5
|
+
let(:manager) { Derelict::Box::Manager.new instance }
|
6
|
+
subject { manager }
|
7
|
+
|
8
|
+
it "is autoloaded" do
|
9
|
+
should be_a Derelict::Box::Manager
|
10
|
+
end
|
11
|
+
|
12
|
+
include_context "logged messages"
|
13
|
+
let(:expected_logs) {[
|
14
|
+
"DEBUG manager: Successfully initialized Derelict::Box::Manager for test instance\n"
|
15
|
+
]}
|
16
|
+
|
17
|
+
describe "#list" do
|
18
|
+
let(:stdout) { "stdout\n" }
|
19
|
+
let(:result) { double("result", :stdout => stdout) }
|
20
|
+
let(:parser) { double("parser", :boxes => boxes) }
|
21
|
+
let(:boxes) { [:foo, :bar] }
|
22
|
+
|
23
|
+
subject { manager.list }
|
24
|
+
|
25
|
+
before do
|
26
|
+
expect(instance).to receive(:execute!).with(:box, "list").and_return(result)
|
27
|
+
expect(Derelict::Parser::BoxList).to receive(:new).with(stdout).and_return(parser)
|
28
|
+
end
|
29
|
+
|
30
|
+
it { should be boxes }
|
31
|
+
|
32
|
+
include_context "logged messages"
|
33
|
+
let(:expected_logs) {[
|
34
|
+
"DEBUG manager: Successfully initialized Derelict::Box::Manager for test instance\n",
|
35
|
+
" INFO manager: Retrieving Vagrant box list for Derelict::Box::Manager for test instance\n",
|
36
|
+
]}
|
37
|
+
end
|
38
|
+
|
39
|
+
describe "#present?" do
|
40
|
+
let(:box_name) { double("box_name") }
|
41
|
+
let(:box) { double("box", :provider => box_provider) }
|
42
|
+
let(:box_provider) { nil }
|
43
|
+
let(:provider) { nil }
|
44
|
+
subject { manager.present? box_name, provider }
|
45
|
+
|
46
|
+
context "with known box" do
|
47
|
+
before { expect(manager).to receive(:fetch).with(box_name, provider).and_return(box) }
|
48
|
+
|
49
|
+
let(:provider) { "provider_one" }
|
50
|
+
let(:box_provider) { "provider_one" }
|
51
|
+
it { should be true }
|
52
|
+
end
|
53
|
+
|
54
|
+
context "with unknown box" do
|
55
|
+
before { expect(manager).to receive(:fetch).with(box_name, provider).and_raise(Derelict::Box::NotFound.new box_name, provider) }
|
56
|
+
it { should be false }
|
57
|
+
end
|
58
|
+
|
59
|
+
include_context "logged messages"
|
60
|
+
let(:expected_logs) {[
|
61
|
+
"DEBUG manager: Successfully initialized Derelict::Box::Manager for test instance\n",
|
62
|
+
" INFO manager: Retrieving Vagrant box list for Derelict::Box::Manager for test instance\n",
|
63
|
+
]}
|
64
|
+
end
|
65
|
+
|
66
|
+
describe "#add" do
|
67
|
+
let(:log) { true }
|
68
|
+
let(:box_name) { double("box_name", :to_s => "test box") }
|
69
|
+
let(:source) { double("source", :to_s => "test source") }
|
70
|
+
let(:result) { double("result") }
|
71
|
+
let(:options) { {:log => log} }
|
72
|
+
subject { manager.add box_name, source, options }
|
73
|
+
|
74
|
+
context "with force disabled" do
|
75
|
+
before do
|
76
|
+
expect(instance).to receive(:execute!).with(:box, "add", box_name, source).and_yield("test", nil).and_return(result)
|
77
|
+
end
|
78
|
+
|
79
|
+
it { should be result }
|
80
|
+
|
81
|
+
context "with logging enabled" do
|
82
|
+
include_context "logged messages"
|
83
|
+
let(:expected_logs) {[
|
84
|
+
"DEBUG manager: Successfully initialized Derelict::Box::Manager for test instance\n",
|
85
|
+
" INFO manager: Adding box 'test box' from 'test source' using Derelict::Box::Manager for test instance\n",
|
86
|
+
" INFO external: test\n",
|
87
|
+
]}
|
88
|
+
end
|
89
|
+
|
90
|
+
context "with logging disabled" do
|
91
|
+
let(:log) { false }
|
92
|
+
include_context "logged messages"
|
93
|
+
let(:expected_logs) {[
|
94
|
+
"DEBUG manager: Successfully initialized Derelict::Box::Manager for test instance\n",
|
95
|
+
" INFO manager: Adding box 'test box' from 'test source' using Derelict::Box::Manager for test instance\n",
|
96
|
+
]}
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
context "with force enabled" do
|
101
|
+
before do
|
102
|
+
expect(instance).to receive(:execute!).with(:box, "add", box_name, source, "--force").and_return(result)
|
103
|
+
end
|
104
|
+
|
105
|
+
let(:options) { {:force => true} }
|
106
|
+
it { should be result }
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
describe "#remove" do
|
111
|
+
let(:log) { true }
|
112
|
+
let(:box_name) { "test_box" }
|
113
|
+
let(:provider) { "provider_one" }
|
114
|
+
let(:result) { double("result") }
|
115
|
+
subject { manager.remove box_name, :provider => provider, :log => log }
|
116
|
+
|
117
|
+
before do
|
118
|
+
expect(instance).to receive(:execute!).with(:box, "remove", box_name, provider).and_yield("test", nil).and_return(result)
|
119
|
+
end
|
120
|
+
|
121
|
+
it { should be result }
|
122
|
+
|
123
|
+
context "with logging enabled" do
|
124
|
+
include_context "logged messages"
|
125
|
+
let(:expected_logs) {[
|
126
|
+
"DEBUG manager: Successfully initialized Derelict::Box::Manager for test instance\n",
|
127
|
+
" INFO manager: Removing box 'test_box' for 'provider_one' using Derelict::Box::Manager for test instance\n",
|
128
|
+
" INFO external: test\n",
|
129
|
+
]}
|
130
|
+
end
|
131
|
+
|
132
|
+
context "with logging disabled" do
|
133
|
+
let(:log) { false }
|
134
|
+
include_context "logged messages"
|
135
|
+
let(:expected_logs) {[
|
136
|
+
"DEBUG manager: Successfully initialized Derelict::Box::Manager for test instance\n",
|
137
|
+
" INFO manager: Removing box 'test_box' for 'provider_one' using Derelict::Box::Manager for test instance\n",
|
138
|
+
]}
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
describe "#fetch" do
|
143
|
+
let(:foo) { double("foo", :name => "foo", :provider => "provider_one") }
|
144
|
+
let(:bar) { double("bar", :name => "bar", :provider => "provider_two") }
|
145
|
+
let(:boxes) { [foo, bar] }
|
146
|
+
|
147
|
+
let(:box_name) { double("box_name") }
|
148
|
+
let(:box_provider) { double("box_provider") }
|
149
|
+
subject { manager.fetch box_name, box_provider }
|
150
|
+
before { expect(manager).to receive(:list).and_return(boxes) }
|
151
|
+
|
152
|
+
context "with known box" do
|
153
|
+
let(:box_name) { "foo" }
|
154
|
+
let(:box_provider) { "provider_one" }
|
155
|
+
it { should be foo }
|
156
|
+
end
|
157
|
+
|
158
|
+
context "with unknown box" do
|
159
|
+
let(:box_name) { "qux" }
|
160
|
+
it "should raise NotFound" do
|
161
|
+
expect { subject }.to raise_error Derelict::Box::NotFound
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
165
|
+
include_context "logged messages"
|
166
|
+
let(:expected_logs) {[
|
167
|
+
"DEBUG manager: Successfully initialized Derelict::Box::Manager for test instance\n",
|
168
|
+
]}
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Box::NotFound do
|
4
|
+
subject { Derelict::Box::NotFound.new "test", "provider_one" }
|
5
|
+
|
6
|
+
it "is autoloaded" do
|
7
|
+
should be_a Derelict::Box::NotFound
|
8
|
+
end
|
9
|
+
|
10
|
+
its(:message) {
|
11
|
+
should eq "Box 'test' for provider 'provider_one' missing"
|
12
|
+
}
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Box do
|
4
|
+
let(:name) { double("name") }
|
5
|
+
let(:provider) { double("provider") }
|
6
|
+
let(:box) { Derelict::Box.new name, provider }
|
7
|
+
subject { box }
|
8
|
+
|
9
|
+
it "is autoloaded" do
|
10
|
+
should be_a Derelict::Box
|
11
|
+
end
|
12
|
+
|
13
|
+
its(:name) { should be name }
|
14
|
+
its(:provider) { should be provider }
|
15
|
+
|
16
|
+
context "when comparing to an equivalent" do
|
17
|
+
let(:other) { box.dup }
|
18
|
+
|
19
|
+
it { should eq other }
|
20
|
+
its(:hash) { should eq other.hash }
|
21
|
+
|
22
|
+
specify "#eql?(other) should be true" do
|
23
|
+
expect(subject.eql? other).to be true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
context "when comparing to a non-equivalent" do
|
28
|
+
let(:other) { box.class.new "not_foo", "other_provider" }
|
29
|
+
|
30
|
+
it { should_not eq other }
|
31
|
+
its(:hash) { should_not eq other.hash }
|
32
|
+
|
33
|
+
specify "#eql?(other) should be false" do
|
34
|
+
expect(subject.eql? other).to be false
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Connection::Invalid do
|
4
|
+
it "is autoloaded" do
|
5
|
+
should be_a Derelict::Connection::Invalid
|
6
|
+
end
|
7
|
+
|
8
|
+
context "when using default reason" do
|
9
|
+
its(:message) { should eq "Invalid Derelict connection" }
|
10
|
+
end
|
11
|
+
|
12
|
+
context "when using custom reason" do
|
13
|
+
subject { Derelict::Connection::Invalid.new "reason" }
|
14
|
+
its(:message) { should eq "Invalid Derelict connection: reason" }
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Connection::NotFound do
|
4
|
+
subject { Derelict::Connection::NotFound.new "/foo/bar" }
|
5
|
+
|
6
|
+
it "is autoloaded" do
|
7
|
+
should be_a Derelict::Connection::NotFound
|
8
|
+
end
|
9
|
+
|
10
|
+
its(:message) {
|
11
|
+
should eq "Invalid Derelict connection: Vagrantfile not found for /foo/bar"
|
12
|
+
}
|
13
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Connection do
|
4
|
+
let(:description) { "the test instance" }
|
5
|
+
let(:instance) { double("instance", :description => description) }
|
6
|
+
let(:path) { "/baz/qux" }
|
7
|
+
let(:connection) { Derelict::Connection.new instance, path }
|
8
|
+
subject { connection }
|
9
|
+
|
10
|
+
it "is autoloaded" do
|
11
|
+
should be_a Derelict::Connection
|
12
|
+
end
|
13
|
+
|
14
|
+
include_context "logged messages"
|
15
|
+
let(:expected_logs) {[
|
16
|
+
"DEBUG connection: Successfully initialized Derelict::Connection at '/baz/qux' using the test instance\n"
|
17
|
+
]}
|
18
|
+
|
19
|
+
describe "#validate!" do
|
20
|
+
subject { connection.validate! }
|
21
|
+
let(:exists?) { double("exists?") }
|
22
|
+
before do
|
23
|
+
expect(File).to receive(:exists?).with(path).and_return(exists?)
|
24
|
+
end
|
25
|
+
|
26
|
+
context "with valid data" do
|
27
|
+
let(:exists?) { true }
|
28
|
+
it { should be connection }
|
29
|
+
|
30
|
+
include_context "logged messages"
|
31
|
+
let(:expected_logs) {[
|
32
|
+
"DEBUG connection: Successfully initialized Derelict::Connection at '/baz/qux' using the test instance\n",
|
33
|
+
"DEBUG connection: Starting validation for Derelict::Connection at '/baz/qux' using the test instance\n",
|
34
|
+
" INFO connection: Successfully validated Derelict::Connection at '/baz/qux' using the test instance\n",
|
35
|
+
]}
|
36
|
+
end
|
37
|
+
|
38
|
+
context "with invalid data" do
|
39
|
+
let(:exists?) { false }
|
40
|
+
it "should raise NotFound" do
|
41
|
+
expect { subject }.to raise_error Derelict::Connection::NotFound
|
42
|
+
end
|
43
|
+
|
44
|
+
include_context "logged messages"
|
45
|
+
let(:expected_logs) {[
|
46
|
+
"DEBUG connection: Successfully initialized Derelict::Connection at '/baz/qux' using the test instance\n",
|
47
|
+
"DEBUG connection: Starting validation for Derelict::Connection at '/baz/qux' using the test instance\n",
|
48
|
+
]}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
describe "#execute" do
|
53
|
+
subject { connection.execute :test, "arg 1" }
|
54
|
+
|
55
|
+
it "should change current working directory first" do
|
56
|
+
expect(Dir).to receive(:chdir).with(path).and_return(:foo) # no yield
|
57
|
+
expect(instance).to_not receive(:execute)
|
58
|
+
expect(subject).to be :foo
|
59
|
+
end
|
60
|
+
|
61
|
+
it "should delegate to @instance#execute" do
|
62
|
+
expect(Dir).to receive(:chdir).with(path).and_yield
|
63
|
+
expect(instance).to receive(:execute).with(:test, "arg 1").and_return(:bar)
|
64
|
+
expect(subject).to be :bar
|
65
|
+
end
|
66
|
+
|
67
|
+
include_context "logged messages"
|
68
|
+
let(:expected_logs) {[
|
69
|
+
"DEBUG connection: Successfully initialized Derelict::Connection at '/baz/qux' using the test instance\n",
|
70
|
+
"DEBUG connection: Executing test [\"arg 1\"] on Derelict::Connection at '/baz/qux' using the test instance\n",
|
71
|
+
]}
|
72
|
+
end
|
73
|
+
|
74
|
+
describe "#execute!" do
|
75
|
+
subject { connection.execute! :test, "arg 1" }
|
76
|
+
|
77
|
+
it "should change current working directory first" do
|
78
|
+
expect(Dir).to receive(:chdir).with(path).and_return(:foo) # no yield
|
79
|
+
expect(instance).to_not receive(:execute!)
|
80
|
+
expect(subject).to be :foo
|
81
|
+
end
|
82
|
+
|
83
|
+
it "should delegate to @instance#execute!" do
|
84
|
+
expect(Dir).to receive(:chdir).with(path).and_yield
|
85
|
+
expect(instance).to receive(:execute!).with(:test, "arg 1").and_return(:bar)
|
86
|
+
expect(subject).to be :bar
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
describe "#vm" do
|
91
|
+
let(:name) { :test }
|
92
|
+
let(:vm) { double("vm") }
|
93
|
+
before do
|
94
|
+
c = Derelict::VirtualMachine
|
95
|
+
expect(c).to receive(:new).with(connection, name).and_return(vm)
|
96
|
+
expect(vm).to receive(:validate!).and_return(vm)
|
97
|
+
end
|
98
|
+
subject { connection.vm name }
|
99
|
+
it { should be vm }
|
100
|
+
|
101
|
+
include_context "logged messages"
|
102
|
+
let(:expected_logs) {[
|
103
|
+
"DEBUG connection: Successfully initialized Derelict::Connection at '/baz/qux' using the test instance\n",
|
104
|
+
"DEBUG connection: Retrieving VM 'test' from Derelict::Connection at '/baz/qux' using the test instance\n",
|
105
|
+
]}
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,41 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Derelict::Exception::OptionalReason do
|
4
|
+
context "with #default_message left unimplemented" do
|
5
|
+
let(:exception) do
|
6
|
+
Class.new ::Exception do
|
7
|
+
include Derelict::Exception::OptionalReason
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
describe "#initialize" do
|
12
|
+
subject { exception.new reason }
|
13
|
+
let(:reason) { "test reason" }
|
14
|
+
|
15
|
+
it "should raise NotImplementedError" do
|
16
|
+
expect { subject }.to raise_error NotImplementedError
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
context "with #default_message implemented" do
|
22
|
+
let(:exception) do
|
23
|
+
Class.new ::Exception do
|
24
|
+
include Derelict::Exception::OptionalReason
|
25
|
+
private
|
26
|
+
def default_message
|
27
|
+
"test"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
describe "#initialize" do
|
33
|
+
subject { exception.new reason }
|
34
|
+
let(:reason) { "test reason" }
|
35
|
+
|
36
|
+
it "should raise NotImplementedError" do
|
37
|
+
expect { subject }.to_not raise_error
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|