Sha256: cb3bf9eb79609a27b4ed3742f36dd75f34d56d8a9678073478344a789d7c1207

Contents?: true

Size: 1.94 KB

Versions: 5

Compression:

Stored size: 1.94 KB

Contents

require 'stringio'
require 'rbconfig'

describe "DrbCommandLine without running local server" do
  
  unless Config::CONFIG['ruby_install_name'] == 'jruby'
    it "should print error when there is no running local server" do
      err = StringIO.new
      out = StringIO.new
      Spec::Runner::DrbCommandLine.run(['--version'], err, out, false)
    
      err.rewind
      err.read.should =~ /No server is running/
    end
  end    
end

describe "DrbCommandLine with local server" do

  unless Config::CONFIG['ruby_install_name'] == 'jruby'  
    before :all do
      create_dummy_spec_file
      DRb.start_service("druby://localhost:8989", Spec::Runner::CommandLine)
    end
    
    after :all do
      DRb.stop_service      
      File.delete(@dummy_spec_filename)
    end

    it "should run against local server" do
      out = run_spec_via_druby(['--version'])
      out.should =~ /RSpec/n
    end
    
    it "should output green colorized text when running with --colour option" do
      out = run_spec_via_druby(["--colour", @dummy_spec_filename])
      out.should =~ /\e\[32m/n
    end
    
    it "should output red colorized text when running with -c option" do      
      out = run_spec_via_druby(["-c", @dummy_spec_filename])
      out.should =~ /\e\[31m/n
    end

    def create_dummy_spec_file
      @dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + '/_dummy_spec.rb'
      File.open(@dummy_spec_filename, 'w') do |f|
        f.write %{
describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do
  it "should be output with green bar" do
    true.should be_true
  end

  it "should be output with red bar" do
    violated("I wan to see a red bar!")
  end
end
}
      end
    end
    
    def run_spec_via_druby(args)
      err, out = StringIO.new, StringIO.new
      out.instance_eval do
        def tty?; true end
      end
      Spec::Runner::DrbCommandLine.run(args, err, out, false, true)
      out.rewind; out.read
    end
  end
  
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rspec-0.9.0 spec/spec/runner/drb_command_line_spec.rb
rspec-0.9.1 spec/spec/runner/drb_command_line_spec.rb
rspec-0.9.2 spec/spec/runner/drb_command_line_spec.rb
rspec-0.9.3 spec/spec/runner/drb_command_line_spec.rb
rspec-0.9.4 spec/spec/runner/drb_command_line_spec.rb