Sha256: af3f6cfbab88a1d408af7ffc860760cfb99752f821ade9369760032569fbd77f

Contents?: true

Size: 1.19 KB

Versions: 3

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true

require "spec_helpers"

describe "URL parameters" do
  let(:url) { test_app_path("git-scm.com/book/en/v2.html") }

  describe Wayfarer::Base do
    specify do
      class self.class::DummyJob < Wayfarer::Base
        extend SpecHelpers
        include RSpec::Matchers

        route do
          to :index, host: test_app_host do
            path "git-scm.com/book/:lang/:file"
          end
        end

        def index
          expect(params).to eq("lang" => "en", "file" => "v2.html")
        end
      end

      self.class::DummyJob.crawl(url)
      perform_enqueued_jobs
    end
  end

  describe Wayfarer::Handler do
    specify do
      class self.class::DummyJob < Wayfarer::Base
        extend SpecHelpers

        route do
          to DummyHandler, host: test_app_host do
            path "git-scm.com/book/:lang/:file"
          end
        end

        class DummyHandler < Wayfarer::Handler
          include RSpec::Matchers

          route { to :index }

          def index
            expect(params).to eq("lang" => "en", "file" => "v2.html")
          end
        end
      end

      self.class::DummyJob.crawl(url)
      perform_enqueued_jobs
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wayfarer-0.4.6 spec/integration/params_spec.rb
wayfarer-0.4.5 spec/integration/params_spec.rb
wayfarer-0.4.4 spec/integration/params_spec.rb