Permalink
Browse files

better names

  • Loading branch information...
1 parent 7fe2a04 commit fbd9ab76e550f807b80b6abf34fd2e96ff9464a7 @dchelimsky dchelimsky committed Jun 2, 2010
@@ -39,7 +39,7 @@ def to_drb_argv
argv << "--profile" if options[:profile_examples]
argv << "--backtrace" if options[:full_backtrace]
argv << "--formatter" << options[:formatter] if options[:formatter]
- argv << "--drb-port" << options[:drb_port].to_s if options[:drb_port]
+ # argv << "--drb-port" << options[:drb_port].to_s if options[:drb_port]
argv << "--line_number" << options[:line_number] if options[:line_number]
argv << "--options_file" << options[:options_file] if options[:options_file]
argv << "--example" << options[:full_description].source if options[:full_description]
View
@@ -15,104 +15,98 @@ def self.autorun
end
def self.running_in_drb?
- !!((DRb.current_server.uri rescue "") =~ /druby\:\/\/127.0.0.1\:/)
- end
-
- def configuration
- RSpec.configuration
+ (DRb.current_server rescue false) &&
+ !!((DRb.current_server.uri) =~ /druby\:\/\/127.0.0.1\:/)
end
def run(args, err, out)
if args.any? {|a| %w[--drb -X].include? a}
- run_over_drb(args, err, out) ||
- run_in_process(args, err, out)
+ run_over_drb(args, err, out) || run_in_process(args, err, out)
else
run_in_process(args, err, out)
end
end
def run_over_drb(args, err, out)
- DRbProxy.new(args).run(err, out)
+ DRbCommandLine.new(args).run(err, out)
end
def run_in_process(args, err, out)
- InProcess.new(args).run(err, out)
+ CommandLine.new(args).run(err, out)
end
- private
-
- class Worker
- def initialize(argv)
- drb = argv.any? {|a| %w[--drb -X].include? a}
- @options = RSpec::Core::ConfigurationOptions.new(argv)
- unless drb
- @options.configure(configuration)
- configuration.require_files_to_run
- configuration.configure_mock_framework
- end
- end
-
- def configuration
- RSpec.configuration
- end
+ end
- def run(err, out)
- configuration.error_stream = err
- configuration.output_stream = out
- end
+ class DRbCommandLine
+ def initialize(argv)
+ @options = RSpec::Core::ConfigurationOptions.new(argv)
end
- class DRbProxy < Worker
- def run(err, out)
- super(err, out)
+ def run(err, out)
+ begin
begin
- begin
- DRb.start_service("druby://localhost:0")
- rescue SocketError, Errno::EADDRNOTAVAIL
- DRb.start_service("druby://:0")
- end
- spec_server = DRbObject.new_with_uri("druby://127.0.0.1:#{@options.drb_port}")
- spec_server.run(@options.to_drb_argv, err, out)
- true
- rescue DRb::DRbConnError
- out.puts "WTF"
- err.puts "No DRb server is running. Running in local process instead ..."
- false
+ DRb.start_service("druby://localhost:0")
+ rescue SocketError, Errno::EADDRNOTAVAIL
+ DRb.start_service("druby://:0")
end
+ spec_server = DRbObject.new_with_uri("druby://127.0.0.1:#{@options.drb_port}")
+ spec_server.run(@options.to_drb_argv, err, out)
+ true
+ rescue DRb::DRbConnError
+ err.puts "No DRb server is running. Running in local process instead ..."
+ false
end
end
+ end
- class InProcess < Worker
- def run(err, out)
- super(err, out)
- RSpec.world.announce_inclusion_filter
+ class CommandLine
+ def initialize(argv)
+ @options = RSpec::Core::ConfigurationOptions.new(argv)
+ @options.configure(configuration)
+ configuration.require_files_to_run
+ configuration.configure_mock_framework
+ end
- RSpec.configuration.formatter.report(RSpec.world.example_count) do |reporter|
- example_groups.run_examples(reporter)
- end
-
- example_groups.success?
- end
+ def run(err, out)
+ configuration.error_stream = err
+ configuration.output_stream = out
+ world.announce_inclusion_filter
- def example_count
- RSpec.world.example_count
+ configuration.formatter.report(world.example_count) do |reporter|
+ example_groups.run_examples(reporter)
end
+
+ example_groups.success?
+ end
- module ExampleGroups
- def run_examples(reporter)
- @success = self.inject(true) {|success, group| success &= group.run(reporter)}
- end
+ private
- def success?
- @success ||= false
- end
+ def example_count
+ world.example_count
+ end
+
+ module ExampleGroups
+ def run_examples(reporter)
+ @success = self.inject(true) {|success, group| success &= group.run(reporter)}
end
- def example_groups
- RSpec.world.example_groups.extend(ExampleGroups)
+ def success?
+ @success ||= false
end
end
+ def example_groups
+ world.example_groups.extend(ExampleGroups)
+ end
+
+ def configuration
+ RSpec.configuration
+ end
+
+ def world
+ RSpec.world
+ end
end
+
end
end
@@ -1,7 +1,7 @@
if defined?(Spork::TestFramework::RSpec)
class Spork::TestFramework::RSpec < Spork::TestFramework
def run_tests(argv, err, out)
- ::RSpec::Core::Runner.new.run(argv, err, out)
+ ::RSpec::Core::CommandLine.new(argv).run(err, out)
end
end
end
View
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
s.authors = ["Chad Humphries", "David Chelimsky"]
- s.date = %q{2010-05-31}
+ s.date = %q{2010-06-01}
s.description = %q{RSpec runner and example group classes}
s.email = %q{dchelimsky@gmail.com;chad.humphries@gmail.com}
s.executables = ["rspec", "spec"]
@@ -163,6 +163,7 @@ Gem::Specification.new do |s|
"spec/rspec/core/resources/a_foo.rb",
"spec/rspec/core/resources/a_spec.rb",
"spec/rspec/core/resources/custom_example_group_runner.rb",
+ "spec/rspec/core/resources/drb_example_spec.rb",
"spec/rspec/core/resources/utf8_encoded.rb",
"spec/rspec/core/ruby_project_spec.rb",
"spec/rspec/core/runner_spec.rb",
@@ -213,6 +214,7 @@ Gem::Specification.new do |s|
"spec/rspec/core/resources/a_foo.rb",
"spec/rspec/core/resources/a_spec.rb",
"spec/rspec/core/resources/custom_example_group_runner.rb",
+ "spec/rspec/core/resources/drb_example_spec.rb",
"spec/rspec/core/resources/utf8_encoded.rb",
"spec/rspec/core/ruby_project_spec.rb",
"spec/rspec/core/runner_spec.rb",
@@ -1,23 +1,23 @@
require "spec_helper"
-describe "::DRbProxy" do
+describe "::DRbCommandLine" do
before do
RSpec.stub(:configuration).and_return(RSpec::Core::Configuration.new)
end
context "without server running" do
it "prints error" do
err, out = StringIO.new, StringIO.new
- RSpec::Core::Runner::DRbProxy.new([]).run(err, out)
+ RSpec::Core::DRbCommandLine.new([]).run(err, out)
err.rewind
err.read.should =~ /No DRb server is running/
end
it "returns false" do
err, out = StringIO.new, StringIO.new
- result = RSpec::Core::Runner::DRbProxy.new([]).run(err, out)
+ result = RSpec::Core::DRbCommandLine.new([]).run(err, out)
result.should be_false
end
end
@@ -48,14 +48,14 @@ def dummy_spec_filename
def run_spec_via_druby(argv)
err, out = StringIO.new, StringIO.new
- RSpec::Core::Runner::DRbProxy.new(argv.push("--drb-port", @drb_port.to_s)).run(err, out)
+ RSpec::Core::DRbCommandLine.new(argv.push("--drb-port", @drb_port.to_s)).run(err, out)
out.rewind
out.read
end
it "returns true" do
err, out = StringIO.new, StringIO.new
- result = RSpec::Core::Runner::DRbProxy.new(["--drb-port", @drb_port.to_s]).run(err, out)
+ result = RSpec::Core::DRbCommandLine.new(["--drb-port", @drb_port.to_s]).run(err, out)
result.should be_true
end
@@ -35,12 +35,12 @@ module RSpec::Core
RSpec::Core::ConfigurationOptions.stub(:new) { @options }
- @drb_proxy = double(RSpec::Core::Runner::DRbProxy, :run => true)
- RSpec::Core::Runner::DRbProxy.stub(:new => @drb_proxy)
+ @drb_proxy = double(RSpec::Core::Runner::DRbCommandLine, :run => true)
+ RSpec::Core::Runner::DRbCommandLine.stub(:new => @drb_proxy)
end
- it "builds a DRbProxy" do
- RSpec::Core::Runner::DRbProxy.should_receive(:new)
+ it "builds a DRbCommandLine" do
+ RSpec::Core::Runner::DRbCommandLine.should_receive(:new)
RSpec::Core::Runner.new.run(%w[ --drb ], @err, @out)
end
View
@@ -58,8 +58,10 @@ def in_editor?
RSpec.instance_variable_set(:@world, @real_world)
end
end
+ puts "PREFORK"
end
Spork.each_run do
+ puts "EACH RUN"
end

0 comments on commit fbd9ab7

Please sign in to comment.