Sha256: 2e78b1eef4c3b6433ed6f3b51978b1b142de39c9df75a164effb222e2b07b94f
Contents?: true
Size: 1.12 KB
Versions: 7
Compression:
Stored size: 1.12 KB
Contents
# frozen_string_literal: true require "spec_helpers" describe Wayfarer::Routing::Matchers::Path, mri: true do let(:route) { Wayfarer::Routing::RootRoute.new } subject(:matcher) { Wayfarer::Routing::Matchers::Path.new(path, route) } describe "#match?" do context "with matching URL" do let(:path) { "/{alpha}/{beta}" } it "returns true" do expect(matcher).to match(Addressable::URI.parse("http://example.com/foo/bar")) end end context "with mismatching URL" do let(:path) { "/{alpha}/{beta}" } it "returns false" do expect(matcher).not_to match(Addressable::URI.parse("http://example.com/foo")) end end context "with mismatching URL" do let(:path) { "/" } it "returns false" do expect(matcher).not_to match(Addressable::URI.parse("http://example.com/foo")) end end end describe "#params" do let(:path) { "/{alpha}/{beta}" } it "returns the correct parameters" do url = Addressable::URI.parse("http://example.com/foo/bar") expect(matcher.params(url)).to eq("alpha" => "foo", "beta" => "bar") end end end
Version data entries
7 entries across 7 versions & 1 rubygems