Skip to content

Commit

Permalink
stub out config.files_to_run in examples that run specs but don't nee…
Browse files Browse the repository at this point in the history
…d to

- See #397
  • Loading branch information
dchelimsky committed Jun 9, 2011
1 parent 0ae46b5 commit d5285ce
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 19 deletions.
42 changes: 23 additions & 19 deletions lib/rspec/core/configuration.rb
Expand Up @@ -298,11 +298,31 @@ def reporter
end

def files_or_directories_to_run=(*files)
files = files.flatten
if files.empty? && default_directory
files << default_directory
end
self.files_to_run = get_files_to_run(files)
# if you comment out the next line, the "block not supplied" error goes away
self.files_to_run = get_files_to_run(default_directory) if files_to_run.empty?
end

def get_files_to_run(*files)
files.flatten.collect do |file|
if File.directory?(file)
pattern.split(",").collect do |pattern|
Dir["#{file}/#{pattern.strip}"]
end
else
if file =~ /(\:(\d+))$/
self.line_number = $2
file.sub($1,'')
else
file
end
end
end.flatten
end


# E.g. alias_example_to :crazy_slow, :speed => 'crazy_slow' defines
# crazy_slow as an example variant that has the crazy_slow speed option
def alias_example_to(new_name, *args)
Expand Down Expand Up @@ -350,6 +370,7 @@ def inclusion_filter=(filter)
def inclusion_filter
settings[:inclusion_filter] || {}
end

def filter_run_including(*args)
force_overwrite = if args.last.is_a?(Hash) || args.last.is_a?(Symbol)
false
Expand Down Expand Up @@ -466,23 +487,6 @@ def custom_formatter(formatter_ref)
end
end

def get_files_to_run(*files)
files.flatten.collect do |file|
if File.directory?(file)
pattern.split(",").collect do |pattern|
Dir["#{file}/#{pattern.strip}"]
end
else
if file =~ /(\:(\d+))$/
self.line_number = $2
file.sub($1,'')
else
file
end
end
end.flatten
end

def string_const?(str)
str.is_a?(String) && /\A[A-Z][a-zA-Z0-9_:]*\z/ =~ str
end
Expand Down
1 change: 1 addition & 0 deletions spec/rspec/core/command_line_spec.rb
Expand Up @@ -156,6 +156,7 @@ def config_options(argv=[])

before do
config.stub(:run_hook)
config.stub(:files_to_run) { [] }
end

it "doesn't override output_stream" do
Expand Down
2 changes: 2 additions & 0 deletions spec/rspec/core/runner_spec.rb
Expand Up @@ -25,6 +25,7 @@ module RSpec::Core
let(:out) { StringIO.new }

it "resets world and configuration" do
RSpec.configuration.stub(:files_to_run) { [] }
RSpec.configuration.should_receive(:reset)
RSpec.world.should_receive(:reset)
RSpec::Core::Runner.run([], err, out)
Expand Down Expand Up @@ -58,6 +59,7 @@ def run_specs
end

it "outputs a message" do
RSpec.configuration.stub(:files_to_run) { [] }
err.should_receive(:puts).with(
"No DRb server is running. Running in local process instead ..."
)
Expand Down

0 comments on commit d5285ce

Please sign in to comment.