Sha256: 4f837b44e491e4067b5d348358f06fe3bcbd25950e426082af351d31d30d54fb

Contents?: true

Size: 1.72 KB

Versions: 2

Compression:

Stored size: 1.72 KB

Contents

require 'spec_helper'
require 'ronin/exploits/metadata/default_port'

describe Ronin::Exploits::Metadata::DefaultPort do
  module TestMetadataDefaultPort
    class WithNoDefaultPortSet
      include Ronin::Exploits::Metadata::DefaultPort
    end

    class WithDefaultPortSet
      include Ronin::Exploits::Metadata::DefaultPort

      default_port 111
    end

    class InheritsItsDefaultPort < WithDefaultPortSet
      include Ronin::Exploits::Metadata::DefaultPort
    end

    class OverridesItsInheritedDefaultPort < WithDefaultPortSet
      include Ronin::Exploits::Metadata::DefaultPort

      default_port 222
    end
  end

  describe ".default_port" do
    subject { test_class }

    context "and when default port is not set in the class" do
      let(:test_class) { TestMetadataDefaultPort::WithNoDefaultPortSet }

      it "must default to nil" do
        expect(subject.default_port).to be(nil)
      end
    end

    context "and when default port is set in the class" do
      let(:test_class) { TestMetadataDefaultPort::WithDefaultPortSet }

      it "must return the set default_port" do
        expect(subject.default_port).to eq(111)
      end
    end

    context "but when the default port was set in the superclass" do
      let(:test_class) { TestMetadataDefaultPort::InheritsItsDefaultPort }

      it "must return the default port set in the superclass" do
        expect(subject.default_port).to eq(111)
      end

      context "but the default port is overridden in the sub-class" do
        let(:test_class) { TestMetadataDefaultPort::OverridesItsInheritedDefaultPort }

        it "must return the default port set in the sub-class" do
          expect(subject.default_port).to eq(222)
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ronin-exploits-1.0.0.beta2 spec/metadata/default_port_spec.rb
ronin-exploits-1.0.0.beta1 spec/metadata/default_port_spec.rb