FakeFS::File.should_receive(:chmod)
完整规格:
class TestFileUploader
mount_uploader :file, FileUploader
end
describe FileUploader do
include FakeFS::SpecHelpers
context 'for non-production environment' do
it 'should upload video clip to dev-bucket on s3' do
FakeFS.activate!
FakeFS::File.should_receive(:chmod) #this is needed or you will get an exception
File.open('test_file', 'w') do |f|
f.puts('foo') # this is required or uploader_test.file.url will be nil
end
uploader_test = TestFileUploader.new
uploader_test.file = File.open('test_file')
uploader_test.save!
uploader_test.file.url.should match /.*\/dev-bucket.*/ #test to make sure that it is not production-bucket
FakeFS.deactivate!
end
end
end
答案 0 :(得分:3)
它说的是,在特定FakeFS::File
的过程中,该特定类it
应该在其上调用.chmod
方法。
只要在某些时候代码确实如此:
FakeFS::File.chmod
那样的期望就会满足。这是确保调用某些代码或忽略某些代码的好方法。
例如,如果FakeFS::File.chmod
需要很长时间才能执行,或者需要设置大量代码,则可以添加此期望值。