Class: Polyrun::Quick::ExampleRunner

Inherits:
Object
  • Object
show all
Includes:
Assertions, Matchers
Defined in:
lib/polyrun/quick/example_runner.rb

Overview

Per-example execution: merged lets, hooks, assertions, optional Capybara::DSL.

Instance Method Summary collapse

Methods included from Matchers

#be_falsey, #be_truthy, #eq, #expect, #include, #match

Methods included from Assertions

#assert, #assert_equal, #assert_nil, #assert_raises

Constructor Details

#initialize(reporter) ⇒ ExampleRunner

Returns a new instance of ExampleRunner.



12
13
14
15
# File 'lib/polyrun/quick/example_runner.rb', line 12

def initialize(reporter)
  @reporter = reporter
  @_let_cache = {}
end

Instance Method Details

#run(group_name:, description:, ancestor_chain:, block:) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/polyrun/quick/example_runner.rb', line 17

def run(group_name:, description:, ancestor_chain:, block:)
  @_let_cache = {}
  merge_lets_from_chain(ancestor_chain)
  define_let_methods!
  run_let_bangs_from_chain
  extend_capybara_if_enabled!
  begin
    run_before_hooks_from_chain(ancestor_chain)
    instance_eval(&block)
    @reporter.pass(group_name, description)
  rescue AssertionFailed => e
    @reporter.fail(group_name, description, e)
  rescue => e
    @reporter.error(group_name, description, e)
  ensure
    run_after_hooks_from_chain(ancestor_chain)
    reset_capybara_if_enabled!
    @_let_cache = {}
  end
end