Sha256: ee1d255c25b7550b7d3190ebdf6d15d40ec6c0f27913bbb75465861faa7930cb
Contents?: true
Size: 1.24 KB
Versions: 7
Compression:
Stored size: 1.24 KB
Contents
# frozen_string_literal: true require "spec_helpers" describe Wayfarer::Routing::Route do subject(:root) { Wayfarer::Routing::RootRoute.new } describe "#invoke" do context "with matching matchers" do it "returns a Match" do root.host "example.com", to: :overridden do path "/:a/:b" do to :overrider, query: { page: 42 } end end result = root.invoke(Addressable::URI.parse("http://example.com/foo/bar?page=42")) expect(result).to be_a(Wayfarer::Routing::Result::Match) expect(result.action).to be(:overrider) expect(result.params).to eq({ "a" => "foo", "b" => "bar", "page" => "42" }) end end context "with mismatching matchers" do it "returns a Mismatch" do root.host "example.com", to: :overridden do path "/:a/:b" do query({ page: 42 }, { to: :overrider }) end end result = root.invoke(Addressable::URI.parse("http://w3c.org/foo/bar?page=42")) expect(result).to be_a(Wayfarer::Routing::Result::Mismatch) end end end end
Version data entries
7 entries across 7 versions & 1 rubygems