spec/lib/conker_spec.rb in conker-0.12.2 vs spec/lib/conker_spec.rb in conker-0.13.1
- old
+ new
@@ -1,7 +1,7 @@
require 'active_support/core_ext/hash/indifferent_access'
-
+$:.unshift File.expand_path("../../lib", __FILE__)
require 'conker'
describe Conker do
before :each do
@constants = Kernel.constants
@@ -13,9 +13,38 @@
(Kernel.constants - @constants).each do |k|
Kernel.send :remove_const, k
end
end
+ describe 'type: :ip_address' do
+ it 'should parse IP addresses' do
+ Conker.module_eval do
+ setup_config! :development, {"IP_ADDR" => "172.17.16.15"},
+ IP_ADDR: optional(type: :ip_address, default: nil)
+ end
+ ::IP_ADDR.should == IPAddr.new("172.17.16.15")
+ end
+ end
+
+ describe 'type: :ip_range' do
+ it 'should parse CIDR ranges' do
+ Conker.module_eval do
+ setup_config! :development, {"IP_RANGE" => "172.17.16.0/24"},
+ IP_RANGE: optional(type: :ip_range, default: nil)
+
+ end
+ ::IP_RANGE.should include IPAddr.new("172.17.16.15")
+ end
+
+ it 'should parse <from>..<to>' do
+ Conker.module_eval do
+ setup_config! :development, {"IP_RANGE" => "172.17.16.116..172.17.16.131"},
+ IP_RANGE: optional(type: :ip_range, default: nil)
+
+ end
+ ::IP_RANGE.should include IPAddr.new("172.17.16.128")
+ end
+ end
describe 'reading config from a hash' do
describe 'basic usage' do
def setup!(env = :development, config = {})
Conker.module_eval do