randomize spec load order because why not
This commit is contained in:
parent
16f867af09
commit
f8db052281
@ -182,7 +182,11 @@ module Jasmine::Headless
|
||||
|
||||
def add_files(patterns, type, dirs)
|
||||
dirs.product(patterns).each do |search|
|
||||
Dir[File.join(*search)].find_all { |file| file[extension_filter] }.each do |path|
|
||||
files = Dir[File.join(*search)].find_all { |file| file[extension_filter] }
|
||||
|
||||
files.sort! { |a, b| rand(3) - 1 } if type == 'spec_files'
|
||||
|
||||
files.each do |path|
|
||||
add_path(path, type) if File.file?(path)
|
||||
end
|
||||
end
|
||||
|
@ -175,5 +175,29 @@ describe Jasmine::Headless::FilesList do
|
||||
it { should == [ file_one, file_two, file_four ] }
|
||||
end
|
||||
end
|
||||
|
||||
describe '#add_files' do
|
||||
no_default_files!
|
||||
|
||||
let(:dir) { 'tmp' }
|
||||
|
||||
before do
|
||||
srand(100)
|
||||
|
||||
FileUtils.mkdir_p dir
|
||||
|
||||
10.times do |index|
|
||||
File.open(File.join(dir, "file-#{index}.js"), 'wb')
|
||||
end
|
||||
end
|
||||
|
||||
it 'should load spec files in a random order' do
|
||||
files_list.send(:add_files, [ '*' ], 'spec_files', [ dir ])
|
||||
|
||||
files_list.files.collect { |name| name[%r{\d+}] }.should == %w{6 7 1 0 5 3 4 8 2 9}
|
||||
|
||||
FileUtils.rm_rf dir
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -8,7 +8,7 @@ require 'fakefs/spec_helpers'
|
||||
|
||||
RSpec.configure do |c|
|
||||
c.mock_with :mocha
|
||||
#c.backtrace_clean_patterns = []
|
||||
c.backtrace_clean_patterns = []
|
||||
|
||||
c.before(:each) do
|
||||
Jasmine::Headless::CacheableAction.enabled = false
|
||||
@ -42,6 +42,12 @@ class FakeFS::File
|
||||
RealFile.fnmatch?(pattern, file)
|
||||
end
|
||||
end
|
||||
|
||||
class Stat
|
||||
def file?
|
||||
File.file?(@file)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
module RSpec::Matchers
|
||||
|
Loading…
Reference in New Issue
Block a user