Commit
These are for #660.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,6 +316,40 @@ module RSpec::Core | |
config.files_to_run.should be_empty | ||
end | ||
end | ||
|
||
def test_files_to_run_ordering | ||
File.stub(:directory?).with('a') { true } | ||
|
||
orderings = [ | ||
%w[ a/1.rb a/2.rb a/3.rb ], | ||
%w[ a/2.rb a/1.rb a/3.rb ], | ||
%w[ a/3.rb a/2.rb a/1.rb ] | ||
].map do |files| | ||
Dir.should_receive(:[]).with(/^a/) { files } | ||
yield | ||
config.files_to_run | ||
end.uniq | ||
|
||
orderings.size.should eq(1) | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
myronmarston
Author
Member
|
||
end | ||
|
||
context 'when the given directories match the pattern' do | ||
it 'orders the files in a consistent ordering, regardless of the underlying OS ordering' do | ||
test_files_to_run_ordering do | ||
config.pattern = 'a/*.rb' | ||
config.files_or_directories_to_run = 'a' | ||
end | ||
end | ||
end | ||
|
||
context 'when the pattern is given relative to the given directories' do | ||
it 'orders the files in a consistent ordering, regardless of the underlying OS ordering' do | ||
test_files_to_run_ordering do | ||
config.pattern = '*.rb' | ||
config.files_or_directories_to_run = 'a' | ||
end | ||
end | ||
end | ||
end | ||
|
||
%w[pattern= filename_pattern=].each do |setter| | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -80,12 +80,39 @@ def spec_command | |
end | ||
end | ||
|
||
def test_files_to_run_ordering(pattern, task) | ||
This comment has been minimized.
Sorry, something went wrong.
dchelimsky
Contributor
|
||
orderings = [ | ||
%w[ a/1.rb a/2.rb a/3.rb ], | ||
%w[ a/2.rb a/1.rb a/3.rb ], | ||
%w[ a/3.rb a/2.rb a/1.rb ] | ||
].map do |files| | ||
FileList.should_receive(:[]).with(pattern) { files } | ||
task.__send__(:files_to_run) | ||
end.uniq | ||
|
||
orderings.size.should eq(1) | ||
end | ||
|
||
context "with SPEC env var set" do | ||
it "sets files to run" do | ||
with_env_vars 'SPEC' => 'path/to/file' do | ||
task.__send__(:files_to_run).should eq(["path/to/file"]) | ||
end | ||
end | ||
|
||
it "sets the files to run in a consistent order, regardless of the underlying FileList ordering" do | ||
with_env_vars 'SPEC' => 'a/*.rb' do | ||
test_files_to_run_ordering('a/*.rb', task) | ||
end | ||
end | ||
end | ||
|
||
it "sets the files to run in a consistent order, regardless of the underlying FileList ordering" do | ||
task = RakeTask.new do |t| | ||
t.pattern = 'a/*.rb' | ||
end | ||
|
||
test_files_to_run_ordering('a/*.rb', task) | ||
end | ||
|
||
context "with paths with quotes" do | ||
|
This is very subtle and subjective, but I think moving
uniq
to this line would be clearer:orderings.uniq.size.should eq(1)