Module: Grape::Testing::ClassMethods

Included in:
Endpoint
Defined in:
lib/grape/testing.rb

Instance Method Summary collapse

Instance Method Details

#before_each(&block) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
17
18
# File 'lib/grape/testing.rb', line 13

def before_each(&block)
  raise ArgumentError, 'a block is required' unless block

  @before_each ||= []
  @before_each << block
end

#reset_before_eachObject



20
21
22
# File 'lib/grape/testing.rb', line 20

def reset_before_each
  @before_each&.clear
end

#run_before_each(endpoint) ⇒ Object



24
25
26
27
# File 'lib/grape/testing.rb', line 24

def run_before_each(endpoint)
  superclass.run_before_each(endpoint) unless self == Grape::Endpoint
  @before_each&.each { |blk| blk.call(endpoint) }
end