Class: RRRSpec::Client::RSpecRunner
- Inherits:
- 
      Object
      
        - Object
- RRRSpec::Client::RSpecRunner
 
- Defined in:
- lib/rrrspec/client/rspec_runner.rb
Instance Method Summary collapse
- #exc_safe_replace_stdouts ⇒ Object
- 
  
    
      #initialize  ⇒ RSpecRunner 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of RSpecRunner. 
- #reset ⇒ Object
- #run(*formatters) ⇒ Object
- #setup(filepath) ⇒ Object
Constructor Details
#initialize ⇒ RSpecRunner
Returns a new instance of RSpecRunner.
| 7 8 9 10 11 12 13 14 | # File 'lib/rrrspec/client/rspec_runner.rb', line 7 def initialize @options = RSpec::Core::ConfigurationOptions.new([]) @options. @configuration = RSpec.configuration @configuration.setup_load_path_and_require([]) @world = RSpec.world @before_suite_run = false end | 
Instance Method Details
#exc_safe_replace_stdouts ⇒ Object
| 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | # File 'lib/rrrspec/client/rspec_runner.rb', line 16 def exc_safe_replace_stdouts outbuf = '' errbuf = '' $stdout = StringIO.new(outbuf) $stderr = StringIO.new(errbuf) begin yield rescue Exception $stdout.puts $! $stdout.puts $!.backtrace.join("\n") end [outbuf, errbuf] ensure $stdout = STDOUT $stderr = STDERR end | 
#reset ⇒ Object
| 77 78 79 80 | # File 'lib/rrrspec/client/rspec_runner.rb', line 77 def reset @world.example_groups.clear @configuration.reset end | 
#run(*formatters) ⇒ Object
| 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | # File 'lib/rrrspec/client/rspec_runner.rb', line 56 def run(*formatters) status = false outbuf, errbuf = exc_safe_replace_stdouts do @configuration.formatters << RSpec::Core::Formatters::BaseTextFormatter.new($stdout) formatters.each do |formatter| @configuration.formatters << formatter end @configuration.reporter.report( @world.example_count, @configuration.randomize? ? @configuration.seed : nil ) do |reporter| @world.example_groups.ordered.each do |example_group| example_group.run(reporter) end end status = true end [status, outbuf, errbuf] end | 
#setup(filepath) ⇒ Object
| 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | # File 'lib/rrrspec/client/rspec_runner.rb', line 33 def setup(filepath) status = false outbuf, errbuf = exc_safe_replace_stdouts do begin @options.configure(@configuration) @configuration.files_to_run = [filepath] @configuration.load_spec_files @world.announce_filters unless @before_suite_run @configuration.run_hook(:before, :suite) @before_suite_run = true end status = true rescue Exception $stdout.puts $! $stdout.puts $!.backtrace.join("\n") status = false end end [status, outbuf, errbuf] end |