Sha256: c88df02c4dadf8fc4c5ad70d8a486ae843aa2b10140c6c4f23d46846215998a8
Contents?: true
Size: 1.84 KB
Versions: 3
Compression:
Stored size: 1.84 KB
Contents
# frozen_string_literal: true require "spec_helpers" describe "Callbacks" 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 } attr_accessor :callbacks_fired before_fetch do self.callbacks_fired = %i[before_fetch] end before_action do callbacks_fired.push(:before_action) end after_batch do expect(callbacks_fired).to eq(%i[before_fetch before_action]) end def index; 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 include RSpec::Matchers route { host test_app_host, to: DummyHandler } attr_accessor :callbacks_fired before_fetch do self.callbacks_fired = %i[before_fetch_job] end before_action do callbacks_fired.push(:before_action_job) end after_batch do expect(callbacks_fired).to eq(%i[before_fetch_job before_action_job]) end class DummyHandler < Wayfarer::Handler include RSpec::Matchers route { to :index } attr_accessor :callbacks_fired before_fetch do raise "before_fetch ran in handler" end before_action do self.callbacks_fired = %i[before_action_handler] end def index expect(callbacks_fired).to eq(%i[before_action_handler]) 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/callbacks_spec.rb |
wayfarer-0.4.5 | spec/integration/callbacks_spec.rb |
wayfarer-0.4.4 | spec/integration/callbacks_spec.rb |