title: Is there a way to mock a filesystem for unit testing in Scala
body: <p>I'm looking for a way to mock a filesystem in Scala.  I'd like to do something like this:</p>
  
  <pre><code>class MyMainClass(fs: FileSystem) {
     ...
  }
  </code></pre>
  
  <p>normal runtime:</p>
  
  <pre><code>val fs = FileSystem.default
  main = new MyMainClass(fs)
  </code></pre>
  
  <p>test time:</p>
  
  <pre><code>val fs = new RamFileSystem
  main = new MyMainClass(fs)
  </code></pre>
  
  <p>My examples look a lot like Scala-IO and I thought it might be my answer.  However, it doesn't look like all the core functionality in Scala-IO works with the <code>FileSystem</code> abstraction.  In particular, I can't read from a <code>Path</code> or apply <code>Path.asInput</code>.  Further, several of the abstractions like <code>Path</code> and <code>Resource</code> seem tightly bound to <code>FileSystem.default</code>.</p>
  
  <p>I also googled some interesting stuff in Scala-Tools, but that project seems to be defunct.</p>
  
  <p>Rob</p>