~ubuntu-branches/ubuntu/oneiric/puppet/oneiric-security

« back to all changes in this revision

Viewing changes to spec/unit/indirector/envelope.rb

  • Committer: Bazaar Package Importer
  • Author(s): Micah Anderson
  • Date: 2008-07-26 15:43:45 UTC
  • mto: (3.1.1 lenny) (1.3.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080726154345-1fmgo76b4l72ulvc
ImportĀ upstreamĀ versionĀ 0.24.5

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env ruby
 
2
 
 
3
require File.dirname(__FILE__) + '/../../spec_helper'
 
4
require 'puppet/indirector/envelope'
 
5
 
 
6
describe Puppet::Indirector::Envelope do
 
7
    before do
 
8
        @instance = Object.new
 
9
        @instance.extend(Puppet::Indirector::Envelope)
 
10
    end
 
11
 
 
12
    it "should have an expiration accessor" do
 
13
        @instance.expiration = "testing"
 
14
        @instance.expiration.should == "testing"
 
15
    end
 
16
 
 
17
    it "should have an expiration setter" do
 
18
        @instance.should respond_to(:expiration=)
 
19
    end
 
20
 
 
21
    it "should have a means of testing whether it is expired" do
 
22
        @instance.should respond_to(:expired?)
 
23
    end
 
24
 
 
25
    describe "when testing if it is expired" do
 
26
        it "should return false if there is no expiration set" do
 
27
            @instance.should_not be_expired
 
28
        end
 
29
 
 
30
        it "should return true if the current date is after the expiration date" do
 
31
            @instance.expiration = Time.now - 10
 
32
            @instance.should be_expired
 
33
        end
 
34
 
 
35
        it "should return false if the current date is prior to the expiration date" do
 
36
            @instance.expiration = Time.now + 10
 
37
            @instance.should_not be_expired
 
38
        end
 
39
 
 
40
        it "should return false if the current date is equal to the expiration date" do
 
41
            now = Time.now
 
42
            Time.stubs(:now).returns(now)
 
43
            @instance.expiration = now
 
44
            @instance.should_not be_expired
 
45
        end
 
46
    end
 
47
end