transferred Code Ocean from original repository to GitHub
This commit is contained in:
2
db/seeds/files/data.txt
Normal file
2
db/seeds/files/data.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
Foo
|
||||
Bar
|
6
db/seeds/files/exercise.rb
Normal file
6
db/seeds/files/exercise.rb
Normal file
@@ -0,0 +1,6 @@
|
||||
SOURCE_FILENAME = 'data.txt'
|
||||
TARGET_FILENAME = 'copy.txt'
|
||||
|
||||
def copy_file
|
||||
# Implement this method.
|
||||
end
|
21
db/seeds/files/exercise_spec.rb
Normal file
21
db/seeds/files/exercise_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require './exercise'
|
||||
|
||||
describe '#write_to_file' do
|
||||
before(:each) do
|
||||
@file_content = File.new(SOURCE_FILENAME, 'r').read
|
||||
write_to_file
|
||||
end
|
||||
|
||||
it 'preserves the source file' do
|
||||
expect(File.exist?(SOURCE_FILENAME)).to be true
|
||||
expect(File.new(SOURCE_FILENAME, 'r').read).to eq(@file_content)
|
||||
end
|
||||
|
||||
it 'creates the target file' do
|
||||
expect(File.exist?(TARGET_FILENAME)).to be true
|
||||
end
|
||||
|
||||
it 'copies the file content' do
|
||||
expect(File.new(TARGET_FILENAME, 'r').read).to eq(@file_content)
|
||||
end
|
||||
end
|
Reference in New Issue
Block a user