Sha256: 6a7a8eef62e8687d636d87ce2c7efad0ed7bb39b765a837629c8bd526f5c087b

Contents?: true

Size: 1.66 KB

Versions: 3

Compression:

Stored size: 1.66 KB

Contents

# frozen_string_literal: true

require "spec_helpers"

describe "Pages" 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 { host test_app_host, to: :index }

        def index
          expect(page.url).to eq("http://test:9876/git-scm.com/book/en/v2.html")
          expect(page.status_code).to be(200)
          expect(page.body).not_to be_empty
          expect(page.headers.count).to be(9)

          expect(page.meta.links.all.count).to be(157)
          expect(page.meta.links.internal.count).to be(102)
          expect(page.meta.links.external.count).to be(55)
        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 { host test_app_host, to: DummyHandler }

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

          route { to :index }

          def index
            expect(page.url).to eq("http://test:9876/git-scm.com/book/en/v2.html")
            expect(page.status_code).to be(200)
            expect(page.body).not_to be_empty
            expect(page.headers.count).to be(9)

            expect(page.meta.links.all.count).to be(157)
            expect(page.meta.links.internal.count).to be(102)
            expect(page.meta.links.external.count).to be(55)
          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/page_spec.rb
wayfarer-0.4.5 spec/integration/page_spec.rb
wayfarer-0.4.4 spec/integration/page_spec.rb