devdnsd 2.3.0 → 2.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.travis-gemfile +1 -1
- data/Rakefile +18 -0
- data/devdnsd.gemspec +1 -1
- data/doc/DevDNSd.html +1 -1
- data/doc/DevDNSd/Application.html +1 -1
- data/doc/DevDNSd/ApplicationMethods.html +1 -1
- data/doc/DevDNSd/ApplicationMethods/Server.html +1 -1
- data/doc/DevDNSd/ApplicationMethods/System.html +1 -1
- data/doc/DevDNSd/ApplicationMethods/System/ClassMethods.html +1 -1
- data/doc/DevDNSd/Configuration.html +1 -1
- data/doc/DevDNSd/Errors.html +1 -1
- data/doc/DevDNSd/Errors/InvalidRule.html +1 -1
- data/doc/DevDNSd/Rule.html +1 -1
- data/doc/DevDNSd/Version.html +2 -2
- data/doc/_index.html +1 -1
- data/doc/file.README.html +1 -1
- data/doc/index.html +1 -1
- data/doc/top-level-namespace.html +1 -1
- data/lib/devdnsd/version.rb +1 -1
- data/spec/devdnsd/application_spec.rb +73 -73
- data/spec/devdnsd/rule_spec.rb +21 -21
- metadata +5 -5
data/.travis-gemfile
CHANGED
data/Rakefile
CHANGED
@@ -9,3 +9,21 @@ require "rspec/core/rake_task"
|
|
9
9
|
|
10
10
|
RSpec::Core::RakeTask.new("spec")
|
11
11
|
RSpec::Core::RakeTask.new("spec:coverage") { |t| t.ruby_opts = "-r./spec/coverage_helper" }
|
12
|
+
|
13
|
+
desc "Generate the documentation"
|
14
|
+
task :docs do
|
15
|
+
system("yardoc") || raise("Failed Execution of: yardoc")
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "Get the current release version"
|
19
|
+
task :version, :with_name do |_, args|
|
20
|
+
gem = Bundler::GemHelper.instance.gemspec
|
21
|
+
puts [args[:with_name] == "true" ? gem.name : nil, gem.version].compact.join("-")
|
22
|
+
end
|
23
|
+
|
24
|
+
desc "Prepare the release"
|
25
|
+
task :prerelease => ["spec:coverage", "docs"] do
|
26
|
+
["git add -A", "git commit -am \"Version #{Bundler::GemHelper.instance.gemspec.version}\""].each do |cmd|
|
27
|
+
system(cmd) || raise("Failed Execution of: #{cmd}")
|
28
|
+
end
|
29
|
+
end
|
data/devdnsd.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |gem|
|
|
23
23
|
|
24
24
|
gem.required_ruby_version = ">= 1.9.3"
|
25
25
|
|
26
|
-
gem.add_dependency("mamertes", "~> 2.2.
|
26
|
+
gem.add_dependency("mamertes", "~> 2.2.1")
|
27
27
|
gem.add_dependency("rubydns", "~> 0.6.3")
|
28
28
|
gem.add_dependency("rexec", "~> 1.5.1")
|
29
29
|
end
|
data/doc/DevDNSd.html
CHANGED
@@ -121,7 +121,7 @@ Licensed under the MIT license, which can be found at http://www.opensource.org/
|
|
121
121
|
</div>
|
122
122
|
|
123
123
|
<div id="footer">
|
124
|
-
Generated on
|
124
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
125
125
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
126
126
|
0.8.6.2 (ruby-1.9.3).
|
127
127
|
</div>
|
@@ -2093,7 +2093,7 @@
|
|
2093
2093
|
</div>
|
2094
2094
|
|
2095
2095
|
<div id="footer">
|
2096
|
-
Generated on
|
2096
|
+
Generated on Sat Jul 20 12:04:59 2013 by
|
2097
2097
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2098
2098
|
0.8.6.2 (ruby-1.9.3).
|
2099
2099
|
</div>
|
@@ -116,7 +116,7 @@
|
|
116
116
|
</div>
|
117
117
|
|
118
118
|
<div id="footer">
|
119
|
-
Generated on
|
119
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
121
121
|
0.8.6.2 (ruby-1.9.3).
|
122
122
|
</div>
|
@@ -508,7 +508,7 @@
|
|
508
508
|
</div>
|
509
509
|
|
510
510
|
<div id="footer">
|
511
|
-
Generated on
|
511
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
512
512
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
513
513
|
0.8.6.2 (ruby-1.9.3).
|
514
514
|
</div>
|
@@ -947,7 +947,7 @@
|
|
947
947
|
</div>
|
948
948
|
|
949
949
|
<div id="footer">
|
950
|
-
Generated on
|
950
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
951
951
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
952
952
|
0.8.6.2 (ruby-1.9.3).
|
953
953
|
</div>
|
@@ -363,7 +363,7 @@
|
|
363
363
|
</div>
|
364
364
|
|
365
365
|
<div id="footer">
|
366
|
-
Generated on
|
366
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
367
367
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
368
368
|
0.8.6.2 (ruby-1.9.3).
|
369
369
|
</div>
|
@@ -411,7 +411,7 @@ config.add_rule("match.dev", "10.0.0.1")
|
|
411
411
|
</div>
|
412
412
|
|
413
413
|
<div id="footer">
|
414
|
-
Generated on
|
414
|
+
Generated on Sat Jul 20 12:04:59 2013 by
|
415
415
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
416
416
|
0.8.6.2 (ruby-1.9.3).
|
417
417
|
</div>
|
data/doc/DevDNSd/Errors.html
CHANGED
@@ -116,7 +116,7 @@
|
|
116
116
|
</div>
|
117
117
|
|
118
118
|
<div id="footer">
|
119
|
-
Generated on
|
119
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
120
120
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
121
121
|
0.8.6.2 (ruby-1.9.3).
|
122
122
|
</div>
|
@@ -124,7 +124,7 @@
|
|
124
124
|
</div>
|
125
125
|
|
126
126
|
<div id="footer">
|
127
|
-
Generated on
|
127
|
+
Generated on Sat Jul 20 12:04:59 2013 by
|
128
128
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
129
129
|
0.8.6.2 (ruby-1.9.3).
|
130
130
|
</div>
|
data/doc/DevDNSd/Rule.html
CHANGED
@@ -2927,7 +2927,7 @@
|
|
2927
2927
|
</div>
|
2928
2928
|
|
2929
2929
|
<div id="footer">
|
2930
|
-
Generated on
|
2930
|
+
Generated on Sat Jul 20 12:04:59 2013 by
|
2931
2931
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
2932
2932
|
0.8.6.2 (ruby-1.9.3).
|
2933
2933
|
</div>
|
data/doc/DevDNSd/Version.html
CHANGED
@@ -149,7 +149,7 @@
|
|
149
149
|
|
150
150
|
</div>
|
151
151
|
</dt>
|
152
|
-
<dd><pre class="code"><span class='int'>
|
152
|
+
<dd><pre class="code"><span class='int'>1</span></pre></dd>
|
153
153
|
|
154
154
|
<dt id="STRING-constant" class="">STRING =
|
155
155
|
<div class="docstring">
|
@@ -180,7 +180,7 @@
|
|
180
180
|
</div>
|
181
181
|
|
182
182
|
<div id="footer">
|
183
|
-
Generated on
|
183
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
184
184
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
185
185
|
0.8.6.2 (ruby-1.9.3).
|
186
186
|
</div>
|
data/doc/_index.html
CHANGED
@@ -230,7 +230,7 @@
|
|
230
230
|
</div>
|
231
231
|
|
232
232
|
<div id="footer">
|
233
|
-
Generated on
|
233
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
234
234
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
235
235
|
0.8.6.2 (ruby-1.9.3).
|
236
236
|
</div>
|
data/doc/file.README.html
CHANGED
@@ -163,7 +163,7 @@ This argument is ignored if you pass the block, as it assumes that the second ar
|
|
163
163
|
</div></div>
|
164
164
|
|
165
165
|
<div id="footer">
|
166
|
-
Generated on
|
166
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
167
167
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
168
168
|
0.8.6.2 (ruby-1.9.3).
|
169
169
|
</div>
|
data/doc/index.html
CHANGED
@@ -163,7 +163,7 @@ This argument is ignored if you pass the block, as it assumes that the second ar
|
|
163
163
|
</div></div>
|
164
164
|
|
165
165
|
<div id="footer">
|
166
|
-
Generated on
|
166
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
167
167
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
168
168
|
0.8.6.2 (ruby-1.9.3).
|
169
169
|
</div>
|
@@ -103,7 +103,7 @@
|
|
103
103
|
</div>
|
104
104
|
|
105
105
|
<div id="footer">
|
106
|
-
Generated on
|
106
|
+
Generated on Sat Jul 20 12:04:58 2013 by
|
107
107
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
108
108
|
0.8.6.2 (ruby-1.9.3).
|
109
109
|
</div>
|
data/lib/devdnsd/version.rb
CHANGED
@@ -8,8 +8,8 @@ require "spec_helper"
|
|
8
8
|
|
9
9
|
describe DevDNSd::Application do
|
10
10
|
before(:each) do
|
11
|
-
Bovem::Logger.
|
12
|
-
DevDNSd::Application.
|
11
|
+
allow(Bovem::Logger).to receive(:default_file).and_return("/dev/null")
|
12
|
+
allow(DevDNSd::Application).to receive(:instance).and_return(application)
|
13
13
|
end
|
14
14
|
|
15
15
|
def create_application(overrides = {})
|
@@ -33,15 +33,15 @@ describe DevDNSd::Application do
|
|
33
33
|
let(:launch_agent_path) { "/tmp/devdnsd-test-agent-#{Time.now.strftime("%Y%m%d-%H%M%S")}" }
|
34
34
|
|
35
35
|
describe "#initialize" do
|
36
|
-
it
|
36
|
+
it "should setup the logger" do
|
37
37
|
expect(application.logger).not_to be_nil
|
38
38
|
end
|
39
39
|
|
40
|
-
it
|
40
|
+
it "should setup the configuration" do
|
41
41
|
expect(application.config).not_to be_nil
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it "should abort with an invalid configuration" do
|
45
45
|
path = "/tmp/devdnsd-test-#{Time.now.strftime("%Y%m%d-%H:%M:%S")}"
|
46
46
|
file = ::File.new(path, "w")
|
47
47
|
file.write("config.port = ")
|
@@ -54,14 +54,14 @@ describe DevDNSd::Application do
|
|
54
54
|
|
55
55
|
describe ".run" do
|
56
56
|
it "should run the server" do
|
57
|
-
application.
|
57
|
+
expect(application).to receive(:perform_server)
|
58
58
|
DevDNSd::Application.run
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
62
62
|
describe ".quit" do
|
63
63
|
it "should quit the application" do
|
64
|
-
::EventMachine.
|
64
|
+
expect(::EventMachine).to receive(:stop)
|
65
65
|
DevDNSd::Application.quit
|
66
66
|
end
|
67
67
|
end
|
@@ -69,22 +69,22 @@ describe DevDNSd::Application do
|
|
69
69
|
describe ".check_ruby_implementation" do
|
70
70
|
it "won't run on Rubinius" do
|
71
71
|
stub_const("Rubinius", true)
|
72
|
-
Kernel.
|
73
|
-
Kernel.
|
72
|
+
expect(Kernel).to receive(:exit).with(0)
|
73
|
+
expect(Kernel).to receive(:puts)
|
74
74
|
DevDNSd::Application.check_ruby_implementation
|
75
75
|
end
|
76
76
|
|
77
77
|
it "won't run on JRuby" do
|
78
78
|
stub_const("JRuby", true)
|
79
|
-
Kernel.
|
80
|
-
Kernel.
|
79
|
+
expect(Kernel).to receive(:exit).with(0)
|
80
|
+
expect(Kernel).to receive(:puts)
|
81
81
|
DevDNSd::Application.check_ruby_implementation
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
describe ".instance" do
|
86
86
|
before(:each) do
|
87
|
-
DevDNSd::Application.
|
87
|
+
allow(DevDNSd::Application).to receive(:instance).and_call_original
|
88
88
|
end
|
89
89
|
|
90
90
|
let(:mamertes) {
|
@@ -104,14 +104,14 @@ describe DevDNSd::Application do
|
|
104
104
|
|
105
105
|
it "should always return the same instance" do
|
106
106
|
other = DevDNSd::Application.instance(mamertes)
|
107
|
-
DevDNSd::Application.
|
107
|
+
expect(DevDNSd::Application).not_to receive(:new)
|
108
108
|
expect(DevDNSd::Application.instance(mamertes)).to eq(other)
|
109
109
|
expect(DevDNSd::Application.instance).to eq(other)
|
110
110
|
end
|
111
111
|
|
112
112
|
it "should recreate an instance" do
|
113
113
|
other = DevDNSd::Application.instance(mamertes)
|
114
|
-
expect(DevDNSd::Application.instance(mamertes, :en, true)).not_to
|
114
|
+
expect(DevDNSd::Application.instance(mamertes, :en, true)).not_to be(other)
|
115
115
|
end
|
116
116
|
end
|
117
117
|
|
@@ -158,7 +158,7 @@ describe DevDNSd::Application do
|
|
158
158
|
let(:application){ create_application({"log_file" => log_file, "configuration" => sample_config}) }
|
159
159
|
|
160
160
|
def test_resolve(host = "match_1.dev", type = "ANY", nameserver = "127.0.0.1", port = 7771, logger = nil)
|
161
|
-
application.
|
161
|
+
allow(application).to receive(:on_start) do Thread.main[:resolver].run if Thread.main[:resolver].try(:alive?) end
|
162
162
|
|
163
163
|
Thread.current[:resolver] = Thread.start {
|
164
164
|
Thread.stop
|
@@ -181,13 +181,13 @@ describe DevDNSd::Application do
|
|
181
181
|
end
|
182
182
|
|
183
183
|
it "should run the server" do
|
184
|
-
RubyDNS.
|
184
|
+
expect(RubyDNS).to receive(:run_server)
|
185
185
|
application.perform_server
|
186
186
|
end
|
187
187
|
|
188
188
|
it "should setup callbacks" do
|
189
|
-
RubyDNS::Server.
|
190
|
-
RubyDNS::Server.
|
189
|
+
expect_any_instance_of(RubyDNS::Server).to receive(:on).with(:start)
|
190
|
+
expect_any_instance_of(RubyDNS::Server).to receive(:on).with(:stop)
|
191
191
|
|
192
192
|
Thread.new {
|
193
193
|
sleep(0.1)
|
@@ -199,21 +199,21 @@ describe DevDNSd::Application do
|
|
199
199
|
|
200
200
|
it "should iterate the rules" do
|
201
201
|
test_resolve do
|
202
|
-
application.config.rules.
|
202
|
+
expect(application.config.rules).to receive(:each).at_least(1)
|
203
203
|
application.perform_server
|
204
204
|
end
|
205
205
|
end
|
206
206
|
|
207
207
|
it "should call process_rule" do
|
208
208
|
test_resolve do
|
209
|
-
application.
|
209
|
+
expect(application).to receive(:process_rule).at_least(1)
|
210
210
|
application.perform_server
|
211
211
|
end
|
212
212
|
end
|
213
213
|
|
214
214
|
it "should complain about wrong rules" do
|
215
215
|
test_resolve do
|
216
|
-
application.
|
216
|
+
allow(application).to receive(:process_rule).and_raise(::Exception)
|
217
217
|
expect { application.perform_server }.to raise_exception
|
218
218
|
end
|
219
219
|
end
|
@@ -323,7 +323,7 @@ describe DevDNSd::Application do
|
|
323
323
|
|
324
324
|
describe "#dns_update" do
|
325
325
|
it "should update the DNS cache" do
|
326
|
-
application.
|
326
|
+
allow(application).to receive(:execute_command).and_return("EXECUTED")
|
327
327
|
expect(application.dns_update).to eq("EXECUTED")
|
328
328
|
end
|
329
329
|
end
|
@@ -361,22 +361,22 @@ describe DevDNSd::Application do
|
|
361
361
|
it "should call perform_server in foreground" do
|
362
362
|
application = create_application({"log_file" => log_file})
|
363
363
|
application.config.foreground = true
|
364
|
-
application.
|
364
|
+
expect(application).to receive(:perform_server)
|
365
365
|
application.action_start
|
366
366
|
end
|
367
367
|
|
368
368
|
it "should start the daemon" do
|
369
369
|
application = create_application({"log_file" => log_file})
|
370
|
-
::RExec::Daemon::Controller.
|
370
|
+
expect(::RExec::Daemon::Controller).to receive(:start)
|
371
371
|
application.action_start
|
372
372
|
end
|
373
373
|
|
374
374
|
it "should check for availability of fork" do
|
375
375
|
application.config.foreground = false
|
376
376
|
|
377
|
-
Process.
|
378
|
-
application.
|
379
|
-
application.logger.
|
377
|
+
allow(Process).to receive(:respond_to?).and_return(false)
|
378
|
+
expect(application).to receive(:perform_server)
|
379
|
+
expect(application.logger).to receive(:warn)
|
380
380
|
|
381
381
|
application.action_start
|
382
382
|
expect(application.config.foreground).to be_true
|
@@ -385,20 +385,20 @@ describe DevDNSd::Application do
|
|
385
385
|
|
386
386
|
describe "#action_stop" do
|
387
387
|
it "should stop the daemon" do
|
388
|
-
::RExec::Daemon::Controller.
|
388
|
+
expect(::RExec::Daemon::Controller).to receive(:stop)
|
389
389
|
application.action_stop
|
390
390
|
end
|
391
391
|
end
|
392
392
|
|
393
393
|
describe "#action_install" do
|
394
394
|
before(:each) do
|
395
|
-
application.
|
396
|
-
application.
|
395
|
+
allow(application).to receive(:is_osx?).and_return(true)
|
396
|
+
allow(application).to receive(:execute_command)
|
397
397
|
end
|
398
398
|
|
399
399
|
it "should create the resolver" do
|
400
|
-
application.
|
401
|
-
application.
|
400
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
401
|
+
allow(application).to receive(:launch_agent_path).and_return(launch_agent_path)
|
402
402
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
403
403
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
404
404
|
|
@@ -410,12 +410,12 @@ describe DevDNSd::Application do
|
|
410
410
|
end
|
411
411
|
|
412
412
|
it "should create the agent" do
|
413
|
-
application.
|
414
|
-
application.
|
413
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
414
|
+
allow(application).to receive(:launch_agent_path).and_return(launch_agent_path)
|
415
415
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
416
416
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
417
417
|
|
418
|
-
application.
|
418
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
419
419
|
application.action_install
|
420
420
|
expect(::File.exists?(application.launch_agent_path)).to be_true
|
421
421
|
|
@@ -424,12 +424,12 @@ describe DevDNSd::Application do
|
|
424
424
|
end
|
425
425
|
|
426
426
|
it "should update the DNS cache" do
|
427
|
-
application.
|
428
|
-
application.
|
427
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
428
|
+
allow(application).to receive(:launch_agent_path).and_return(launch_agent_path)
|
429
429
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
430
430
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
431
431
|
|
432
|
-
application.
|
432
|
+
expect(application).to receive(:dns_update)
|
433
433
|
application.action_install
|
434
434
|
|
435
435
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -437,12 +437,12 @@ describe DevDNSd::Application do
|
|
437
437
|
end
|
438
438
|
|
439
439
|
it "should not create an invalid resolver" do
|
440
|
-
application.
|
441
|
-
application.
|
440
|
+
allow(application).to receive(:resolver_path).and_return("/invalid/resolver")
|
441
|
+
allow(application).to receive(:launch_agent_path).and_return("/invalid/agent")
|
442
442
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
443
443
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
444
444
|
|
445
|
-
application.logger.
|
445
|
+
expect(application.logger).to receive(:error).with("Cannot create the resolver file.")
|
446
446
|
application.action_install
|
447
447
|
|
448
448
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -450,12 +450,12 @@ describe DevDNSd::Application do
|
|
450
450
|
end
|
451
451
|
|
452
452
|
it "should not create an invalid agent" do
|
453
|
-
application.
|
454
|
-
application.
|
453
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
454
|
+
allow(application).to receive(:launch_agent_path).and_return("/invalid/agent")
|
455
455
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
456
456
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
457
457
|
|
458
|
-
application.logger.
|
458
|
+
expect(application.logger).to receive(:error).with("Cannot create the launch agent.")
|
459
459
|
application.action_install
|
460
460
|
|
461
461
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -463,16 +463,16 @@ describe DevDNSd::Application do
|
|
463
463
|
end
|
464
464
|
|
465
465
|
it "should not load an invalid agent" do
|
466
|
-
application.
|
466
|
+
allow(application).to receive(:execute_command) do |command|
|
467
467
|
command =~ /^launchctl/ ? raise(StandardError) : true
|
468
468
|
end
|
469
469
|
|
470
|
-
application.
|
471
|
-
application.
|
470
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
471
|
+
allow(application).to receive(:launch_agent_path).and_return(launch_agent_path)
|
472
472
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
473
473
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
474
474
|
|
475
|
-
application.logger.
|
475
|
+
expect(application.logger).to receive(:error).with("Cannot load the launch agent.")
|
476
476
|
application.action_install
|
477
477
|
|
478
478
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -480,21 +480,21 @@ describe DevDNSd::Application do
|
|
480
480
|
end
|
481
481
|
|
482
482
|
it "should raise an exception if not running on OSX" do
|
483
|
-
application.
|
484
|
-
application.logger.
|
483
|
+
allow(application).to receive(:is_osx?).and_return(false)
|
484
|
+
expect(application.logger).to receive(:fatal).with("Install DevDNSd as a local resolver is only available on MacOSX.")
|
485
485
|
expect(application.action_install).to be_false
|
486
486
|
end
|
487
487
|
end
|
488
488
|
|
489
489
|
describe "#action_uninstall" do
|
490
490
|
before(:each) do
|
491
|
-
application.
|
492
|
-
application.
|
491
|
+
allow(application).to receive(:is_osx?).and_return(true)
|
492
|
+
allow(application).to receive(:execute_command)
|
493
493
|
end
|
494
494
|
|
495
495
|
it "should remove the resolver" do
|
496
|
-
application.
|
497
|
-
application.
|
496
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
497
|
+
allow(application).to receive(:launch_agent_path).and_return(launch_agent_path)
|
498
498
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
499
499
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
500
500
|
|
@@ -507,12 +507,12 @@ describe DevDNSd::Application do
|
|
507
507
|
end
|
508
508
|
|
509
509
|
it "should remove the agent" do
|
510
|
-
application.
|
511
|
-
application.
|
510
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
511
|
+
allow(application).to receive(:launch_agent_path).and_return(launch_agent_path)
|
512
512
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
513
513
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
514
514
|
|
515
|
-
Bovem::Logger.
|
515
|
+
allow(Bovem::Logger).to receive(:default_file).and_return($stdout)
|
516
516
|
application.action_install
|
517
517
|
application.action_uninstall
|
518
518
|
expect(::File.exists?(application.launch_agent_path)).to be_false
|
@@ -522,11 +522,11 @@ describe DevDNSd::Application do
|
|
522
522
|
end
|
523
523
|
|
524
524
|
it "should not delete an invalid resolver" do
|
525
|
-
application.
|
526
|
-
application.
|
525
|
+
allow(application).to receive(:resolver_path).and_return("/invalid/resolver")
|
526
|
+
allow(application).to receive(:launch_agent_path).and_return("/invalid/agent")
|
527
527
|
|
528
528
|
application.action_install
|
529
|
-
application.logger.
|
529
|
+
expect(application.logger).to receive(:warn).at_least(1)
|
530
530
|
application.action_uninstall
|
531
531
|
|
532
532
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -534,11 +534,11 @@ describe DevDNSd::Application do
|
|
534
534
|
end
|
535
535
|
|
536
536
|
it "should not delete an invalid agent" do
|
537
|
-
application.
|
538
|
-
application.
|
537
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
538
|
+
allow(application).to receive(:launch_agent_path).and_return("/invalid/agent")
|
539
539
|
|
540
540
|
application.action_install
|
541
|
-
application.logger.
|
541
|
+
expect(application.logger).to receive(:warn).at_least(1)
|
542
542
|
application.action_uninstall
|
543
543
|
|
544
544
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -546,13 +546,13 @@ describe DevDNSd::Application do
|
|
546
546
|
end
|
547
547
|
|
548
548
|
it "should not unload invalid agent" do
|
549
|
-
application.
|
550
|
-
application.
|
549
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
550
|
+
allow(application).to receive(:launch_agent_path).and_return("/invalid/agent")
|
551
551
|
|
552
552
|
application.action_install
|
553
|
-
application.
|
554
|
-
application.
|
555
|
-
application.logger.
|
553
|
+
allow(application).to receive(:execute_command).and_raise(StandardError)
|
554
|
+
allow(application).to receive(:dns_update)
|
555
|
+
expect(application.logger).to receive(:warn).at_least(1)
|
556
556
|
application.action_uninstall
|
557
557
|
|
558
558
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -560,13 +560,13 @@ describe DevDNSd::Application do
|
|
560
560
|
end
|
561
561
|
|
562
562
|
it "should update the DNS cache" do
|
563
|
-
application.
|
564
|
-
application.
|
563
|
+
allow(application).to receive(:resolver_path).and_return(resolver_path)
|
564
|
+
allow(application).to receive(:launch_agent_path).and_return(launch_agent_path)
|
565
565
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
566
566
|
::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
|
567
567
|
|
568
568
|
application.action_install
|
569
|
-
application.
|
569
|
+
expect(application).to receive(:dns_update)
|
570
570
|
application.action_uninstall
|
571
571
|
|
572
572
|
::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
|
@@ -574,8 +574,8 @@ describe DevDNSd::Application do
|
|
574
574
|
end
|
575
575
|
|
576
576
|
it "should raise an exception if not running on OSX" do
|
577
|
-
application.
|
578
|
-
application.logger.
|
577
|
+
allow(application).to receive(:is_osx?).and_return(false)
|
578
|
+
expect(application.logger).to receive(:fatal).with("Install DevDNSd as a local resolver is only available on MacOSX.")
|
579
579
|
expect(application.action_uninstall).to be_false
|
580
580
|
end
|
581
581
|
end
|
data/spec/devdnsd/rule_spec.rb
CHANGED
@@ -8,7 +8,7 @@ require "spec_helper"
|
|
8
8
|
|
9
9
|
describe DevDNSd::Rule do
|
10
10
|
describe "#new" do
|
11
|
-
it
|
11
|
+
it "should create a default rule" do
|
12
12
|
rule = DevDNSd::Rule.new
|
13
13
|
expect(rule.match).to eq(/.+/)
|
14
14
|
expect(rule.reply).to eq("127.0.0.1")
|
@@ -17,7 +17,7 @@ describe DevDNSd::Rule do
|
|
17
17
|
expect(rule.block).to be_nil
|
18
18
|
end
|
19
19
|
|
20
|
-
it
|
20
|
+
it "should create a rule with arguments and no block" do
|
21
21
|
rule = DevDNSd::Rule.new("MATCH", "REPLY", "TYPE", {a: :b})
|
22
22
|
expect(rule.match).to eq("MATCH")
|
23
23
|
expect(rule.reply).to eq("REPLY")
|
@@ -26,7 +26,7 @@ describe DevDNSd::Rule do
|
|
26
26
|
expect(rule.block).to be_nil
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it "should create a rule with arguments and a block" do
|
30
30
|
rule = DevDNSd::Rule.new("MATCH", "REPLY", "TYPE") do end
|
31
31
|
expect(rule.match).to eq("MATCH")
|
32
32
|
expect(rule.reply).to be_nil
|
@@ -37,54 +37,54 @@ describe DevDNSd::Rule do
|
|
37
37
|
end
|
38
38
|
|
39
39
|
describe "#is_regexp?" do
|
40
|
-
it
|
40
|
+
it "should return true for a regexp pattern" do
|
41
41
|
expect(DevDNSd::Rule.create(/.+/, "127.0.0.1").is_regexp?).to be_true
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it "should return false otherwise" do
|
45
45
|
expect(DevDNSd::Rule.create("RULE", "127.0.0.1").is_regexp?).to be_false
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
describe "#has_block?" do
|
50
|
-
it
|
50
|
+
it "should return true when a block is present" do
|
51
51
|
expect(DevDNSd::Rule.create("RULE"){}.has_block?).to be_true
|
52
52
|
end
|
53
53
|
|
54
|
-
it
|
54
|
+
it "should return false otherwise" do
|
55
55
|
expect(DevDNSd::Rule.create("RULE", "127.0.0.1").has_block?).to be_false
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
59
|
describe "#match_host" do
|
60
60
|
describe "with a string pattern" do
|
61
|
-
it
|
61
|
+
it "should return true when hostname matches" do
|
62
62
|
expect(DevDNSd::Rule.create("match.dev", "127.0.0.1").match_host("match.dev")).to be_true
|
63
63
|
end
|
64
64
|
|
65
|
-
it
|
65
|
+
it "should return false when hostname doesn't match" do
|
66
66
|
expect(DevDNSd::Rule.create("match.dev", "127.0.0.1").match_host("unmatch.dev")).to be_false
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
70
|
describe "with a regexp pattern" do
|
71
|
-
it
|
71
|
+
it "should return a MatchData when hostname matches" do
|
72
72
|
expect(DevDNSd::Rule.create(/^match/, "127.0.0.1").match_host("match.dev")).to be_a(MatchData)
|
73
73
|
end
|
74
74
|
|
75
|
-
it
|
75
|
+
it "should return nil when hostname doesn't match" do
|
76
76
|
expect(DevDNSd::Rule.create(/^match/, "127.0.0.1").match_host("unmatch.dev")).to be_nil
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
80
80
|
|
81
81
|
describe "::create" do
|
82
|
-
it
|
82
|
+
it "should not allow rules without sufficient arguments" do
|
83
83
|
expect{ DevDNSd::Rule.create("RULE") }.to raise_error(DevDNSd::Errors::InvalidRule)
|
84
84
|
expect{ DevDNSd::Rule.create("RULE", "REPLY", "TYPE", "ARG") }.to raise_error(DevDNSd::Errors::InvalidRule)
|
85
85
|
end
|
86
86
|
|
87
|
-
it
|
87
|
+
it "should create a rule with host and reply" do
|
88
88
|
rule = DevDNSd::Rule.create("MATCH", "REPLY")
|
89
89
|
expect(rule.match).to eq("MATCH")
|
90
90
|
expect(rule.reply).to eq("REPLY")
|
@@ -92,7 +92,7 @@ describe DevDNSd::Rule do
|
|
92
92
|
expect(rule.block).to be_nil
|
93
93
|
end
|
94
94
|
|
95
|
-
it
|
95
|
+
it "should create a rule with host, reply and type" do
|
96
96
|
rule = DevDNSd::Rule.create("MATCH", "REPLY", "TYPE", {a: :b})
|
97
97
|
expect(rule.match).to eq("MATCH")
|
98
98
|
expect(rule.reply).to eq("REPLY")
|
@@ -101,7 +101,7 @@ describe DevDNSd::Rule do
|
|
101
101
|
expect(rule.block).to be_nil
|
102
102
|
end
|
103
103
|
|
104
|
-
it
|
104
|
+
it "should create a rule with host, type and a reply block" do
|
105
105
|
rule = DevDNSd::Rule.create("MATCH", "TYPE", "UNUSED") do end
|
106
106
|
expect(rule.match).to eq("MATCH")
|
107
107
|
expect(rule.reply).to be_nil
|
@@ -112,32 +112,32 @@ describe DevDNSd::Rule do
|
|
112
112
|
end
|
113
113
|
|
114
114
|
describe "#resource_class" do
|
115
|
-
it
|
115
|
+
it "should return a single class" do
|
116
116
|
expect(DevDNSd::Rule.create("MATCH", "REPLY", :A).resource_class).to eq(Resolv::DNS::Resource::IN::A)
|
117
117
|
end
|
118
118
|
|
119
|
-
it
|
119
|
+
it "should return an array of classes" do
|
120
120
|
expect(DevDNSd::Rule.create("MATCH", "REPLY", [:A, :MX]).resource_class).to eq([Resolv::DNS::Resource::IN::A, Resolv::DNS::Resource::IN::MX])
|
121
121
|
end
|
122
122
|
|
123
|
-
it
|
123
|
+
it "should fail for a invalid class" do
|
124
124
|
expect { DevDNSd::Rule.create("MATCH", "REPLY", :INVALID).resource_class }.to raise_error(DevDNSd::Errors::InvalidRule)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
128
128
|
describe "::resource_class_to_symbol" do
|
129
|
-
it
|
129
|
+
it "should convert a class a symbol" do
|
130
130
|
expect(DevDNSd::Rule.resource_class_to_symbol(Resolv::DNS::Resource::IN::A)).to eq(:A)
|
131
131
|
expect(DevDNSd::Rule.resource_class_to_symbol(Resolv)).to eq(:Resolv)
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
135
|
describe "::symbol_to_resource_class" do
|
136
|
-
it
|
136
|
+
it "should convert a symbol to a resource class" do
|
137
137
|
expect(DevDNSd::Rule.symbol_to_resource_class(:A, :en)).to eq(Resolv::DNS::Resource::IN::A)
|
138
138
|
end
|
139
139
|
|
140
|
-
it
|
140
|
+
it "should fail for a invalid class" do
|
141
141
|
expect { DevDNSd::Rule.symbol_to_resource_class(:Invalid, :en) }.to raise_error(DevDNSd::Errors::InvalidRule)
|
142
142
|
end
|
143
143
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: devdnsd
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.1
|
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: 2013-07-
|
12
|
+
date: 2013-07-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mamertes
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 2.2.
|
21
|
+
version: 2.2.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 2.2.
|
29
|
+
version: 2.2.1
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: rubydns
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
137
137
|
version: '0'
|
138
138
|
segments:
|
139
139
|
- 0
|
140
|
-
hash:
|
140
|
+
hash: 2120411428097888079
|
141
141
|
requirements: []
|
142
142
|
rubyforge_project: devdnsd
|
143
143
|
rubygems_version: 1.8.25
|