Sha256: 55a82062a26ffacfe8800579716e4b02cb3908f8e78cec39eb56872cd5123028

Contents?: true

Size: 1.36 KB

Versions: 1

Compression:

Stored size: 1.36 KB

Contents

require 'spec_helper'
require 'ronin/post_ex/sessions/session'

describe Ronin::PostEx::Sessions::Session do
  describe "#name" do
    context "when #name is set" do
      module TestSession
        class SessionWithNameSet < Ronin::PostEx::Sessions::Session

          def initialize(name)
            @name = name
          end

        end
      end

      let(:name) { 'example-session' }

      subject { TestSession::SessionWithNameSet.new(name) }

      it "must return @name" do
        expect(subject.name).to eq(name)
      end
    end

    context "when @name is not set" do
      module TestSession
        class SessionWithoutNameSet < Ronin::PostEx::Sessions::Session
        end
      end

      subject { TestSession::SessionWithoutNameSet.new }

      it do
        expect {
          subject.name
        }.to raise_error(NotImplementedError,"#{subject.class}#name was not set")
      end
    end
  end

  describe "#system" do
    it "must return a Ronin::PostEx::System object" do
      expect(subject.system).to be_kind_of(Ronin::PostEx::System)
    end

    it "must return the same object each time" do
      expect(subject.system).to be(subject.system)
    end
  end

  describe "#to_s" do
    let(:name) { "host:port" }

    it "must call #name" do
      expect(subject).to receive(:name).and_return(name)

      expect(subject.to_s).to be(name)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
ronin-post_ex-0.1.0.beta1 spec/sessions/session_spec.rb