Class: RSpec::Core::Example

Inherits:
Object show all
Defined in:
lib/appmap/rspec.rb

Class Method Summary collapse

Class Method Details

.new(*arguments, &block) ⇒ Object



249
250
251
252
253
254
255
# File 'lib/appmap/rspec.rb', line 249

def self.new(*arguments, &block)
  warn "Wrapping example_block for #{name}" if AppMap::RSpec::LOG
  allocate.tap do |obj|
    arguments[arguments.length - 1] = wrap_example_block(obj, arguments.last) if arguments.last.is_a?(Proc)
    obj.send :initialize, *arguments, &block
  end
end

.wrap_example_block(example, fn) ⇒ Object



237
238
239
240
241
242
243
244
245
246
# File 'lib/appmap/rspec.rb', line 237

def wrap_example_block(example, fn)
  proc do
    AppMap::RSpec.begin_spec example
    begin
      instance_exec(&fn)
    ensure
      AppMap::RSpec.end_spec example, exception: $!
    end
  end
end