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) ⇒ 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.
44 45 46 47 48 49 50 |
# File 'lib/mutineer/test_runners/rspec.rb', line 44 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) ⇒ Integer
Runs the given RSpec files.
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/mutineer/test_runners/rspec.rb', line 20 def self.run(spec_files) require_rspec! ::RSpec::Core::Runner.disable_autorun! ::RSpec.reset sink = StringIO.new orig_out = $stdout orig_err = $stderr $stdout = sink $stderr = sink begin status = ::RSpec::Core::Runner.run(["--no-color", *Array(spec_files)], sink, sink) ensure $stdout = orig_out $stderr = orig_err end status.zero? ? 0 : 1 end |