1 require File.dirname(__FILE__) + '/../../spec_helper.rb'
5 describe DrbCommandLine, "without running local server" do
6 unless Config::CONFIG['ruby_install_name'] == 'jruby'
7 it "should print error when there is no running local server" do
10 DrbCommandLine.run(OptionParser.parse(['--version'], err, out))
13 err.read.should =~ /No server is running/
18 class DrbCommandLineSpec < ::Spec::Example::ExampleGroup
19 describe DrbCommandLine, "with local server"
21 class CommandLineForSpec
22 def self.run(argv, stderr, stdout)
23 exit Spec::Runner::CommandLine.run(OptionParser.parse(argv, stderr, stdout))
27 unless Config::CONFIG['ruby_install_name'] == 'jruby'
29 DRb.start_service("druby://localhost:8989", CommandLineForSpec)
30 @@drb_example_file_counter = 0
34 create_dummy_spec_file
35 @@drb_example_file_counter = @@drb_example_file_counter + 1
39 File.delete(@dummy_spec_filename)
46 it "should run against local server" do
47 out = run_spec_via_druby(['--version'])
48 out.should =~ /RSpec/n
51 it "should output green colorized text when running with --colour option" do
52 out = run_spec_via_druby(["--colour", @dummy_spec_filename])
53 out.should =~ /\e\[32m/n
56 it "should output red colorized text when running with -c option" do
57 out = run_spec_via_druby(["-c", @dummy_spec_filename])
58 out.should =~ /\e\[31m/n
61 def create_dummy_spec_file
62 @dummy_spec_filename = File.expand_path(File.dirname(__FILE__)) + "/_dummy_spec#{@@drb_example_file_counter}.rb"
63 File.open(@dummy_spec_filename, 'w') do |f|
65 describe "DUMMY CONTEXT for 'DrbCommandLine with -c option'" do
66 it "should be output with green bar" do
70 it "should be output with red bar" do
71 violated("I want to see a red bar!")
78 def run_spec_via_druby(argv)
79 err, out = StringIO.new, StringIO.new
83 options = ::Spec::Runner::Options.new(err, out)
85 Spec::Runner::DrbCommandLine.run(options)