Sha256: 669623d842dfa56de3f3305b78062365e14518b3c6fc3e3f26c989c0c0f00936

Contents?: true

Size: 1.82 KB

Versions: 2

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'
require 'ronin/exploits/metadata/header_name'

describe Ronin::Exploits::Metadata::HeaderName do
  describe ".header_name" do
    subject { test_class }

    context "and when header_name is not set in the class" do
      module TestMetadataHeaderName
        class WithNoHeaderNameSet
          include Ronin::Exploits::Metadata::HeaderName
        end
      end

      let(:test_class) { TestMetadataHeaderName::WithNoHeaderNameSet }

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

    context "and when header_name is set in the class" do
      module TestMetadataHeaderName
        class WithHeaderNameSet
          include Ronin::Exploits::Metadata::HeaderName

          header_name 'test'
        end
      end

      let(:test_class) { TestMetadataHeaderName::WithHeaderNameSet }

      it "must return the set header_name" do
        expect(subject.header_name).to eq("test")
      end
    end

    context "but when the header_name was set in the superclass" do
      module TestMetadataHeaderName
        class InheritsItsHeaderName < WithHeaderNameSet
        end
      end

      let(:test_class) { TestMetadataHeaderName::InheritsItsHeaderName }

      it "must return the header_name set in the superclass" do
        expect(subject.header_name).to eq("test")
      end

      context "but the header_name is overridden in the sub-class" do
        module TestMetadataHeaderName
          class OverridesItsInheritedHeaderName < WithHeaderNameSet
            header_name "test2"
          end
        end

        let(:test_class) do
          TestMetadataHeaderName::OverridesItsInheritedHeaderName
        end

        it "must return the header_name set in the sub-class" do
          expect(subject.header_name).to eq("test2")
        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/header_name_spec.rb
ronin-exploits-1.0.0.beta1 spec/metadata/header_name_spec.rb