Permalink
Browse files

should not include test files not in the given dir

a little bug in inspector. introducing a _test file for the regression test required a bunch of changes to inspector_spec.
  • Loading branch information...
nathany committed Sep 3, 2011
1 parent a5479b1 commit 5b933202e047da1c89b7f83b318f12546737cf72
@@ -12,7 +12,7 @@ def clean(paths)
paths.dup.each do |path|
if File.directory?(path)
paths.delete(path)
- paths += Dir.glob("#{path}/**/test_*.rb") + Dir.glob('test/**/*_test.rb') + Dir.glob("#{path}/**/*_spec.rb")
+ paths += Dir.glob("#{path}/**/test_*.rb") + Dir.glob("#{path}/**/*_test.rb") + Dir.glob("#{path}/**/*_spec.rb")
end
end
@@ -43,4 +43,4 @@ def clear_test_files_list
end
end
end
-end
+end
@@ -6,36 +6,44 @@
describe 'clean' do
+ before(:each) do
+ @files_on_disk = ['test/guard/minitest/test_inspector.rb', 'test/guard/test_minitest.rb', 'test/guard/minitest_test.rb'].sort
+ end
+
it "should add all test files under the given dir" do
- subject.clean(['test']).must_equal ['test/guard/minitest/test_inspector.rb', 'test/guard/test_minitest.rb']
+ subject.clean(['test']).sort.must_equal @files_on_disk
end
it 'should remove non-test files' do
- subject.clean(['test/guard/test_minitest.rb', 'bob.rb']).must_equal ['test/guard/test_minitest.rb']
+ subject.clean(['test/guard/test_minitest.rb', 'bob.rb']).wont_include 'bob.rb'
end
- it 'should remove non-test existing files' do
- subject.clean(['test/guard/test_minitest.rb', 'test_bob.rb']).must_equal ['test/guard/test_minitest.rb']
+ it 'should remove non-existing test files' do
+ subject.clean(['test/guard/test_minitest.rb', 'test_bob.rb']).wont_include 'test_bob.rb'
end
it 'should remove non-test existing files (2)' do
subject.clean(['test/guard/minitest/test_formatter.rb']).must_equal []
end
it 'should keep test folder path' do
- subject.clean(['test/guard/test_minitest.rb', 'test']).must_equal ['test/guard/test_minitest.rb', 'test/guard/minitest/test_inspector.rb']
+ subject.clean(['test/guard/test_minitest.rb', 'test']).sort.must_equal @files_on_disk
end
it 'should remove duplication' do
subject.clean(['test/guard/test_minitest.rb', 'test/guard/test_minitest.rb']).must_equal ['test/guard/test_minitest.rb']
end
it 'should remove duplication (2)' do
- subject.clean(['test', 'test']).must_equal ['test/guard/minitest/test_inspector.rb', 'test/guard/test_minitest.rb']
+ subject.clean(['test', 'test']).sort.must_equal @files_on_disk
end
it 'should remove test folder includes in other test folder' do
- subject.clean(['test/minitest', 'test']).must_equal ['test/guard/minitest/test_inspector.rb', 'test/guard/test_minitest.rb']
+ subject.clean(['test/minitest', 'test']).sort.must_equal @files_on_disk
+ end
+
+ it 'should not include test files not in the given dir' do
+ subject.clean(['test/guard/minitest']).wont_include 'test/guard/minitest_test.rb'
end
end
No changes.

0 comments on commit 5b93320

Please sign in to comment.