이것은 디렉토리를 만드는 방법입니다. rspec에서 디렉토리 생성을 조롱 할 수 있습니까?
def create_directory(path)
system 'mkdir', '-p', path
end
는 I이 방법에 대한
rspec
를 생성하고 디렉토리의 작성을 모방
fakefs
사용.
it 'should create directory given path as parameter' do
FakeFS do
create_directory(DIRECTORY_PATH)
end
expect(File.exists?(DIRECTORY_PATH)).to be_truthy
end
rspec
명령을 실행하면이 오류가 발생합니다.
Failures:
1) common Test for common method use should create file given file as parameter
Failure/Error: expect(File.exists?(DIRECTORY_PATH)).to be_truthy
expected: truthy value
got: false
# ./spec/unit/lib/common_spec.rb:16:in `block (3 levels) in <top (required)>'
Finished in 0.01474 seconds (files took 0.10763 seconds to load)
2 examples, 1 failure
Failed examples:
rspec ./spec/unit/lib/common_spec.rb:12 # common Test for common method use should create file given file as parameter
어떻게 RSpec에 또는 fakefs를 사용하여 디렉토리의 생성을 조롱하는?
안녕하세요 @ 앤드류 데인코, 질문을 추가했습니다. ** ** 질문이 없습니다 ** 고객님의 질문에 –
안녕하세요. 감사합니다 – micmicsuarez