devdnsd 1.1.10 → 1.5.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.
- data/.gitignore +7 -21
- data/.yardopts +1 -1
- data/Gemfile.lock +15 -15
- data/README.md +2 -2
- data/Rakefile +2 -2
- data/bin/devdnsd +28 -59
- data/devdnsd.gemspec +1 -3
- data/doc/DevDNSd.html +130 -0
- data/doc/DevDNSd/Application.html +2415 -0
- data/doc/DevDNSd/Configuration.html +421 -0
- data/doc/DevDNSd/Errors.html +125 -0
- data/doc/DevDNSd/Errors/InvalidRule.html +133 -0
- data/doc/DevDNSd/Rule.html +1469 -0
- data/doc/DevDNSd/Version.html +189 -0
- data/doc/_index.html +200 -0
- data/doc/class_list.html +53 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +57 -0
- data/doc/css/style.css +328 -0
- data/doc/file.README.html +161 -0
- data/doc/file_list.html +55 -0
- data/doc/frames.html +28 -0
- data/doc/index.html +161 -0
- data/doc/js/app.js +214 -0
- data/doc/js/full_list.js +173 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +340 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/devdnsd.rb +2 -3
- data/lib/devdnsd/application.rb +21 -26
- data/lib/devdnsd/configuration.rb +2 -3
- data/lib/devdnsd/errors.rb +1 -1
- data/lib/devdnsd/rule.rb +1 -1
- data/lib/devdnsd/version.rb +3 -3
- data/spec/coverage_helper.rb +4 -3
- data/spec/devdnsd/application_spec.rb +67 -23
- data/spec/devdnsd/configuration_spec.rb +2 -16
- data/spec/devdnsd/rule_spec.rb +1 -1
- data/spec/spec_helper.rb +1 -1
- data/utils/tester.rb +1 -2
- metadata +28 -23
@@ -0,0 +1,112 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
4
|
+
<head>
|
5
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
6
|
+
<title>
|
7
|
+
Top Level Namespace
|
8
|
+
|
9
|
+
— Documentation by YARD 0.8.2.1
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" media="screen" charset="utf-8" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" media="screen" charset="utf-8" />
|
16
|
+
|
17
|
+
<script type="text/javascript" charset="utf-8">
|
18
|
+
hasFrames = window.top.frames.main ? true : false;
|
19
|
+
relpath = '';
|
20
|
+
framesUrl = "frames.html#!" + escape(window.location.href);
|
21
|
+
</script>
|
22
|
+
|
23
|
+
|
24
|
+
<script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
|
25
|
+
|
26
|
+
<script type="text/javascript" charset="utf-8" src="js/app.js"></script>
|
27
|
+
|
28
|
+
|
29
|
+
</head>
|
30
|
+
<body>
|
31
|
+
<div id="header">
|
32
|
+
<div id="menu">
|
33
|
+
|
34
|
+
<a href="_index.html">Index</a> »
|
35
|
+
|
36
|
+
|
37
|
+
<span class="title">Top Level Namespace</span>
|
38
|
+
|
39
|
+
|
40
|
+
<div class="noframes"><span class="title">(</span><a href="." target="_top">no frames</a><span class="title">)</span></div>
|
41
|
+
</div>
|
42
|
+
|
43
|
+
<div id="search">
|
44
|
+
|
45
|
+
<a class="full_list_link" id="class_list_link"
|
46
|
+
href="class_list.html">
|
47
|
+
Class List
|
48
|
+
</a>
|
49
|
+
|
50
|
+
<a class="full_list_link" id="method_list_link"
|
51
|
+
href="method_list.html">
|
52
|
+
Method List
|
53
|
+
</a>
|
54
|
+
|
55
|
+
<a class="full_list_link" id="file_list_link"
|
56
|
+
href="file_list.html">
|
57
|
+
File List
|
58
|
+
</a>
|
59
|
+
|
60
|
+
</div>
|
61
|
+
<div class="clear"></div>
|
62
|
+
</div>
|
63
|
+
|
64
|
+
<iframe id="search_frame"></iframe>
|
65
|
+
|
66
|
+
<div id="content"><h1>Top Level Namespace
|
67
|
+
|
68
|
+
|
69
|
+
|
70
|
+
</h1>
|
71
|
+
|
72
|
+
<dl class="box">
|
73
|
+
|
74
|
+
|
75
|
+
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
|
80
|
+
|
81
|
+
</dl>
|
82
|
+
<div class="clear"></div>
|
83
|
+
|
84
|
+
<h2>Defined Under Namespace</h2>
|
85
|
+
<p class="children">
|
86
|
+
|
87
|
+
|
88
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="DevDNSd.html" title="DevDNSd (module)">DevDNSd</a></span>
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
</p>
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
|
98
|
+
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
</div>
|
104
|
+
|
105
|
+
<div id="footer">
|
106
|
+
Generated on Wed Aug 22 13:48:31 2012 by
|
107
|
+
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
|
+
0.8.2.1 (ruby-1.9.2).
|
109
|
+
</div>
|
110
|
+
|
111
|
+
</body>
|
112
|
+
</html>
|
data/lib/devdnsd.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
# This file is part of the
|
3
|
+
# This file is part of the devdnsd gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
4
|
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
5
|
#
|
6
6
|
|
7
7
|
require "rubygems"
|
8
|
-
require "
|
8
|
+
require "mamertes"
|
9
9
|
require "rubydns"
|
10
|
-
require "gli"
|
11
10
|
require "rexec/daemon"
|
12
11
|
|
13
12
|
Lazier.load!(:object)
|
data/lib/devdnsd/application.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
# This file is part of the
|
3
|
+
# This file is part of the devdnsd gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
4
|
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
5
|
#
|
6
6
|
|
@@ -17,39 +17,34 @@ module DevDNSd
|
|
17
17
|
# The {Configuration Configuration} of this application.
|
18
18
|
attr_reader :config
|
19
19
|
|
20
|
-
# The
|
21
|
-
attr_reader :
|
20
|
+
# The Mamertes command.
|
21
|
+
attr_reader :command
|
22
22
|
|
23
23
|
# The logger for this application.
|
24
24
|
attr_accessor :logger
|
25
25
|
|
26
26
|
# Creates a new application.
|
27
27
|
#
|
28
|
-
# @param
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
@args = {
|
33
|
-
:global => globals,
|
34
|
-
:local => locals,
|
35
|
-
:args => args
|
36
|
-
}
|
28
|
+
# @param command [Mamertes::Command] The current Mamertes command.
|
29
|
+
def initialize(command)
|
30
|
+
@command = command
|
31
|
+
application = @command.application
|
37
32
|
|
38
33
|
# Setup logger
|
39
34
|
Bovem::Logger.start_time = Time.now
|
40
|
-
@logger = Bovem::Logger.create(Bovem::Logger.get_real_file(
|
35
|
+
@logger = Bovem::Logger.create(Bovem::Logger.get_real_file(application.options["log-file"].value) || Bovem::Logger.default_file, Logger::INFO)
|
41
36
|
|
42
37
|
# Open configuration
|
43
38
|
begin
|
44
39
|
overrides = {
|
45
|
-
:foreground =>
|
46
|
-
:log_file =>
|
47
|
-
:log_level =>
|
48
|
-
:tld =>
|
49
|
-
:port =>
|
40
|
+
:foreground => command.name == "start" ? command.options["foreground"].value : false,
|
41
|
+
:log_file => application.options["log-file"].value,
|
42
|
+
:log_level => application.options["log-level"].value,
|
43
|
+
:tld => application.options["tld"].value,
|
44
|
+
:port => application.options["port"].value
|
50
45
|
}.reject {|k,v| v.nil? }
|
51
46
|
|
52
|
-
@config = DevDNSd::Configuration.new(
|
47
|
+
@config = DevDNSd::Configuration.new(application.options["configuration"].value, overrides, @logger)
|
53
48
|
|
54
49
|
@logger = nil
|
55
50
|
@logger = self.get_logger
|
@@ -186,7 +181,7 @@ module DevDNSd
|
|
186
181
|
case type
|
187
182
|
when :MX
|
188
183
|
preference = options.delete(:preference)
|
189
|
-
preference = 10
|
184
|
+
preference = preference.nil? ? 10 : preference.to_integer(10)
|
190
185
|
final_reply << preference
|
191
186
|
end
|
192
187
|
|
@@ -262,7 +257,7 @@ module DevDNSd
|
|
262
257
|
begin
|
263
258
|
logger.info("Creating the launch agent in #{launch_agent} ...")
|
264
259
|
|
265
|
-
args = $ARGV ? $ARGV[0, $ARGV.length - 1] : [
|
260
|
+
args = $ARGV ? $ARGV[0, $ARGV.length - 1] : []
|
266
261
|
|
267
262
|
plist = {"KeepAlive" => true, "Label" => "it.cowtech.devdnsd", "Program" => (::Pathname.new(Dir.pwd) + $0).to_s, "ProgramArguments" => args, "RunAtLoad" => true}
|
268
263
|
::File.open(launch_agent, "w") {|f|
|
@@ -345,14 +340,14 @@ module DevDNSd
|
|
345
340
|
end
|
346
341
|
|
347
342
|
# Returns a unique (singleton) instance of the application.
|
348
|
-
#
|
349
|
-
# @param
|
350
|
-
# @param args [Array] Extra arguments.
|
343
|
+
#
|
344
|
+
# @param command [Mamertes::Command] The current Mamertes command.
|
351
345
|
# @param force [Boolean] If to force recreation of the instance.
|
352
346
|
# @return [Application] The unique (singleton) instance of the application.
|
353
|
-
def self.instance(
|
347
|
+
def self.instance(command = nil, force = false)
|
354
348
|
@instance = nil if force
|
355
|
-
@instance ||= DevDNSd::Application.new(
|
349
|
+
@instance ||= DevDNSd::Application.new(command) if command
|
350
|
+
@instance
|
356
351
|
end
|
357
352
|
|
358
353
|
# Runs the application in foreground.
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
# This file is part of the
|
3
|
+
# This file is part of the devdnsd gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
4
|
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
5
|
#
|
6
6
|
|
@@ -40,7 +40,6 @@ module DevDNSd
|
|
40
40
|
# @param file [String] The file to read.
|
41
41
|
# @param overrides [Hash] A set of values which override those set in the configuration file.
|
42
42
|
# @param logger [Logger] The logger to use for notifications.
|
43
|
-
# @see parse
|
44
43
|
def initialize(file = nil, overrides = {}, logger = nil)
|
45
44
|
super(file, overrides, logger)
|
46
45
|
|
@@ -65,4 +64,4 @@ module DevDNSd
|
|
65
64
|
@rules << DevDNSd::Rule.create(*args, &block)
|
66
65
|
end
|
67
66
|
end
|
68
|
-
end
|
67
|
+
end
|
data/lib/devdnsd/errors.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
# This file is part of the
|
3
|
+
# This file is part of the devdnsd gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
4
|
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
5
|
#
|
6
6
|
|
data/lib/devdnsd/rule.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
# This file is part of the
|
3
|
+
# This file is part of the devdnsd gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
4
|
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
5
|
#
|
6
6
|
|
data/lib/devdnsd/version.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
# This file is part of the
|
3
|
+
# This file is part of the devdnsd gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
4
|
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
5
|
#
|
6
6
|
|
@@ -13,10 +13,10 @@ module DevDNSd
|
|
13
13
|
MAJOR = 1
|
14
14
|
|
15
15
|
# The minor version.
|
16
|
-
MINOR =
|
16
|
+
MINOR = 5
|
17
17
|
|
18
18
|
# The patch version.
|
19
|
-
PATCH =
|
19
|
+
PATCH = 0
|
20
20
|
|
21
21
|
# The current version number of DevDNSd.
|
22
22
|
STRING = [MAJOR, MINOR, PATCH].compact.join(".")
|
data/spec/coverage_helper.rb
CHANGED
@@ -1,13 +1,14 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
# This file is part of the
|
3
|
+
# This file is part of the devdnsd gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
4
|
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
5
|
#
|
6
6
|
|
7
|
-
require "simplecov"
|
8
7
|
require "pathname"
|
9
8
|
|
10
|
-
if ENV["DEVDNSD_COVERAGE"] == "TRUE" then
|
9
|
+
if ENV["DEVDNSD_COVERAGE"] == "TRUE" && RUBY_VERSION >= "1.9" then
|
10
|
+
require "simplecov"
|
11
|
+
|
11
12
|
root = Pathname.new(File.dirname(__FILE__)) + ".."
|
12
13
|
|
13
14
|
SimpleCov.start do
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
#
|
3
|
-
# This file is part of the
|
3
|
+
# This file is part of the devdnsd gem. Copyright (C) 2012 and above Shogun <shogun_panda@me.com>.
|
4
4
|
# Licensed under the MIT license, which can be found at http://www.opensource.org/licenses/mit-license.php.
|
5
5
|
#
|
6
6
|
|
@@ -9,10 +9,23 @@ require "spec_helper"
|
|
9
9
|
describe DevDNSd::Application do
|
10
10
|
before(:each) do
|
11
11
|
Bovem::Logger.stub(:default_file).and_return("/dev/null")
|
12
|
+
DevDNSd::Application.stub(:instance).and_return(application)
|
13
|
+
end
|
14
|
+
|
15
|
+
def create_application(overrides = {})
|
16
|
+
mamertes_app = Mamertes::App(:run => false) do
|
17
|
+
option "configuration", [], {:default => overrides["configuration"] || "~/.akaer_config"}
|
18
|
+
option "tld", [], {:default => overrides["tld"] || "dev"}
|
19
|
+
option "port", [], {:type => Integer, :default => overrides["port"] || 7771}
|
20
|
+
option "log-file", [], {:default => overrides["log-file"] || "STDOUT"}
|
21
|
+
option "log-level", [:L], {:type => Integer, :default => overrides["log-level"] || 1}
|
22
|
+
end
|
23
|
+
|
24
|
+
DevDNSd::Application.new(mamertes_app)
|
12
25
|
end
|
13
26
|
|
14
27
|
let(:log_file) { "/tmp/devdnsd-test-log-#{Time.now.strftime("%Y%m%d-%H%M%S")}" }
|
15
|
-
let(:application){
|
28
|
+
let(:application){ create_application({"log-file" => log_file}) }
|
16
29
|
let(:executable) { ::Pathname.new(::File.dirname((__FILE__))) + "../../bin/devdnsd" }
|
17
30
|
let(:sample_config) { ::Pathname.new(::File.dirname((__FILE__))) + "../../config/devdnsd_config.sample" }
|
18
31
|
let(:resolver_path) { "/tmp/devdnsd-test-resolver-#{Time.now.strftime("%Y%m%d-%H%M%S")}" }
|
@@ -33,7 +46,7 @@ describe DevDNSd::Application do
|
|
33
46
|
file.write("config.port = ")
|
34
47
|
file.close
|
35
48
|
|
36
|
-
expect {
|
49
|
+
expect { create_application({"configuration" => file.path, "log-file" => log_file}) }.to raise_error(::SystemExit)
|
37
50
|
::File.unlink(path)
|
38
51
|
end
|
39
52
|
end
|
@@ -52,8 +65,40 @@ describe DevDNSd::Application do
|
|
52
65
|
end
|
53
66
|
end
|
54
67
|
|
68
|
+
describe ".instance" do
|
69
|
+
before(:each) do
|
70
|
+
DevDNSd::Application.unstub(:instance)
|
71
|
+
end
|
72
|
+
|
73
|
+
let(:mamertes) {
|
74
|
+
mamertes_app = Mamertes::App(:run => false) do
|
75
|
+
option "configuration", [], {:default => "~/.akaer_config"}
|
76
|
+
option "tld", [], {:default => "dev"}
|
77
|
+
option "port", [], {:type => Integer, :default => 7771}
|
78
|
+
option "log-file", [], {:default => "STDOUT"}
|
79
|
+
option "log-level", [:L], {:type => Integer, :default => 1}
|
80
|
+
end
|
81
|
+
}
|
82
|
+
|
83
|
+
it "should create a new instance" do
|
84
|
+
expect(DevDNSd::Application.instance(mamertes)).to be_a(DevDNSd::Application)
|
85
|
+
end
|
86
|
+
|
87
|
+
it "should always return the same instance" do
|
88
|
+
other = DevDNSd::Application.instance(mamertes)
|
89
|
+
DevDNSd::Application.should_not_receive(:new)
|
90
|
+
expect(DevDNSd::Application.instance(mamertes)).to eq(other)
|
91
|
+
expect(DevDNSd::Application.instance).to eq(other)
|
92
|
+
end
|
93
|
+
|
94
|
+
it "should recreate an instance" do
|
95
|
+
other = DevDNSd::Application.instance(mamertes)
|
96
|
+
expect(DevDNSd::Application.instance(mamertes, true)).not_to eq(other)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
55
100
|
describe "#perform_server" do
|
56
|
-
let(:application){
|
101
|
+
let(:application){ create_application({"log-file" => log_file, "configuration" => sample_config}) }
|
57
102
|
|
58
103
|
before(:each) do
|
59
104
|
class DevDNSd::Application
|
@@ -168,7 +213,7 @@ describe DevDNSd::Application do
|
|
168
213
|
end
|
169
214
|
end
|
170
215
|
|
171
|
-
let(:application){
|
216
|
+
let(:application){ create_application({"log-file" => log_file, "configuration" => sample_config}) }
|
172
217
|
let(:transaction){ FakeTransaction.new }
|
173
218
|
|
174
219
|
it "should match a valid string request" do
|
@@ -256,13 +301,14 @@ describe DevDNSd::Application do
|
|
256
301
|
|
257
302
|
describe "#action_start" do
|
258
303
|
it "should call perform_server in foreground" do
|
259
|
-
application =
|
304
|
+
application = create_application({"log-file" => log_file})
|
305
|
+
application.config.foreground = true
|
260
306
|
application.should_receive(:perform_server)
|
261
307
|
application.action_start
|
262
308
|
end
|
263
309
|
|
264
310
|
it "should start the daemon" do
|
265
|
-
application =
|
311
|
+
application = create_application({"log-file" => log_file})
|
266
312
|
::RExec::Daemon::Controller.should_receive(:start)
|
267
313
|
application.action_start
|
268
314
|
end
|
@@ -317,26 +363,26 @@ describe DevDNSd::Application do
|
|
317
363
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
318
364
|
end
|
319
365
|
|
320
|
-
it "should not create
|
366
|
+
it "should not create an invalid resolver" do
|
321
367
|
application.stub(:resolver_path).and_return("/invalid/resolver")
|
322
368
|
application.stub(:launch_agent_path).and_return("/invalid/agent")
|
323
369
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
324
370
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
325
371
|
|
326
|
-
application.
|
372
|
+
application.logger.should_receive(:error).with("Cannot create the resolver file.")
|
327
373
|
application.action_install
|
328
374
|
|
329
375
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
330
376
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
331
377
|
end
|
332
378
|
|
333
|
-
it "should not create
|
379
|
+
it "should not create an invalid agent" do
|
334
380
|
application.stub(:resolver_path).and_return(resolver_path)
|
335
381
|
application.stub(:launch_agent_path).and_return("/invalid/agent")
|
336
382
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
337
383
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
338
384
|
|
339
|
-
application.
|
385
|
+
application.logger.should_receive(:error).with("Cannot create the launch agent.")
|
340
386
|
application.action_install
|
341
387
|
|
342
388
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -344,10 +390,8 @@ describe DevDNSd::Application do
|
|
344
390
|
end
|
345
391
|
|
346
392
|
it "should not load an invalid agent" do
|
347
|
-
|
348
|
-
|
349
|
-
command =~ /^launchctl/ ? raise(StandardError) : system(command)
|
350
|
-
end
|
393
|
+
application.stub(:execute_command) do |command|
|
394
|
+
command =~ /^launchctl/ ? raise(StandardError) : system(command)
|
351
395
|
end
|
352
396
|
|
353
397
|
application.stub(:resolver_path).and_return(resolver_path)
|
@@ -355,7 +399,7 @@ describe DevDNSd::Application do
|
|
355
399
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
356
400
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
357
401
|
|
358
|
-
application.
|
402
|
+
application.logger.should_receive(:error).with("Cannot load the launch agent.")
|
359
403
|
application.action_install
|
360
404
|
|
361
405
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -365,7 +409,7 @@ describe DevDNSd::Application do
|
|
365
409
|
|
366
410
|
it "should raise an exception if not running on OSX" do
|
367
411
|
application.stub(:is_osx?).and_return(false)
|
368
|
-
application.
|
412
|
+
application.logger.should_receive(:fatal).with("Install DevDNSd as a local resolver is only available on MacOSX.")
|
369
413
|
expect(application.action_install).to be_false
|
370
414
|
end
|
371
415
|
end
|
@@ -401,12 +445,12 @@ describe DevDNSd::Application do
|
|
401
445
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
402
446
|
end
|
403
447
|
|
404
|
-
it "should not
|
448
|
+
it "should not delete an invalid resolver" do
|
405
449
|
application.stub(:resolver_path).and_return("/invalid/resolver")
|
406
450
|
application.stub(:launch_agent_path).and_return("/invalid/agent")
|
407
451
|
|
408
452
|
application.action_install
|
409
|
-
application.
|
453
|
+
application.logger.should_receive(:warn).at_least(1)
|
410
454
|
application.action_uninstall
|
411
455
|
|
412
456
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -418,20 +462,20 @@ describe DevDNSd::Application do
|
|
418
462
|
application.stub(:launch_agent_path).and_return("/invalid/agent")
|
419
463
|
|
420
464
|
application.action_install
|
421
|
-
application.
|
465
|
+
application.logger.should_receive(:warn).at_least(1)
|
422
466
|
application.action_uninstall
|
423
467
|
|
424
468
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
425
469
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
426
470
|
end
|
427
471
|
|
428
|
-
it "should not
|
472
|
+
it "should not unload delete invalid agent" do
|
429
473
|
application.stub(:resolver_path).and_return(resolver_path)
|
430
474
|
application.stub(:launch_agent_path).and_return("/invalid/agent")
|
431
475
|
|
432
476
|
application.action_install
|
433
477
|
application.stub(:execute_command).and_raise(StandardError)
|
434
|
-
application.
|
478
|
+
application.logger.should_receive(:warn).at_least(1)
|
435
479
|
application.action_uninstall
|
436
480
|
|
437
481
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -455,7 +499,7 @@ describe DevDNSd::Application do
|
|
455
499
|
|
456
500
|
it "should raise an exception if not running on OSX" do
|
457
501
|
application.stub(:is_osx?).and_return(false)
|
458
|
-
application.
|
502
|
+
application.logger.should_receive(:fatal).with("Install DevDNSd as a local resolver is only available on MacOSX.")
|
459
503
|
expect(application.action_uninstall).to be_false
|
460
504
|
end
|
461
505
|
end
|