Class: RSpec::Loop
- Inherits:
-
Object
- Object
- RSpec::Loop
- Defined in:
- lib/rspec/loop.rb,
lib/rspec/loop/version.rb,
lib/rspec/loop/formatter.rb
Defined Under Namespace
Classes: Formatter
Constant Summary collapse
- DEFAULT_LOOP_COUNT =
3- VERSION =
"0.2.1"
Instance Attribute Summary collapse
-
#procsy ⇒ Object
readonly
Returns the value of attribute procsy.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(procsy) ⇒ Loop
constructor
A new instance of Loop.
- #run ⇒ Object
Constructor Details
#initialize(procsy) ⇒ Loop
Returns a new instance of Loop.
28 29 30 |
# File 'lib/rspec/loop.rb', line 28 def initialize(procsy) @procsy = procsy end |
Instance Attribute Details
#procsy ⇒ Object (readonly)
Returns the value of attribute procsy.
26 27 28 |
# File 'lib/rspec/loop.rb', line 26 def procsy @procsy end |
Class Method Details
.setup ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/rspec/loop.rb', line 12 def setup RSpec.configure do |config| config.add_setting :default_loop_count, default: DEFAULT_LOOP_COUNT config.around(:example) do |example| RSpec::Loop.new(example).run end end RSpec::Core::Example::Procsy.include(RSpecExampleProcsyLoop) RSpec::Core::Example.include(RSpecExampleLoop) end |
Instance Method Details
#run ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/rspec/loop.rb', line 32 def run(...) loop_results = [] @procsy.[:loop_results] = loop_results @procsy.loop_count.times do @procsy.exception = nil @procsy.reporter.notify(:example_iteration_started, RSpec::Core::Notifications::ExampleNotification.for(@procsy)) result = Core::Example::ExecutionResult.new result.started_at = Time.now @procsy.run(...) result.finished_at = Time.now result.run_time = result.finished_at - result.started_at result.exception = @procsy.exception.dup result. = @procsy.execution_result..dup result.status = (result. && :pending) || (result.exception && :failed) || :passed loop_results << result @procsy.[:loop_last_result] = result @procsy.reporter.notify(:example_iteration_finished, RSpec::Core::Notifications::ExampleNotification.for(@procsy)) end @procsy.exception = summarize_exceptions(loop_results) = loop_results.map(&:pending_message).compact.first @procsy.execution_result.status = (@procsy.exception && :failed) || ( && :pending) || :passed @procsy.execution_result. = @procsy.execution_result.exception = @procsy.exception @procsy.execution_result.started_at = loop_results.first.started_at @procsy.execution_result.finished_at = loop_results.last.finished_at @procsy.execution_result.run_time = @procsy.execution_result.finished_at - @procsy.execution_result.started_at end |