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