devdnsd 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- devdnsd (1.1.0)
4
+ devdnsd (1.1.1)
5
5
  cowtech-extensions (~> 2.7.0)
6
6
  gli (~> 1.6.0)
7
7
  rainbow (~> 1.1.0)
@@ -29,7 +29,7 @@ GEM
29
29
  multi_json (~> 1.0)
30
30
  builder (3.0.0)
31
31
  coderay (1.0.7)
32
- cowtech-extensions (2.7.0)
32
+ cowtech-extensions (2.7.1)
33
33
  actionpack (~> 3.0)
34
34
  json (~> 1.7.0)
35
35
  tzinfo (~> 0.3.0)
data/README.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # devdnsd
2
2
 
3
+ [![Build Status](https://secure.travis-ci.org/ShogunPanda/devdnsd.png?branch=master)](http://travis-ci.org/ShogunPanda/devdnsd)
4
+ [![Dependency Status](https://gemnasium.com/ShogunPanda/devdnsd.png?travis)](https://gemnasium.com/ShogunPanda/devdnsd)
5
+
3
6
  A small DNS server to enable local .dev domain resolution.
4
7
  http://github.com/ShogunPanda/devdnsd
5
8
 
@@ -16,7 +16,7 @@ module DevDNSd
16
16
  MINOR = 1
17
17
 
18
18
  # The patch version.
19
- PATCH = 0
19
+ PATCH = 1
20
20
 
21
21
  # The current version number of DevDNSd.
22
22
  STRING = [MAJOR, MINOR, PATCH].compact.join(".")
@@ -19,8 +19,13 @@ describe DevDNSd::Application do
19
19
  let(:launch_agent_path) { "/tmp/devdnsd-test-agent-#{Time.now.strftime("%Y%m%d-%H%M%S")}" }
20
20
 
21
21
  describe "#initialize" do
22
- it("should setup the logger") do application.logger.should_not be_nil end
23
- it("should setup the configuration") do application.config.should_not be_nil end
22
+ it("should setup the logger") do
23
+ expect(application.logger).not_to be_nil
24
+ end
25
+
26
+ it("should setup the configuration") do
27
+ expect(application.config).not_to be_nil
28
+ end
24
29
 
25
30
  it("should abort with an invalid configuration") do
26
31
  path = "/tmp/devdnsd-test-#{Time.now.strftime("%Y%m%d-%H:%M:%S")}"
@@ -123,31 +128,31 @@ describe DevDNSd::Application do
123
128
 
124
129
  describe "should correctly resolve hostnames" do
125
130
  it "basing on a exact pattern" do
126
- test_resolve("match_1.dev").should == ["10.0.1.1", :A]
127
- test_resolve("match_2.dev").should == ["10.0.2.1", :MX]
128
- test_resolve("match_3.dev").should == ["10.0.3.1", :A]
129
- test_resolve("match_4.dev").should == ["10.0.4.1", :CNAME]
131
+ expect(test_resolve("match_1.dev")).to eq(["10.0.1.1", :A])
132
+ expect(test_resolve("match_2.dev")).to eq(["10.0.2.1", :MX])
133
+ expect(test_resolve("match_3.dev")).to eq(["10.0.3.1", :A])
134
+ expect(test_resolve("match_4.dev")).to eq(["10.0.4.1", :CNAME])
130
135
  end
131
136
 
132
137
  it "basing on a regexp pattern" do
133
- test_resolve("match_5_11.dev").should == ["10.0.5.11", :A]
134
- test_resolve("match_5_22.dev").should == ["10.0.5.22", :A]
135
- test_resolve("match_6_33.dev").should == ["10.0.6.33", :PTR]
136
- test_resolve("match_6_44.dev").should == ["10.0.6.44", :PTR]
137
- test_resolve("match_7_55.dev").should == ["10.0.7.55", :A]
138
- test_resolve("match_7_66.dev").should == ["10.0.7.66", :A]
139
- test_resolve("match_8_77.dev").should == ["10.0.8.77", :PTR]
140
- test_resolve("match_8_88.dev").should == ["10.0.8.88", :PTR]
138
+ expect(test_resolve("match_5_11.dev")).to eq(["10.0.5.11", :A])
139
+ expect(test_resolve("match_5_22.dev")).to eq(["10.0.5.22", :A])
140
+ expect(test_resolve("match_6_33.dev")).to eq(["10.0.6.33", :PTR])
141
+ expect(test_resolve("match_6_44.dev")).to eq(["10.0.6.44", :PTR])
142
+ expect(test_resolve("match_7_55.dev")).to eq(["10.0.7.55", :A])
143
+ expect(test_resolve("match_7_66.dev")).to eq(["10.0.7.66", :A])
144
+ expect(test_resolve("match_8_77.dev")).to eq(["10.0.8.77", :PTR])
145
+ expect(test_resolve("match_8_88.dev")).to eq(["10.0.8.88", :PTR])
141
146
  end
142
147
 
143
148
  it "and return multiple or only relevant answsers" do
144
- test_resolve("match_10.dev").should == [["10.0.10.1", :A], ["10.0.10.2", :MX]]
145
- test_resolve("match_10.dev", "MX").should == ["10.0.10.2", :MX]
149
+ expect(test_resolve("match_10.dev")).to eq([["10.0.10.1", :A], ["10.0.10.2", :MX]])
150
+ expect(test_resolve("match_10.dev", "MX")).to eq(["10.0.10.2", :MX])
146
151
  end
147
152
 
148
153
  it "and reject invalid matches (with or without rules)" do
149
- test_resolve("match_9.dev").should be_nil
150
- test_resolve("invalid.dev").should be_nil
154
+ expect(test_resolve("match_9.dev")).to be_nil
155
+ expect(test_resolve("invalid.dev")).to be_nil
151
156
  end
152
157
  end
153
158
  end
@@ -170,75 +175,85 @@ describe DevDNSd::Application do
170
175
 
171
176
  it "should match a valid string request" do
172
177
  rule = application.config.rules[0]
173
- application.process_rule(rule, rule.resource_class, nil, transaction).should be_true
178
+ expect(application.process_rule(rule, rule.resource_class, nil, transaction)).to be_true
174
179
  end
175
180
 
176
181
  it "should match a valid string request with specific type" do
177
182
  rule = application.config.rules[1]
178
- application.process_rule(rule, rule.resource_class, nil, transaction).should be_true
183
+ expect(application.process_rule(rule, rule.resource_class, nil, transaction)).to be_true
179
184
  end
180
185
 
181
186
  it "should match a valid string request with a block" do
182
187
  rule = application.config.rules[2]
183
- application.process_rule(rule, rule.resource_class, nil, transaction).should be_true
188
+ expect(application.process_rule(rule, rule.resource_class, nil, transaction)).to be_true
184
189
  end
185
190
 
186
191
  it "should match a valid string request with a block" do
187
192
  rule = application.config.rules[3]
188
- application.process_rule(rule, rule.resource_class, nil, transaction).should be_true
193
+ expect(application.process_rule(rule, rule.resource_class, nil, transaction)).to be_true
189
194
  end
190
195
 
191
196
  it "should match a valid regexp request" do
192
197
  rule = application.config.rules[4]
193
198
  mo = rule.match_host("match_5_12.dev")
194
- application.process_rule(rule, rule.resource_class, mo, transaction).should be_true
199
+ expect(application.process_rule(rule, rule.resource_class, mo, transaction)).to be_true
195
200
  end
196
201
 
197
202
  it "should match a valid regexp request with specific type" do
198
203
  rule = application.config.rules[5]
199
204
  mo = rule.match_host("match_6_34.dev")
200
- application.process_rule(rule, rule.resource_class, mo, transaction).should be_true
205
+ expect(application.process_rule(rule, rule.resource_class, mo, transaction)).to be_true
201
206
  end
202
207
 
203
208
  it "should match a valid regexp request with a block" do
204
209
  rule = application.config.rules[6]
205
210
  mo = rule.match_host("match_7_56.dev")
206
- application.process_rule(rule, rule.resource_class, mo, transaction).should be_true
211
+ expect(application.process_rule(rule, rule.resource_class, mo, transaction)).to be_true
207
212
  end
208
213
 
209
214
  it "should match a valid regexp request with a block and specific type" do
210
215
  rule = application.config.rules[7]
211
216
  mo = rule.match_host("match_8_78.dev")
212
- application.process_rule(rule, rule.resource_class, mo, transaction).should be_true
217
+ expect(application.process_rule(rule, rule.resource_class, mo, transaction)).to be_true
213
218
  end
214
219
 
215
220
  it "should return false for a false block" do
216
221
  rule = application.config.rules[8]
217
- application.process_rule(rule, rule.resource_class, nil, transaction).should be_false
222
+ expect(application.process_rule(rule, rule.resource_class, nil, transaction)).to be_false
218
223
  end
219
224
 
220
225
  it "should return nil for a nil reply" do
221
226
  rule = application.config.rules[0]
222
227
  rule.reply = nil
223
- application.process_rule(rule, rule.resource_class, nil, transaction).should be_nil
228
+ expect(application.process_rule(rule, rule.resource_class, nil, transaction)).to be_nil
224
229
  end
225
230
  end
226
231
 
227
232
  describe "#dns_update" do
228
233
  it "should update the DNS cache" do
229
234
  application.stub(:execute_command).and_return("EXECUTED")
230
- application.dns_update.should == "EXECUTED"
235
+ expect(application.dns_update).to eq("EXECUTED")
231
236
  end
232
237
  end
233
238
 
234
239
  describe "#resolver_path" do
235
- it "should return the resolver file basing on the configuration" do application.resolver_path.should == "/etc/resolver/#{application.config.tld}" end
236
- it "should return the resolver file basing on the argument" do application.resolver_path("foo").should == "/etc/resolver/foo" end
240
+ it "should return the resolver file basing on the configuration" do
241
+ expect(application.resolver_path).to eq("/etc/resolver/#{application.config.tld}")
242
+ end
243
+
244
+ it "should return the resolver file basing on the argument" do
245
+ expect(application.resolver_path("foo")).to eq("/etc/resolver/foo")
246
+ end
237
247
  end
238
248
 
239
249
  describe "#launch_agent_path" do
240
- it "should return the agent file with a default name" do application.launch_agent_path.should == ENV["HOME"] + "/Library/LaunchAgents/it.cowtech.devdnsd.plist" end
241
- it "should return the agent file with a specified name" do application.launch_agent_path("foo").should == ENV["HOME"] + "/Library/LaunchAgents/foo.plist" end
250
+ it "should return the agent file with a default name" do
251
+ expect(application.launch_agent_path).to eq(ENV["HOME"] + "/Library/LaunchAgents/it.cowtech.devdnsd.plist")
252
+ end
253
+
254
+ it "should return the agent file with a specified name" do
255
+ expect(application.launch_agent_path("foo")).to eq(ENV["HOME"] + "/Library/LaunchAgents/foo.plist")
256
+ end
242
257
  end
243
258
 
244
259
  describe "#action_start" do
@@ -271,7 +286,7 @@ describe DevDNSd::Application do
271
286
  ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
272
287
 
273
288
  application.action_install
274
- ::File.exists?(resolver_path).should be_true
289
+ expect(::File.exists?(resolver_path)).to be_true
275
290
 
276
291
  ::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
277
292
  ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
@@ -285,7 +300,7 @@ describe DevDNSd::Application do
285
300
 
286
301
  application.stub(:resolver_path).and_return(resolver_path)
287
302
  application.action_install
288
- ::File.exists?(application.launch_agent_path).should be_true
303
+ expect(::File.exists?(application.launch_agent_path)).to be_true
289
304
 
290
305
  ::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
291
306
  ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
@@ -353,7 +368,7 @@ describe DevDNSd::Application do
353
368
  it "should raise an exception if not running on OSX" do
354
369
  application.stub(:is_osx?).and_return(false)
355
370
  application.get_logger.should_receive(:fatal).with("Install DevDNSd as a local resolver is only available on MacOSX.")
356
- application.action_install.should be_false
371
+ expect(application.action_install).to be_false
357
372
  end
358
373
  end
359
374
 
@@ -367,7 +382,7 @@ describe DevDNSd::Application do
367
382
 
368
383
  application.action_install
369
384
  application.action_uninstall
370
- ::File.exists?(resolver_path).should be_false
385
+ expect(::File.exists?(resolver_path)).to be_false
371
386
 
372
387
  ::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
373
388
  ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
@@ -382,7 +397,7 @@ describe DevDNSd::Application do
382
397
  DevDNSd::Logger.stub(:default_file).and_return($stdout)
383
398
  application.action_install
384
399
  application.action_uninstall
385
- ::File.exists?(application.launch_agent_path).should be_false
400
+ expect(::File.exists?(application.launch_agent_path)).to be_false
386
401
 
387
402
  ::File.unlink(application.resolver_path) if ::File.exists?(application.resolver_path)
388
403
  ::File.unlink(application.launch_agent_path) if ::File.exists?(application.launch_agent_path)
@@ -443,7 +458,7 @@ describe DevDNSd::Application do
443
458
  it "should raise an exception if not running on OSX" do
444
459
  application.stub(:is_osx?).and_return(false)
445
460
  application.get_logger.should_receive(:fatal).with("Install DevDNSd as a local resolver is only available on MacOSX.")
446
- application.action_uninstall.should be_false
461
+ expect(application.action_uninstall).to be_false
447
462
  end
448
463
  end
449
464
  end
@@ -25,13 +25,13 @@ describe DevDNSd::Configuration do
25
25
  describe "#initialize" do
26
26
  it "sets default arguments and rules" do
27
27
  config = DevDNSd::Configuration.new
28
- config.address.should == "0.0.0.0"
29
- config.port.should == 7771
30
- config.tld.should == "dev"
31
- config.log_file.should == "/var/log/devdnsd.log"
32
- config.log_level.should == ::Logger::INFO
33
- config.rules.count.should == 1
34
- config.foreground.should == false
28
+ expect(config.address).to eq("0.0.0.0")
29
+ expect(config.port).to eq(7771)
30
+ expect(config.tld).to eq("dev")
31
+ expect(config.log_file).to eq("/var/log/devdnsd.log")
32
+ expect(config.log_level).to eq(::Logger::INFO)
33
+ expect(config.rules.count).to eq(1)
34
+ expect(config.foreground).to eq(false)
35
35
  end
36
36
 
37
37
  it "reads a valid configuration file" do
@@ -40,7 +40,7 @@ describe DevDNSd::Configuration do
40
40
  file.close
41
41
 
42
42
  config = DevDNSd::Configuration.new(file.path, new_application)
43
- config.port.should == 7772
43
+ expect(config.port).to eq(7772)
44
44
  file.unlink
45
45
  end
46
46
 
@@ -59,7 +59,7 @@ describe DevDNSd::Configuration do
59
59
  file.close
60
60
 
61
61
  config = DevDNSd::Configuration.new(file.path, new_application, {:foreground => true, :port => 7773})
62
- config.port.should == 7773
62
+ expect(config.port).to eq(7773)
63
63
  config.foreground = true
64
64
  file.unlink
65
65
  end
@@ -69,7 +69,7 @@ describe DevDNSd::Configuration do
69
69
  it "should add a good rule" do
70
70
  config = DevDNSd::Configuration.new
71
71
  config.add_rule("RULE", "127.0.0.1")
72
- config.rules.count.should == 2
72
+ expect(config.rules.count).to eq(2)
73
73
  end
74
74
 
75
75
  it "should reject a bad rule" do
@@ -14,24 +14,24 @@ describe DevDNSd::Logger do
14
14
  describe ".create" do
15
15
  it("should create a new default logger") do
16
16
  logger = DevDNSd::Logger.create
17
- logger.device.should == DevDNSd::Logger.default_file
18
- logger.level.should == ::Logger::INFO
19
- logger.formatter.should == DevDNSd::Logger.default_formatter
17
+ expect(logger.device).to eq(DevDNSd::Logger.default_file)
18
+ expect(logger.level).to eq(::Logger::INFO)
19
+ expect(logger.formatter).to eq(DevDNSd::Logger.default_formatter)
20
20
  end
21
21
 
22
22
  it("should create a logger with a custom file and level") do
23
23
  logger = DevDNSd::Logger.create("/dev/null", ::Logger::WARN)
24
- logger.device.should == "/dev/null"
25
- logger.level.should == ::Logger::WARN
26
- logger.formatter.should == DevDNSd::Logger.default_formatter
24
+ expect(logger.device).to eq("/dev/null")
25
+ expect(logger.level).to eq(::Logger::WARN)
26
+ expect(logger.formatter).to eq(DevDNSd::Logger.default_formatter)
27
27
  end
28
28
 
29
29
  it("should create a logger with a custom formatter") do
30
30
  formatter = Proc.new {|severity, datetime, progname, msg| msg }
31
31
  logger = DevDNSd::Logger.create("/dev/null", ::Logger::WARN, formatter)
32
- logger.device.should == "/dev/null"
33
- logger.level.should == ::Logger::WARN
34
- logger.formatter.should == formatter
32
+ expect(logger.device).to eq("/dev/null")
33
+ expect(logger.level).to eq(::Logger::WARN)
34
+ expect(logger.formatter).to eq(formatter)
35
35
  end
36
36
 
37
37
  it("should raise exceptions for invalid files") do
@@ -49,42 +49,52 @@ describe DevDNSd::Logger do
49
49
 
50
50
  it "should correctly format a DEBUG message" do
51
51
  logger.debug("Message.")
52
- get_last_line(output).should == "[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] DEBUG: Message."
52
+ expect(get_last_line(output)).to eq("[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] DEBUG: Message.")
53
53
  end
54
54
 
55
55
  it "should correctly format a INFO message" do
56
56
  logger.info("Message.")
57
- get_last_line(output).should == "[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] INFO: Message."
57
+ expect(get_last_line(output)).to eq("[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] INFO: Message.")
58
58
  end
59
59
 
60
60
  it "should correctly format a WARN message" do
61
61
  logger.warn("Message.")
62
- get_last_line(output).should == "[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] WARN: Message."
62
+ expect(get_last_line(output)).to eq("[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] WARN: Message.")
63
63
  end
64
64
 
65
65
  it "should correctly format a ERROR message" do
66
66
  logger.error("Message.")
67
- get_last_line(output).should == "[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] ERROR: Message."
67
+ expect(get_last_line(output)).to eq("[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] ERROR: Message.")
68
68
  end
69
69
 
70
70
  it "should correctly format a FATAL message" do
71
71
  logger.fatal("Message.")
72
- get_last_line(output).should == "[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] FATAL: Message."
72
+ expect(get_last_line(output)).to eq("[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] FATAL: Message.")
73
73
  end
74
74
 
75
75
  it "should correctly format a INVALID message" do
76
76
  logger.log(::Logger::UNKNOWN, "Message.")
77
- get_last_line(output).should == "[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] ANY: Message."
77
+ expect(get_last_line(output)).to eq("[#{::Time.now.strftime("%Y/%b/%d %H:%M:%S")}] ANY: Message.")
78
78
  end
79
79
  end
80
80
 
81
81
  describe ".get_real_file" do
82
- it("should return the standard ouput") do DevDNSd::Logger.get_real_file("STDOUT").should == $stdout end
83
- it("should return the standard error") do DevDNSd::Logger.get_real_file("STDERR").should == $stderr end
84
- it("should return the file") do DevDNSd::Logger.get_real_file("/dev/null").should == "/dev/null" end
82
+ it("should return the standard ouput") do
83
+ expect(DevDNSd::Logger.get_real_file("STDOUT")).to eq($stdout )
84
+ end
85
+
86
+ it("should return the standard error") do
87
+ expect(DevDNSd::Logger.get_real_file("STDERR")).to eq($stderr )
88
+ end
89
+
90
+ it("should return the file") do
91
+ expect(DevDNSd::Logger.get_real_file("/dev/null")).to eq("/dev/null" )
92
+ end
85
93
  end
86
94
 
87
95
  describe ".default_file" do
88
- it("should return the standard output") do DevDNSd::Logger.default_file.should == $stdout end
96
+ it("should return the standard output") do
97
+ expect(DevDNSd::Logger.default_file).to eq($stdout)
98
+ end
89
99
  end
90
100
  end
@@ -10,51 +10,71 @@ describe DevDNSd::Rule do
10
10
  describe "#new" do
11
11
  it("should create a default rule") do
12
12
  rule = DevDNSd::Rule.new
13
- rule.match.should == /.+/
14
- rule.reply.should == "127.0.0.1"
15
- rule.type.should == :A
16
- rule.options.should == {}
17
- rule.block.should be_nil
13
+ expect(rule.match).to eq(/.+/)
14
+ expect(rule.reply).to eq("127.0.0.1")
15
+ expect(rule.type).to eq(:A)
16
+ expect(rule.options).to eq({})
17
+ expect(rule.block).to be_nil
18
18
  end
19
19
 
20
20
  it("should create a rule with arguments and no block") do
21
21
  rule = DevDNSd::Rule.new("MATCH", "REPLY", "TYPE", {:a => :b})
22
- rule.match.should == "MATCH"
23
- rule.reply.should == "REPLY"
24
- rule.type.should == "TYPE"
25
- rule.options.should == {:a => :b}
26
- rule.block.should be_nil
22
+ expect(rule.match).to eq("MATCH")
23
+ expect(rule.reply).to eq("REPLY")
24
+ expect(rule.type).to eq("TYPE")
25
+ expect(rule.options).to eq({:a => :b})
26
+ expect(rule.block).to be_nil
27
27
  end
28
28
 
29
29
  it("should create a rule with arguments and a block") do
30
30
  rule = DevDNSd::Rule.new("MATCH", "REPLY", "TYPE") do end
31
- rule.match.should == "MATCH"
32
- rule.reply.should be_nil
33
- rule.type.should == "TYPE"
34
- rule.options.should == {}
35
- rule.block.should_not be_nil
31
+ expect(rule.match).to eq("MATCH")
32
+ expect(rule.reply).to be_nil
33
+ expect(rule.type).to eq("TYPE")
34
+ expect(rule.options).to eq({})
35
+ expect(rule.block).not_to be_nil
36
36
  end
37
37
  end
38
38
 
39
39
  describe "#is_regexp?" do
40
- it("should return true for a regexp pattern") do DevDNSd::Rule.create(/.+/, "127.0.0.1").is_regexp?.should be_true end
41
- it("should return false otherwise") do DevDNSd::Rule.create("RULE", "127.0.0.1").is_regexp?.should be_false end
40
+ it("should return true for a regexp pattern") do
41
+ expect(DevDNSd::Rule.create(/.+/, "127.0.0.1").is_regexp?).to be_true
42
+ end
43
+
44
+ it("should return false otherwise") do
45
+ expect(DevDNSd::Rule.create("RULE", "127.0.0.1").is_regexp?).to be_false
46
+ end
42
47
  end
43
48
 
44
49
  describe "#has_block?" do
45
- it("should return true when a block is present") do DevDNSd::Rule.create("RULE"){}.has_block?.should be_true end
46
- it("should return false otherwise") do DevDNSd::Rule.create("RULE", "127.0.0.1").has_block?.should be_false end
50
+ it("should return true when a block is present") do
51
+ expect(DevDNSd::Rule.create("RULE"){}.has_block?).to be_true
52
+ end
53
+
54
+ it("should return false otherwise") do
55
+ expect(DevDNSd::Rule.create("RULE", "127.0.0.1").has_block?).to be_false
56
+ end
47
57
  end
48
58
 
49
59
  describe "#match_host" do
50
60
  describe "with a string pattern" do
51
- it("should return true when hostname matches") do DevDNSd::Rule.create("match.dev", "127.0.0.1").match_host("match.dev").should be_true end
52
- it("should return false when hostname doesn't match") do DevDNSd::Rule.create("match.dev", "127.0.0.1").match_host("unmatch.dev").should be_false end
61
+ it("should return true when hostname matches") do
62
+ expect(DevDNSd::Rule.create("match.dev", "127.0.0.1").match_host("match.dev")).to be_true
63
+ end
64
+
65
+ it("should return false when hostname doesn't match") do
66
+ expect(DevDNSd::Rule.create("match.dev", "127.0.0.1").match_host("unmatch.dev")).to be_false
67
+ end
53
68
  end
54
69
 
55
70
  describe "with a regexp pattern" do
56
- it("should return a MatchData when hostname matches") do DevDNSd::Rule.create(/^match/, "127.0.0.1").match_host("match.dev").should be_a(MatchData) end
57
- it("should return nil when hostname doesn't match") do DevDNSd::Rule.create(/^match/, "127.0.0.1").match_host("unmatch.dev").should be_nil end
71
+ it("should return a MatchData when hostname matches") do
72
+ expect(DevDNSd::Rule.create(/^match/, "127.0.0.1").match_host("match.dev")).to be_a(MatchData)
73
+ end
74
+
75
+ it("should return nil when hostname doesn't match") do
76
+ expect(DevDNSd::Rule.create(/^match/, "127.0.0.1").match_host("unmatch.dev")).to be_nil
77
+ end
58
78
  end
59
79
  end
60
80
 
@@ -66,46 +86,59 @@ describe DevDNSd::Rule do
66
86
 
67
87
  it("should create a rule with host and reply") do
68
88
  rule = DevDNSd::Rule.create("MATCH", "REPLY")
69
- rule.match.should == "MATCH"
70
- rule.reply.should == "REPLY"
71
- rule.type.should == :A
72
- rule.block.should be_nil
89
+ expect(rule.match).to eq("MATCH")
90
+ expect(rule.reply).to eq("REPLY")
91
+ expect(rule.type).to eq(:A)
92
+ expect(rule.block).to be_nil
73
93
  end
74
94
 
75
95
  it("should create a rule with host, reply and type") do
76
96
  rule = DevDNSd::Rule.create("MATCH", "REPLY", "TYPE", {:a => :b})
77
- rule.match.should == "MATCH"
78
- rule.reply.should == "REPLY"
79
- rule.type.should == "TYPE"
80
- rule.options.should == {:a => :b}
81
- rule.block.should be_nil
97
+ expect(rule.match).to eq("MATCH")
98
+ expect(rule.reply).to eq("REPLY")
99
+ expect(rule.type).to eq("TYPE")
100
+ expect(rule.options).to eq({:a => :b})
101
+ expect(rule.block).to be_nil
82
102
  end
83
103
 
84
104
  it("should create a rule with host, type and a reply block") do
85
105
  rule = DevDNSd::Rule.create("MATCH", "TYPE", "UNUSED") do end
86
- rule.match.should == "MATCH"
87
- rule.reply.should be_nil
88
- rule.type.should == "TYPE"
89
- rule.options.should == {}
90
- rule.block.should_not be_nil
106
+ expect(rule.match).to eq("MATCH")
107
+ expect(rule.reply).to be_nil
108
+ expect(rule.type).to eq("TYPE")
109
+ expect(rule.options).to eq({})
110
+ expect(rule.block).not_to be_nil
91
111
  end
92
112
  end
93
113
 
94
114
  describe "#resource_class" do
95
- it("should return a single class") do DevDNSd::Rule.create("MATCH", "REPLY", :A).resource_class.should == Resolv::DNS::Resource::IN::A end
96
- it("should return an array of classes") do DevDNSd::Rule.create("MATCH", "REPLY", [:A, :MX]).resource_class.should == [Resolv::DNS::Resource::IN::A, Resolv::DNS::Resource::IN::MX] end
97
- it("should fail for a invalid class") do expect { DevDNSd::Rule.create("MATCH", "REPLY", :INVALID).resource_class }.to raise_error(DevDNSd::Errors::InvalidRule) end
115
+ it("should return a single class") do
116
+ expect(DevDNSd::Rule.create("MATCH", "REPLY", :A).resource_class).to eq(Resolv::DNS::Resource::IN::A)
117
+ end
118
+
119
+ it("should return an array of classes") do
120
+ expect(DevDNSd::Rule.create("MATCH", "REPLY", [:A, :MX]).resource_class).to eq([Resolv::DNS::Resource::IN::A, Resolv::DNS::Resource::IN::MX])
121
+ end
122
+
123
+ it("should fail for a invalid class") do
124
+ expect { DevDNSd::Rule.create("MATCH", "REPLY", :INVALID).resource_class }.to raise_error(DevDNSd::Errors::InvalidRule)
125
+ end
98
126
  end
99
127
 
100
128
  describe "::resource_class_to_symbol" do
101
129
  it("should convert a class a symbol") do
102
- DevDNSd::Rule.resource_class_to_symbol(Resolv::DNS::Resource::IN::A).should == :A
103
- DevDNSd::Rule.resource_class_to_symbol(Resolv).should == :Resolv
130
+ expect(DevDNSd::Rule.resource_class_to_symbol(Resolv::DNS::Resource::IN::A)).to eq(:A)
131
+ expect(DevDNSd::Rule.resource_class_to_symbol(Resolv)).to eq(:Resolv)
104
132
  end
105
133
  end
106
134
 
107
135
  describe "::symbol_to_resource_class" do
108
- it("should convert a symbol to a resource class") do DevDNSd::Rule.symbol_to_resource_class(:A).should == Resolv::DNS::Resource::IN::A end
109
- it("should fail for a invalid class") do expect { DevDNSd::Rule.symbol_to_resource_class(:Invalid) }.to raise_error(DevDNSd::Errors::InvalidRule) end
136
+ it("should convert a symbol to a resource class") do
137
+ expect(DevDNSd::Rule.symbol_to_resource_class(:A)).to eq(Resolv::DNS::Resource::IN::A)
138
+ end
139
+
140
+ it("should fail for a invalid class") do
141
+ expect { DevDNSd::Rule.symbol_to_resource_class(:Invalid) }.to raise_error(DevDNSd::Errors::InvalidRule)
142
+ end
110
143
  end
111
144
  end
data/spec/spec_helper.rb CHANGED
@@ -10,4 +10,10 @@ require "coverage_helper"
10
10
  require "devdnsd"
11
11
  require "net/dns"
12
12
 
13
+ RSpec.configure do |config|
14
+ config.expect_with :rspec do |c|
15
+ c.syntax = :expect
16
+ end
17
+ end
18
+
13
19
  require File.expand_path(File.dirname(__FILE__)) + "/../utils/tester"
metadata CHANGED
@@ -1,232 +1,240 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: devdnsd
3
- version: !ruby/object:Gem::Version
4
- version: 1.1.0
3
+ version: !ruby/object:Gem::Version
4
+ hash: 17
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 1
9
+ - 1
10
+ version: 1.1.1
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Shogun
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-25 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: rubydns
16
- requirement: !ruby/object:Gem::Requirement
17
+
18
+ date: 2012-07-28 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
21
+ version_requirements: &id001 !ruby/object:Gem::Requirement
17
22
  none: false
18
- requirements:
23
+ requirements:
19
24
  - - ~>
20
- - !ruby/object:Gem::Version
25
+ - !ruby/object:Gem::Version
26
+ hash: 15
27
+ segments:
28
+ - 0
29
+ - 4
30
+ - 0
21
31
  version: 0.4.0
22
- type: :runtime
23
32
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ~>
28
- - !ruby/object:Gem::Version
29
- version: 0.4.0
30
- - !ruby/object:Gem::Dependency
31
- name: cowtech-extensions
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ~>
36
- - !ruby/object:Gem::Version
37
- version: 2.7.0
38
33
  type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
34
+ name: rubydns
35
+ requirement: *id001
36
+ - !ruby/object:Gem::Dependency
37
+ version_requirements: &id002 !ruby/object:Gem::Requirement
41
38
  none: false
42
- requirements:
39
+ requirements:
43
40
  - - ~>
44
- - !ruby/object:Gem::Version
41
+ - !ruby/object:Gem::Version
42
+ hash: 19
43
+ segments:
44
+ - 2
45
+ - 7
46
+ - 0
45
47
  version: 2.7.0
46
- - !ruby/object:Gem::Dependency
47
- name: gli
48
- requirement: !ruby/object:Gem::Requirement
49
- none: false
50
- requirements:
51
- - - ~>
52
- - !ruby/object:Gem::Version
53
- version: 1.6.0
54
- type: :runtime
55
48
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
49
+ type: :runtime
50
+ name: cowtech-extensions
51
+ requirement: *id002
52
+ - !ruby/object:Gem::Dependency
53
+ version_requirements: &id003 !ruby/object:Gem::Requirement
57
54
  none: false
58
- requirements:
55
+ requirements:
59
56
  - - ~>
60
- - !ruby/object:Gem::Version
57
+ - !ruby/object:Gem::Version
58
+ hash: 15
59
+ segments:
60
+ - 1
61
+ - 6
62
+ - 0
61
63
  version: 1.6.0
62
- - !ruby/object:Gem::Dependency
63
- name: rexec
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ~>
68
- - !ruby/object:Gem::Version
69
- version: 1.4.1
70
- type: :runtime
71
64
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
65
+ type: :runtime
66
+ name: gli
67
+ requirement: *id003
68
+ - !ruby/object:Gem::Dependency
69
+ version_requirements: &id004 !ruby/object:Gem::Requirement
73
70
  none: false
74
- requirements:
71
+ requirements:
75
72
  - - ~>
76
- - !ruby/object:Gem::Version
73
+ - !ruby/object:Gem::Version
74
+ hash: 5
75
+ segments:
76
+ - 1
77
+ - 4
78
+ - 1
77
79
  version: 1.4.1
78
- - !ruby/object:Gem::Dependency
79
- name: rainbow
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ~>
84
- - !ruby/object:Gem::Version
85
- version: 1.1.0
86
- type: :runtime
87
80
  prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
81
+ type: :runtime
82
+ name: rexec
83
+ requirement: *id004
84
+ - !ruby/object:Gem::Dependency
85
+ version_requirements: &id005 !ruby/object:Gem::Requirement
89
86
  none: false
90
- requirements:
87
+ requirements:
91
88
  - - ~>
92
- - !ruby/object:Gem::Version
89
+ - !ruby/object:Gem::Version
90
+ hash: 19
91
+ segments:
92
+ - 1
93
+ - 1
94
+ - 0
93
95
  version: 1.1.0
94
- - !ruby/object:Gem::Dependency
95
- name: rspec
96
- requirement: !ruby/object:Gem::Requirement
97
- none: false
98
- requirements:
99
- - - ~>
100
- - !ruby/object:Gem::Version
101
- version: 2.11.0
102
- type: :development
103
96
  prerelease: false
104
- version_requirements: !ruby/object:Gem::Requirement
97
+ type: :runtime
98
+ name: rainbow
99
+ requirement: *id005
100
+ - !ruby/object:Gem::Dependency
101
+ version_requirements: &id006 !ruby/object:Gem::Requirement
105
102
  none: false
106
- requirements:
103
+ requirements:
107
104
  - - ~>
108
- - !ruby/object:Gem::Version
105
+ - !ruby/object:Gem::Version
106
+ hash: 35
107
+ segments:
108
+ - 2
109
+ - 11
110
+ - 0
109
111
  version: 2.11.0
110
- - !ruby/object:Gem::Dependency
111
- name: rake
112
- requirement: !ruby/object:Gem::Requirement
113
- none: false
114
- requirements:
115
- - - ~>
116
- - !ruby/object:Gem::Version
117
- version: 0.9.0
118
- type: :development
119
112
  prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
113
+ type: :development
114
+ name: rspec
115
+ requirement: *id006
116
+ - !ruby/object:Gem::Dependency
117
+ version_requirements: &id007 !ruby/object:Gem::Requirement
121
118
  none: false
122
- requirements:
119
+ requirements:
123
120
  - - ~>
124
- - !ruby/object:Gem::Version
121
+ - !ruby/object:Gem::Version
122
+ hash: 59
123
+ segments:
124
+ - 0
125
+ - 9
126
+ - 0
125
127
  version: 0.9.0
126
- - !ruby/object:Gem::Dependency
127
- name: simplecov
128
- requirement: !ruby/object:Gem::Requirement
129
- none: false
130
- requirements:
131
- - - ~>
132
- - !ruby/object:Gem::Version
133
- version: 0.6.0
134
- type: :development
135
128
  prerelease: false
136
- version_requirements: !ruby/object:Gem::Requirement
129
+ type: :development
130
+ name: rake
131
+ requirement: *id007
132
+ - !ruby/object:Gem::Dependency
133
+ version_requirements: &id008 !ruby/object:Gem::Requirement
137
134
  none: false
138
- requirements:
135
+ requirements:
139
136
  - - ~>
140
- - !ruby/object:Gem::Version
137
+ - !ruby/object:Gem::Version
138
+ hash: 7
139
+ segments:
140
+ - 0
141
+ - 6
142
+ - 0
141
143
  version: 0.6.0
142
- - !ruby/object:Gem::Dependency
143
- name: pry
144
- requirement: !ruby/object:Gem::Requirement
145
- none: false
146
- requirements:
147
- - - ~>
148
- - !ruby/object:Gem::Version
149
- version: 0.9.10
150
- type: :development
151
144
  prerelease: false
152
- version_requirements: !ruby/object:Gem::Requirement
145
+ type: :development
146
+ name: simplecov
147
+ requirement: *id008
148
+ - !ruby/object:Gem::Dependency
149
+ version_requirements: &id009 !ruby/object:Gem::Requirement
153
150
  none: false
154
- requirements:
151
+ requirements:
155
152
  - - ~>
156
- - !ruby/object:Gem::Version
153
+ - !ruby/object:Gem::Version
154
+ hash: 47
155
+ segments:
156
+ - 0
157
+ - 9
158
+ - 10
157
159
  version: 0.9.10
158
- - !ruby/object:Gem::Dependency
159
- name: net-dns
160
- requirement: !ruby/object:Gem::Requirement
161
- none: false
162
- requirements:
163
- - - ~>
164
- - !ruby/object:Gem::Version
165
- version: 0.7.0
166
- type: :development
167
160
  prerelease: false
168
- version_requirements: !ruby/object:Gem::Requirement
161
+ type: :development
162
+ name: pry
163
+ requirement: *id009
164
+ - !ruby/object:Gem::Dependency
165
+ version_requirements: &id010 !ruby/object:Gem::Requirement
169
166
  none: false
170
- requirements:
167
+ requirements:
171
168
  - - ~>
172
- - !ruby/object:Gem::Version
169
+ - !ruby/object:Gem::Version
170
+ hash: 3
171
+ segments:
172
+ - 0
173
+ - 7
174
+ - 0
173
175
  version: 0.7.0
174
- - !ruby/object:Gem::Dependency
175
- name: yard
176
- requirement: !ruby/object:Gem::Requirement
177
- none: false
178
- requirements:
179
- - - ~>
180
- - !ruby/object:Gem::Version
181
- version: 0.8.0
182
- type: :development
183
176
  prerelease: false
184
- version_requirements: !ruby/object:Gem::Requirement
177
+ type: :development
178
+ name: net-dns
179
+ requirement: *id010
180
+ - !ruby/object:Gem::Dependency
181
+ version_requirements: &id011 !ruby/object:Gem::Requirement
185
182
  none: false
186
- requirements:
183
+ requirements:
187
184
  - - ~>
188
- - !ruby/object:Gem::Version
185
+ - !ruby/object:Gem::Version
186
+ hash: 63
187
+ segments:
188
+ - 0
189
+ - 8
190
+ - 0
189
191
  version: 0.8.0
190
- - !ruby/object:Gem::Dependency
191
- name: redcarpet
192
- requirement: !ruby/object:Gem::Requirement
193
- none: false
194
- requirements:
195
- - - ~>
196
- - !ruby/object:Gem::Version
197
- version: 2.1.0
198
- type: :development
199
192
  prerelease: false
200
- version_requirements: !ruby/object:Gem::Requirement
193
+ type: :development
194
+ name: yard
195
+ requirement: *id011
196
+ - !ruby/object:Gem::Dependency
197
+ version_requirements: &id012 !ruby/object:Gem::Requirement
201
198
  none: false
202
- requirements:
199
+ requirements:
203
200
  - - ~>
204
- - !ruby/object:Gem::Version
201
+ - !ruby/object:Gem::Version
202
+ hash: 11
203
+ segments:
204
+ - 2
205
+ - 1
206
+ - 0
205
207
  version: 2.1.0
206
- - !ruby/object:Gem::Dependency
207
- name: github-markup
208
- requirement: !ruby/object:Gem::Requirement
209
- none: false
210
- requirements:
211
- - - ~>
212
- - !ruby/object:Gem::Version
213
- version: 0.7.0
214
- type: :development
215
208
  prerelease: false
216
- version_requirements: !ruby/object:Gem::Requirement
209
+ type: :development
210
+ name: redcarpet
211
+ requirement: *id012
212
+ - !ruby/object:Gem::Dependency
213
+ version_requirements: &id013 !ruby/object:Gem::Requirement
217
214
  none: false
218
- requirements:
215
+ requirements:
219
216
  - - ~>
220
- - !ruby/object:Gem::Version
217
+ - !ruby/object:Gem::Version
218
+ hash: 3
219
+ segments:
220
+ - 0
221
+ - 7
222
+ - 0
221
223
  version: 0.7.0
224
+ prerelease: false
225
+ type: :development
226
+ name: github-markup
227
+ requirement: *id013
222
228
  description: A small DNS server to enable local domain resolution.
223
- email:
229
+ email:
224
230
  - shogun_panda@me.com
225
- executables:
231
+ executables:
226
232
  - devdnsd
227
233
  extensions: []
234
+
228
235
  extra_rdoc_files: []
229
- files:
236
+
237
+ files:
230
238
  - .DS_Store
231
239
  - .gitignore
232
240
  - .travis.yml
@@ -254,35 +262,38 @@ files:
254
262
  - utils/tester.rb
255
263
  homepage: http://github.com/ShogunPanda/devdnsd
256
264
  licenses: []
265
+
257
266
  post_install_message:
258
267
  rdoc_options: []
259
- require_paths:
268
+
269
+ require_paths:
260
270
  - lib
261
- required_ruby_version: !ruby/object:Gem::Requirement
271
+ required_ruby_version: !ruby/object:Gem::Requirement
262
272
  none: false
263
- requirements:
264
- - - ! '>='
265
- - !ruby/object:Gem::Version
266
- version: '0'
267
- segments:
273
+ requirements:
274
+ - - ">="
275
+ - !ruby/object:Gem::Version
276
+ hash: 3
277
+ segments:
268
278
  - 0
269
- hash: 97728399073097527
270
- required_rubygems_version: !ruby/object:Gem::Requirement
279
+ version: "0"
280
+ required_rubygems_version: !ruby/object:Gem::Requirement
271
281
  none: false
272
- requirements:
273
- - - ! '>='
274
- - !ruby/object:Gem::Version
275
- version: '0'
276
- segments:
282
+ requirements:
283
+ - - ">="
284
+ - !ruby/object:Gem::Version
285
+ hash: 3
286
+ segments:
277
287
  - 0
278
- hash: 97728399073097527
288
+ version: "0"
279
289
  requirements: []
290
+
280
291
  rubyforge_project: devdnsd
281
292
  rubygems_version: 1.8.24
282
293
  signing_key:
283
294
  specification_version: 3
284
295
  summary: A small DNS server to enable local domain resolution.
285
- test_files:
296
+ test_files:
286
297
  - spec/coverage_helper.rb
287
298
  - spec/devdnsd/application_spec.rb
288
299
  - spec/devdnsd/configuration_spec.rb