Sha256: b97260042726dd87920fa4c054516c9dd87f34114c56fb837a2ba9625d5d3272

Contents?: true

Size: 1.85 KB

Versions: 2

Compression:

Stored size: 1.85 KB

Contents

require 'spec_helper'
require 'ronin/exploits/metadata/cookie_param'

describe Ronin::Exploits::Metadata::CookieParam do
  describe ".cookie_param" do
    subject { test_class }

    context "and when cookie_param is not set in the class" do
      module TestMetadataCookieParam
        class WithNoCookieParamSet
          include Ronin::Exploits::Metadata::CookieParam
        end
      end

      let(:test_class) { TestMetadataCookieParam::WithNoCookieParamSet }

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

    context "and when cookie_param is set in the class" do
      module TestMetadataCookieParam
        class WithCookieParamSet
          include Ronin::Exploits::Metadata::CookieParam

          cookie_param 'test'
        end
      end

      let(:test_class) { TestMetadataCookieParam::WithCookieParamSet }

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

    context "but when the cookie_param was set in the superclass" do
      module TestMetadataCookieParam
        class InheritsItsCookieParam < WithCookieParamSet
        end
      end

      let(:test_class) { TestMetadataCookieParam::InheritsItsCookieParam }

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

      context "but the cookie_param is overridden in the sub-class" do
        module TestMetadataCookieParam
          class OverridesItsInheritedCookieParam < WithCookieParamSet
            cookie_param "test2"
          end
        end

        let(:test_class) do
          TestMetadataCookieParam::OverridesItsInheritedCookieParam
        end

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