Sha256: b21f09d2e21af2efaec734752e9f8d20e930173b01f387d4090a72b326d2c95e

Contents?: true

Size: 1.19 KB

Versions: 4

Compression:

Stored size: 1.19 KB

Contents

#! /usr/bin/env ruby -S rspec
require 'spec_helper'

require 'puppet/util/network_device/transport/base'

describe Puppet::Util::NetworkDevice::Transport::Base do
  class TestTransport < Puppet::Util::NetworkDevice::Transport::Base
  end

  before(:each) do
    @transport = TestTransport.new
  end

  describe "when sending commands" do
    it "should send the command to the telnet session" do
      @transport.expects(:send).with("line")
      @transport.command("line")
    end

    it "should expect an output matching the given prompt" do
      @transport.expects(:expect).with(/prompt/)
      @transport.command("line", :prompt => /prompt/)
    end

    it "should expect an output matching the default prompt" do
      @transport.default_prompt = /defprompt/
      @transport.expects(:expect).with(/defprompt/)
      @transport.command("line")
    end

    it "should yield telnet output to the given block" do
      @transport.expects(:expect).yields("output")
      @transport.command("line") { |out| out.should == "output" }
    end

    it "should return telnet output to the caller" do
      @transport.expects(:expect).returns("output")
      @transport.command("line").should == "output"
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppet-3.0.0.rc8 spec/unit/util/network_device/transport/base_spec.rb
puppet-3.0.0.rc7 spec/unit/util/network_device/transport/base_spec.rb
puppet-3.0.0.rc5 spec/unit/util/network_device/transport/base_spec.rb
puppet-3.0.0.rc4 spec/unit/util/network_device/transport/base_spec.rb