Module: Mutineer::TestRunners::RSpec
- Defined in:
- lib/mutineer/test_runners/rspec.rb
Overview
Child-process-only RSpec runner.
Mirrors MinitestIntegration's contract: run the given spec files and return 0 (all passed) or 1 (any failure).
Class Method Summary collapse
-
.require_rspec! ⇒ Object
private
Requires rspec-core from the project under test.
-
.run(spec_files, stop_at_first_failure: false) ⇒ Integer
Runs the given RSpec files.
Class Method Details
.require_rspec! ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Requires rspec-core from the project under test.
42 43 44 45 46 47 48 |
# File 'lib/mutineer/test_runners/rspec.rb', line 42 def self.require_rspec! require "rspec/core" rescue LoadError raise Mutineer::FrameworkUnavailable, "framework 'rspec' requested but rspec is not available; " \ "add rspec to the project under test (its bundle), then retry" end |
.run(spec_files, stop_at_first_failure: false) ⇒ Integer
Runs the given RSpec files.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/mutineer/test_runners/rspec.rb', line 22 def self.run(spec_files, stop_at_first_failure: false) require_rspec! ::RSpec::Core::Runner.disable_autorun! ::RSpec.reset # The sink takes RSpec's own formatter output. Spec output is not # silenced here: the fork boundary that calls this method has already # pointed stdout at File::NULL (see ChildStdout). sink = StringIO.new args = ["--no-color"] args << "--fail-fast" if stop_at_first_failure status = ::RSpec::Core::Runner.run([*args, *Array(spec_files)], sink, sink) status.zero? ? 0 : 1 end |