~ubuntu-branches/ubuntu/karmic/chef/karmic

« back to all changes in this revision

Viewing changes to chef/spec/unit/resource/route_spec.rb

  • Committer: Bazaar Package Importer
  • Author(s): Joshua Timberman
  • Date: 2009-08-12 12:18:48 UTC
  • Revision ID: james.westby@ubuntu.com-20090812121848-yl38hpd7nfsl51xz
Tags: upstream-0.7.8
ImportĀ upstreamĀ versionĀ 0.7.8

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Author:: Bryan McLellan (btm@loftninjas.org)
 
3
# Copyright:: Copyright (c) 2008 Bryan McLellan
 
4
# License:: Apache License, Version 2.0
 
5
#
 
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
 
9
 
10
#     http://www.apache.org/licenses/LICENSE-2.0
 
11
 
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.
 
17
#
 
18
 
 
19
require File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "spec_helper"))
 
20
 
 
21
describe Chef::Resource::Route do
 
22
 
 
23
  before(:each) do
 
24
    @resource = Chef::Resource::Route.new("10.0.0.10")
 
25
  end  
 
26
 
 
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)
 
30
  end
 
31
  
 
32
  it "should have a name" do
 
33
    @resource.name.should eql("10.0.0.10")
 
34
  end
 
35
  
 
36
  it "should have a default action of 'add'" do
 
37
    @resource.action.should eql(:add)
 
38
  end
 
39
  
 
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)
 
44
  end
 
45
    
 
46
  it "should use the object name as the target by default" do
 
47
    @resource.target.should eql("10.0.0.10")
 
48
  end
 
49
  
 
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")
 
53
  end
 
54
 
 
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")
 
58
  end
 
59
 
 
60
  it "should allow you to specify the metric" do
 
61
    @resource.metric 10
 
62
    @resource.metric.should eql(10)
 
63
  end
 
64
 
 
65
  it "should allow you to specify the device" do
 
66
    @resource.device "eth0"
 
67
    @resource.device.should eql("eth0")
 
68
  end
 
69
 
 
70
  it "should allow you to specify the route type" do
 
71
    @resource.route_type "host"
 
72
    @resource.route_type.should eql(:host)
 
73
  end
 
74
  
 
75
  it "should default to a host route type" do
 
76
    @resource.route_type.should eql(:host)
 
77
  end
 
78
  
 
79
  it "should accept a net route type" do
 
80
    @resource.route_type :net
 
81
    @resource.route_type.should eql(:net)
 
82
  end
 
83
  
 
84
  it "should reject any other route_type but :host and :net" do
 
85
    lambda { @resource.route_type "lolcat" }.should raise_error(ArgumentError)
 
86
  end
 
87
  
 
88
end