test/test_sources.rb in pdd-0.16.1 vs test/test_sources.rb in pdd-0.16.2
- old
+ new
@@ -21,10 +21,11 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
require 'minitest/autorun'
require 'pdd/sources'
+require 'fileutils'
require 'tmpdir'
# Sources test.
# Author:: Yegor Bugayenko (yegor@teamed.io)
# Copyright:: Copyright (c) 2014-2016 Yegor Bugayenko
@@ -36,12 +37,12 @@
assert_equal 2, list.size
end
end
def test_ignores_binary_files
- in_temp(['c', 'd.png']) do |dir|
- File.write(File.join(dir, 'd.png'), '')
+ in_temp(['c']) do |dir|
+ FileUtils.cp(File.join(Dir.pwd, '.git/index'), dir)
list = PDD::Sources.new(dir).fetch
assert_equal 1, list.size
end
end
@@ -68,9 +69,11 @@
in_temp(['a/first.txt', 'b/c/d/second.txt']) do |dir|
list = PDD::Sources.new(dir).exclude('b/c/d/second.txt').fetch
assert_equal 1, list.size
end
end
+
+ private
def in_temp(files)
Dir.mktmpdir 'x' do |dir|
files.each do |path|
file = File.join(dir, path)