require 'spec_helper' require 'ronin/exploits/metadata/shouts' describe Ronin::Exploits::Metadata::Shouts do describe ".shouts" do subject { test_class } context "and when shouts is not set in the class" do module TestMetadataShouts class WithNoShoutsSet include Ronin::Exploits::Metadata::Shouts end end let(:test_class) { TestMetadataShouts::WithNoShoutsSet } it "must default to []" do expect(subject.shouts).to eq([]) end end context "and when shouts is set in the class" do module TestMetadataShouts class WithShoutsSet include Ronin::Exploits::Metadata::Shouts shouts [ 'https://example.com/link1', 'https://example.com/link2' ] end end let(:test_class) { TestMetadataShouts::WithShoutsSet } it "must return the set shouts" do expect(subject.shouts).to eq( [ 'https://example.com/link1', 'https://example.com/link2' ] ) end end context "but when the shouts was set in the superclass" do module TestMetadataShouts class InheritsItsShouts < WithShoutsSet include Ronin::Exploits::Metadata::Shouts end end let(:test_class) { TestMetadataShouts::InheritsItsShouts } it "must return the shouts set in the superclass" do expect(subject.shouts).to eq( [ 'https://example.com/link1', 'https://example.com/link2' ] ) end context "but the shouts is overridden in the sub-class" do module TestMetadataShouts class OverridesItsInheritedShouts < WithShoutsSet include Ronin::Exploits::Metadata::Shouts shouts [ 'https://example.com/link3' ] end end let(:test_class) do TestMetadataShouts::OverridesItsInheritedShouts end it "must return the shouts in the sub-class and the superclass" do expect(subject.shouts).to eq( [ 'https://example.com/link1', 'https://example.com/link2', 'https://example.com/link3' ] ) end it "must not modify the superclass'es shouts" do expect(subject.superclass.shouts).to eq( [ 'https://example.com/link1', 'https://example.com/link2' ] ) end end end end end