Skip to content
Browse files

clean up drb spec

  • Loading branch information...
1 parent ea12445 commit 5b2b374efa2dc3834a44a1b2b8f47095f7b9007f @dchelimsky dchelimsky committed Dec 13, 2011
Showing with 20 additions and 37 deletions.
  1. +20 −37 spec/rspec/core/drb_command_line_spec.rb
View
57 spec/rspec/core/drb_command_line_spec.rb
@@ -7,23 +7,19 @@
include_context "spec files"
- def command_line(args)
- RSpec::Core::DRbCommandLine.new(config_options(args))
+ def command_line(*args)
+ RSpec::Core::DRbCommandLine.new(config_options(*args))
end
- def config_options(argv=[])
- options = RSpec::Core::ConfigurationOptions.new(argv)
+ def config_options(*args)
+ options = RSpec::Core::ConfigurationOptions.new(args)
options.parse_options
options
end
- def run_with(args)
- command_line(args).run(err, out)
- end
-
context "without server running" do
it "raises an error" do
- lambda { run_with [] }.should raise_error(DRb::DRbConnError)
+ lambda { command_line.run(err, out) }.should raise_error(DRb::DRbConnError)
end
end
@@ -41,40 +37,39 @@ def with_RSPEC_DRB_set_to(val)
context "without RSPEC_DRB environment variable set" do
it "defaults to 8989" do
with_RSPEC_DRB_set_to(nil) do
- command_line([]).drb_port.should eq(8989)
+ command_line.drb_port.should eq(8989)
end
end
it "sets the DRb port" do
with_RSPEC_DRB_set_to(nil) do
- command_line(["--drb-port", "1234"]).drb_port.should eq(1234)
- command_line(["--drb-port", "5678"]).drb_port.should eq(5678)
+ command_line("--drb-port", "1234").drb_port.should eq(1234)
+ command_line("--drb-port", "5678").drb_port.should eq(5678)
end
end
end
context "with RSPEC_DRB environment variable set" do
-
context "without config variable set" do
it "uses RSPEC_DRB value" do
with_RSPEC_DRB_set_to('9000') do
- command_line([]).drb_port.should eq("9000")
+ command_line.drb_port.should eq("9000")
end
end
end
context "and config variable set" do
it "uses configured value" do
with_RSPEC_DRB_set_to('9000') do
- command_line(%w[--drb-port 5678]).drb_port.should eq(5678)
+ command_line(*%w[--drb-port 5678]).drb_port.should eq(5678)
end
end
end
end
end
context "with server running" do
- class ::FakeDrbSpecServer
+ class SimpleDRbSpecServer
def self.run(argv, err, out)
options = RSpec::Core::ConfigurationOptions.new(argv)
options.parse_options
@@ -83,42 +78,30 @@ def self.run(argv, err, out)
end
before(:all) do
- @drb_port = 8990
+ @drb_port = '8990'
@drb_example_file_counter = 0
- DRb::start_service("druby://127.0.0.1:#{@drb_port}", ::FakeDrbSpecServer)
+ DRb::start_service("druby://127.0.0.1:#{@drb_port}", SimpleDRbSpecServer)
end
after(:all) do
DRb::stop_service
end
it "returns 0 if spec passes" do
- err, out = StringIO.new, StringIO.new
- result = command_line(["--drb-port", @drb_port.to_s, passing_spec_filename]).run(err, out)
+ result = command_line("--drb-port", @drb_port, passing_spec_filename).run(err, out)
result.should be(0)
end
- it "returns 1 if spec passes" do
- err, out = StringIO.new, StringIO.new
- result = command_line(["--drb-port", @drb_port.to_s, failing_spec_filename]).run(err, out)
+ it "returns 1 if spec fails" do
+ result = command_line("--drb-port", @drb_port, failing_spec_filename).run(err, out)
result.should be(1)
end
- def run_spec_via_druby
- run_with([failing_spec_filename, "--colour", "--drb-port", @drb_port.to_s])
+ it "outputs colorized text when running with --colour option" do
+ pending "figure out a way to tell the output to say it's tty"
+ command_line(failing_spec_filename, "--color", "--drb-port", @drb_port).run(err, out)
out.rewind
- out.read
- end
-
- it "outputs green colorized text when running with --colour option" do
- pending "figure out a way to properly sandbox this"
- run_spec_via_druby.should =~ /\e\[32m/m
- end
-
- it "outputs red colorized text when running with -c option" do
- pending "figure out a way to properly sandbox this"
- run_spec_via_druby.should =~ /\e\[31m/m
+ out.read.should =~ /\e\[32m/m
end
end
-
end

0 comments on commit 5b2b374

Please sign in to comment.
Something went wrong with that request. Please try again.