Sha256: c8b256ed258baa6591518d11efa6043c5f0dae5e7081ef9533d5dbb437185605

Contents?: true

Size: 1.91 KB

Versions: 2

Compression:

Stored size: 1.91 KB

Contents

require 'spec_helper'
require 'ronin/exploits/metadata/default_filename'

describe Ronin::Exploits::Metadata::DefaultFilename do
  module TestMetadataDefaultFilename
    class WithNoDefaultFilenameSet
      include Ronin::Exploits::Metadata::DefaultFilename
    end

    class WithDefaultFilenameSet
      include Ronin::Exploits::Metadata::DefaultFilename

      default_filename 'exploit.docx'
    end

    class InheritsItsDefaultFilename < WithDefaultFilenameSet
      include Ronin::Exploits::Metadata::DefaultFilename
    end

    class OverridesItsInheritedDefaultFilename < WithDefaultFilenameSet
      include Ronin::Exploits::Metadata::DefaultFilename

      default_filename 'exploit2.docx'
    end
  end

  describe ".default_filename" do
    subject { test_class }

    context "and when default filename is not set in the class" do
      let(:test_class) { TestMetadataDefaultFilename::WithNoDefaultFilenameSet }

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

    context "and when default filename is set in the class" do
      let(:test_class) { TestMetadataDefaultFilename::WithDefaultFilenameSet }

      it "must return the set default_filename" do
        expect(subject.default_filename).to eq('exploit.docx')
      end
    end

    context "but when the default filename was set in the superclass" do
      let(:test_class) { TestMetadataDefaultFilename::InheritsItsDefaultFilename }

      it "must return the default filename set in the superclass" do
        expect(subject.default_filename).to eq('exploit.docx')
      end

      context "but the default filename is overridden in the sub-class" do
        let(:test_class) { TestMetadataDefaultFilename::OverridesItsInheritedDefaultFilename }

        it "must return the default filename set in the sub-class" do
          expect(subject.default_filename).to eq('exploit2.docx')
        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_filename_spec.rb
ronin-exploits-1.0.0.beta1 spec/metadata/default_filename_spec.rb