require 'spec_helper' require 'ronin/exploits/metadata/url_path' describe Ronin::Exploits::Metadata::URLPath do describe ".url_path" do subject { test_class } context "and when url_path is not set in the class" do module TestMetadataURLPath class WithNoURLPathSet include Ronin::Exploits::Metadata::URLPath end end let(:test_class) { TestMetadataURLPath::WithNoURLPathSet } it "must default to '/'" do expect(subject.url_path).to eq('/') end end context "and when url_path is set in the class" do module TestMetadataURLPath class WithURLPathSet include Ronin::Exploits::Metadata::URLPath url_path '/test' end end let(:test_class) { TestMetadataURLPath::WithURLPathSet } it "must return the set url_path" do expect(subject.url_path).to eq("/test") end end context "but when the url_path was set in the superclass" do module TestMetadataURLPath class InheritsItsURLPath < WithURLPathSet end end let(:test_class) { TestMetadataURLPath::InheritsItsURLPath } it "must return the url_path set in the superclass" do expect(subject.url_path).to eq("/test") end context "but the url_path is overridden in the sub-class" do module TestMetadataURLPath class OverridesItsInheritedURLPath < WithURLPathSet url_path "/test2" end end let(:test_class) do TestMetadataURLPath::OverridesItsInheritedURLPath end it "must return the url_path set in the sub-class" do expect(subject.url_path).to eq("/test2") end end end end end