2
# Author:: Bryan McLellan (btm@loftninjas.org)
3
# Copyright:: Copyright (c) 2008 Bryan McLellan
4
# License:: Apache License, Version 2.0
6
# Licensed under the Apache License, Version 2.0 (the "License");
7
# you may not use this file except in compliance with the License.
8
# You may obtain a copy of the License at
10
# http://www.apache.org/licenses/LICENSE-2.0
12
# Unless required by applicable law or agreed to in writing, software
13
# distributed under the License is distributed on an "AS IS" BASIS,
14
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
# See the License for the specific language governing permissions and
16
# limitations under the License.
19
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
21
describe Chef::Resource::Route do
24
@resource = Chef::Resource::Route.new("10.0.0.10")
27
it "should create a new Chef::Resource::Route" do
28
@resource.should be_a_kind_of(Chef::Resource)
29
@resource.should be_a_kind_of(Chef::Resource::Route)
32
it "should have a name" do
33
@resource.name.should eql("10.0.0.10")
36
it "should have a default action of 'add'" do
37
@resource.action.should eql(:add)
40
it "should accept add or delete for action" do
41
lambda { @resource.action :add }.should_not raise_error(ArgumentError)
42
lambda { @resource.action :delete }.should_not raise_error(ArgumentError)
43
lambda { @resource.action :lolcat }.should raise_error(ArgumentError)
46
it "should use the object name as the target by default" do
47
@resource.target.should eql("10.0.0.10")
50
it "should allow you to specify the netmask" do
51
@resource.netmask "255.255.255.0"
52
@resource.netmask.should eql("255.255.255.0")
55
it "should allow you to specify the gateway" do
56
@resource.gateway "10.0.0.1"
57
@resource.gateway.should eql("10.0.0.1")
60
it "should allow you to specify the metric" do
62
@resource.metric.should eql(10)
65
it "should allow you to specify the device" do
66
@resource.device "eth0"
67
@resource.device.should eql("eth0")
70
it "should allow you to specify the route type" do
71
@resource.route_type "host"
72
@resource.route_type.should eql(:host)
75
it "should default to a host route type" do
76
@resource.route_type.should eql(:host)
79
it "should accept a net route type" do
80
@resource.route_type :net
81
@resource.route_type.should eql(:net)
84
it "should reject any other route_type but :host and :net" do
85
lambda { @resource.route_type "lolcat" }.should raise_error(ArgumentError)