Class: Guard::JRubyRSpec::Runner
- Inherits:
-
Object
- Object
- Guard::JRubyRSpec::Runner
- Defined in:
- lib/guard/jruby-rspec/runner.rb
Instance Method Summary collapse
- #cleanup ⇒ Object
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #parsed_or_default_formatter ⇒ Object
- #run(paths, options = {}) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 13 14 15 16 17 18 |
# File 'lib/guard/jruby-rspec/runner.rb', line 9 def initialize( = {}) = { :cli => [], :notification => true }.merge() @pipefile = [:pipefile] @pipefile ||= ".guard-jruby-rspec-pipe" cleanup end |
Instance Method Details
#cleanup ⇒ Object
20 21 22 |
# File 'lib/guard/jruby-rspec/runner.rb', line 20 def cleanup File.delete(@pipefile) if File.exists?(@pipefile) end |
#parsed_or_default_formatter ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/guard/jruby-rspec/runner.rb', line 55 def parsed_or_default_formatter @parsed_or_default_formatter ||= begin file_name = "#{Dir.pwd}/.rspec" parsed_formatter = if File.exist?(file_name) formatters = File.read(file_name).scan(formatter_regex).flatten formatters.map { |formatter| "-f#{formatter}" }.join(' ') end parsed_formatter.nil? || parsed_formatter.empty? ? '-fprogress' : parsed_formatter end end |
#run(paths, options = {}) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/guard/jruby-rspec/runner.rb', line 24 def run(paths, = {}) return false if paths.empty? = [:message] || "Running: #{paths.join(' ')}" UI.info(, :reset => true) # it might be a problem to run Rspec within this runtime. Might have to create an # embedded jruby. if File.exists?(@pipefile) raise "not supported yet" # instead of writing to the pipefile, we should probably use a # formatter and write to /dev/null # orig_stdout = $stdout.clone # orig_stderr = $stderr.clone # begin # $stdout.reopen(@pipefile, "w") # $stderr.reopen(@pipefile, "w") # ::RSpec::Core::Runner.run(paths) # ensure # $stdout.reopen(orig_stdout) # $stderr.reopen(orig_stderr) # end else orig_configuration = ::RSpec.configuration Containment.new.protect do ::RSpec::Core::Runner.run(rspec_arguments(paths, )) end ::RSpec.instance_variable_set(:@configuration, orig_configuration) end end |