Sha256: 160110cf579d226600a4b89a28b65249614dc2a9e656c4c4d93686d4d88ac513

Contents?: true

Size: 1.14 KB

Versions: 3

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

require "spec_helpers"

describe "Steering" 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 RSpec::Matchers

        route do |a, b|
          expect(a).to eq("foobar")
          expect(b).to eq("barqux")
        end

        steer do |task|
          [task.batch, "barqux"]
        end
      end

      self.class::DummyJob.crawl(url, batch: "foobar")
      perform_enqueued_jobs
    end
  end

  describe Wayfarer::Handler do
    specify do
      class self.class::DummyJob < Wayfarer::Base
        route do |_a, _b|
          to DummyHandler
        end

        steer do |_task|
          [123, "barqux"]
        end

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

          route do |a, b|
            expect(a).to eq("foobar")
            expect(b).to eq("fooz")
          end

          steer do |task|
            [task.batch, "fooz"]
          end
        end
      end

      self.class::DummyJob.crawl(url, batch: "foobar")
      perform_enqueued_jobs
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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