Sha256: ec011c69c8e2577b44abb302c5881adc77f47a05ff35acd900c32f9a484283b5

Contents?: true

Size: 1.42 KB

Versions: 9

Compression:

Stored size: 1.42 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../../spec_helper'
require 'puppet/indirector/envelope'

describe Puppet::Indirector::Envelope do
    before do
        @instance = Object.new
        @instance.extend(Puppet::Indirector::Envelope)
    end

    it "should have an expiration accessor" do
        @instance.expiration = "testing"
        @instance.expiration.should == "testing"
    end

    it "should have an expiration setter" do
        @instance.should respond_to(:expiration=)
    end

    it "should have a means of testing whether it is expired" do
        @instance.should respond_to(:expired?)
    end

    describe "when testing if it is expired" do
        it "should return false if there is no expiration set" do
            @instance.should_not be_expired
        end

        it "should return true if the current date is after the expiration date" do
            @instance.expiration = Time.now - 10
            @instance.should be_expired
        end

        it "should return false if the current date is prior to the expiration date" do
            @instance.expiration = Time.now + 10
            @instance.should_not be_expired
        end

        it "should return false if the current date is equal to the expiration date" do
            now = Time.now
            Time.stubs(:now).returns(now)
            @instance.expiration = now
            @instance.should_not be_expired
        end
    end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
puppet-0.25.5 spec/unit/indirector/envelope.rb
puppet-0.25.4 spec/unit/indirector/envelope.rb
puppet-0.25.3 spec/unit/indirector/envelope.rb
puppet-0.24.9 spec/unit/indirector/envelope.rb
puppet-0.25.2 spec/unit/indirector/envelope.rb
puppet-0.25.1 spec/unit/indirector/envelope.rb
puppet-0.25.0 spec/unit/indirector/envelope.rb
puppet-0.24.7 spec/unit/indirector/envelope.rb
puppet-0.24.8 spec/unit/indirector/envelope.rb