Sha256: 1ba2f75a9e2bcf9ebd166f810b1c1dcfed37cb3a8cf2571611ed03b9f0824c07

Contents?: true

Size: 1.17 KB

Versions: 10

Compression:

Stored size: 1.17 KB

Contents

# frozen_string_literal: true

require 'spec_helper'

module Grape
  module DSL
    module CallbacksSpec
      class Dummy
        include Grape::DSL::Callbacks
      end
    end

    describe Callbacks do
      subject { Class.new(CallbacksSpec::Dummy) }
      let(:proc) { ->() {} }

      describe '.before' do
        it 'adds a block to "before"' do
          expect(subject).to receive(:namespace_stackable).with(:befores, proc)
          subject.before(&proc)
        end
      end

      describe '.before_validation' do
        it 'adds a block to "before_validation"' do
          expect(subject).to receive(:namespace_stackable).with(:before_validations, proc)
          subject.before_validation(&proc)
        end
      end

      describe '.after_validation' do
        it 'adds a block to "after_validation"' do
          expect(subject).to receive(:namespace_stackable).with(:after_validations, proc)
          subject.after_validation(&proc)
        end
      end

      describe '.after' do
        it 'adds a block to "after"' do
          expect(subject).to receive(:namespace_stackable).with(:afters, proc)
          subject.after(&proc)
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
grape-1.5.3 spec/grape/dsl/callbacks_spec.rb
grape-1.5.2 spec/grape/dsl/callbacks_spec.rb
grape-1.5.1 spec/grape/dsl/callbacks_spec.rb
grape-1.5.0 spec/grape/dsl/callbacks_spec.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/grape-1.4.0/spec/grape/dsl/callbacks_spec.rb
grape-1.4.0 spec/grape/dsl/callbacks_spec.rb
grape-1.3.3 spec/grape/dsl/callbacks_spec.rb
grape-1.3.2 spec/grape/dsl/callbacks_spec.rb
grape-1.3.1 spec/grape/dsl/callbacks_spec.rb
grape-1.3.0 spec/grape/dsl/callbacks_spec.rb