spec/lib/fasterer/file_traverser_spec.rb in fasterer-0.1.12 vs spec/lib/fasterer/file_traverser_spec.rb in fasterer-0.2.0
- old
+ new
@@ -184,18 +184,105 @@
"exclude_paths:\n"\
" - 'sumthing.rb'"
end
before(:each) do
- create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME,
- config_file_content)
+ create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME, config_file_content)
create_file(file_name)
end
let(:file_traverser) { Fasterer::FileTraverser.new('.') }
it 'returns empty array' do
expect(file_traverser.send(:scannable_files)).to eq([file_name])
end
+ end
+
+ context 'nested ruby files' do
+ before(:each) do
+ create_file('something.rb')
+ create_file('nested/something.rb')
+ end
+
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
+
+ it 'returns files properly' do
+ expect(file_traverser.send(:scannable_files))
+ .to match_array(['something.rb', 'nested/something.rb'])
+ end
+ end
+
+ context 'ruby files but nested ignored explicitly' do
+ let(:config_file_content) do
+ "exclude_paths:\n"\
+ " - 'nested/something.rb'"
+ end
+
+ before(:each) do
+ create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME, config_file_content)
+ create_file('something.rb')
+ create_file('nested/something.rb')
+ end
+
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
+
+ it 'returns unignored files' do
+ expect(file_traverser.send(:scannable_files))
+ .to match_array(['something.rb'])
+ end
+ end
+
+ context 'ruby files but nested ignored with *' do
+ let(:config_file_content) do
+ "exclude_paths:\n"\
+ " - 'nested/*'"
+ end
+
+ before(:each) do
+ create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME, config_file_content)
+ create_file('something.rb')
+ create_file('nested/something.rb')
+ end
+
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
+
+ it 'returns unignored files' do
+ expect(file_traverser.send(:scannable_files))
+ .to match_array(['something.rb'])
+ end
+ end
+
+ context 'ruby files but unnested ignored' do
+ let(:config_file_content) do
+ "exclude_paths:\n"\
+ " - 'something.rb'"
+ end
+
+ before(:each) do
+ create_file(Fasterer::FileTraverser::CONFIG_FILE_NAME, config_file_content)
+ create_file('something.rb')
+ create_file('nested/something.rb')
+ end
+
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
+
+ it 'returns unignored files' do
+ expect(file_traverser.send(:scannable_files))
+ .to match_array(['nested/something.rb'])
+ end
+ end
+ end
+
+ describe 'parse errors' do
+ before do
+ create_file('user.rb', '[]*/sa*()')
+ file_traverser.traverse
+ end
+
+ let(:file_traverser) { Fasterer::FileTraverser.new('.') }
+
+ it 'should have errors' do
+ expect(file_traverser.parse_error_paths)
+ .to match_array(['user.rb - RubyParser::SyntaxError - unterminated string meets end of file. near line 1: ""'])
end
end
end