Module: RSpecAtoms::Discover
- Defined in:
- lib/rspec_atoms/discover.rb
Class Method Summary collapse
- .call(arguments, output: $stdout, error: $stderr) ⇒ Object
- .rspec_arguments(arguments, atoms_path) ⇒ Object
- .write_runner_output(runner_output, error) ⇒ Object
Class Method Details
.call(arguments, output: $stdout, error: $stderr) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rspec_atoms/discover.rb', line 13 def call(arguments, output: $stdout, error: $stderr) Tempfile.create(["rspec-atoms", ".txt"]) do |atoms_file| runner_output = StringIO.new RSpec.configuration.fail_if_no_examples = true status = RSpec::Core::Runner.run( rspec_arguments(arguments, atoms_file.path), error, runner_output ) if status.zero? atoms_file.rewind IO.copy_stream(atoms_file, output) else write_runner_output(runner_output, error) end status end end |
.rspec_arguments(arguments, atoms_path) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rspec_atoms/discover.rb', line 35 def rspec_arguments(arguments, atoms_path) [ "--dry-run", "--no-color", "--format", "RSpecAtoms::DiscoveryFormatter", "--out", atoms_path, *arguments ] end |
.write_runner_output(runner_output, error) ⇒ Object
47 48 49 50 51 52 53 |
# File 'lib/rspec_atoms/discover.rb', line 47 def write_runner_output(runner_output, error) content = runner_output.string return if content.empty? error.write(content) error.write("\n") unless content.end_with?("\n") end |