Sha256: 01763e16a0c198cfade3df29d05f4592e79b80fb034398714205e05cb5a5b066
Contents?: true
Size: 1.19 KB
Versions: 7
Compression:
Stored size: 1.19 KB
Contents
# frozen_string_literal: true require "spec_helpers" describe Wayfarer::Routing::Matchers::Host do subject(:matcher) { Wayfarer::Routing::Matchers::Host.new(str_or_regexp) } describe "#matches?" do describe "String matching" do let(:str_or_regexp) { "example.com" } context "with matching URL" do let(:url) { Addressable::URI.parse("http://example.com/foo/bar") } it "returns true" do expect(matcher).to match(url) end end context "with mismatching URL" do let(:url) { Addressable::URI.parse("http://google.com/bar/qux") } it "returns false" do expect(matcher).not_to match(url) end end end describe "RegExp matching" do let(:str_or_regexp) { /example.com/ } context "with matching URL" do let(:url) { Addressable::URI.parse("http://sub.example.com") } it "returns true" do expect(matcher).to match(url) end end context "with mismatching URL" do let(:url) { Addressable::URI.parse("http://example.sub.com") } it "returns false" do expect(matcher).not_to match(url) end end end end end
Version data entries
7 entries across 7 versions & 1 rubygems