Module: FactorySloth::SpecRunner
- Defined in:
- lib/factory_sloth/spec_runner.rb
Defined Under Namespace
Classes: Result
Class Method Summary collapse
Class Method Details
.call(spec_path, spec_code, line: nil) ⇒ Object
5 6 7 8 9 10 11 12 13 |
# File 'lib/factory_sloth/spec_runner.rb', line 5 def self.call(spec_path, spec_code, line: nil) path = File.join(tmpdir, spec_path) FileUtils.mkdir_p(File.dirname(path)) File.write(path, spec_code) path_arg = [path, line].compact.map(&:to_s).join(':') command = "bundle exec rspec #{path_arg} --fail-fast --order defined 2>&1" output, process_status = Open3.capture2(command) Result.new(output: output, process_status: process_status) end |
.tmpdir ⇒ Object
21 22 23 24 25 26 27 |
# File 'lib/factory_sloth/spec_runner.rb', line 21 def self.tmpdir @tmpdir ||= begin dir = Dir.mktmpdir('factory_sloth-') at_exit { FileUtils.remove_entry(dir) if File.exist?(dir) } dir end end |