Submit Search
Upload
Fake your files - MemFs
•
1 like
•
1,016 views
Simon Courtois
Follow
My talk for Paris.rb on 2014-02-04.
Read less
Read more
Technology
Slideshow view
Report
Share
Slideshow view
Report
Share
1 of 24
Download now
Download to read offline
Recommended
Python 101
Python 101
The Active Network
Introduction to JavaScript: Week Two
Introduction to JavaScript: Week Two
Event Handler
Getting to know Arel
Getting to know Arel
Ray Zane
SolrMeter Lightning talk - Lucene Revolution 2010
SolrMeter Lightning talk - Lucene Revolution 2010
Tomás Fernández Löbbe
gitfs
gitfs
Temian Vlad
F strings
F strings
Mariatta Wijaya
Baabtra.com little coder chapter - 3
Baabtra.com little coder chapter - 3
baabtra.com - No. 1 supplier of quality freshers
10 reasons to love CoffeeScript
10 reasons to love CoffeeScript
Lukas Alexandre
Recommended
Python 101
Python 101
The Active Network
Introduction to JavaScript: Week Two
Introduction to JavaScript: Week Two
Event Handler
Getting to know Arel
Getting to know Arel
Ray Zane
SolrMeter Lightning talk - Lucene Revolution 2010
SolrMeter Lightning talk - Lucene Revolution 2010
Tomás Fernández Löbbe
gitfs
gitfs
Temian Vlad
F strings
F strings
Mariatta Wijaya
Baabtra.com little coder chapter - 3
Baabtra.com little coder chapter - 3
baabtra.com - No. 1 supplier of quality freshers
10 reasons to love CoffeeScript
10 reasons to love CoffeeScript
Lukas Alexandre
DIWE - File handling with PHP
DIWE - File handling with PHP
Rasan Samarasinghe
Description 1) Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
theodorelove43763
Php files
Php files
kalyani66
File Handling in C Programming
File Handling in C Programming
RavindraSalunke3
Filesystems Lisbon 2018
Filesystems Lisbon 2018
Frank de Jonge
File handling in C++
File handling in C++
Hitesh Kumar
Ch3(working with file)
Ch3(working with file)
Chhom Karath
Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3
Gheyath M. Othman
Advance C Programming UNIT 4-FILE HANDLING IN C.pdf
Advance C Programming UNIT 4-FILE HANDLING IN C.pdf
sangeeta borde
Log into your netlab workstation then ssh to server.cnt1015.local wi.docx
Log into your netlab workstation then ssh to server.cnt1015.local wi.docx
desteinbrook
Having Fun Programming!
Having Fun Programming!
Aaron Patterson
Automate the boring stuff with python
Automate the boring stuff with python
DEEPAKSINGHBIST1
Java File I/O
Java File I/O
Canterbury HS
Filing system in PHP
Filing system in PHP
Mudasir Syed
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
Ranjan Raja
Java 7 Features and Enhancements
Java 7 Features and Enhancements
Gagan Agrawal
Can someone put this code in a zip file. I tried running it last tim.pdf
Can someone put this code in a zip file. I tried running it last tim.pdf
fedosys
file_handling_in_c.ppt
file_handling_in_c.ppt
yuvrajkeshri
General Functions
General Functions
BabuDevanandam
Linux commands
Linux commands
shekhar70
Conseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussi
Simon Courtois
Organize your assets with Rails
Organize your assets with Rails
Simon Courtois
More Related Content
Similar to Fake your files - MemFs
DIWE - File handling with PHP
DIWE - File handling with PHP
Rasan Samarasinghe
Description 1) Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
theodorelove43763
Php files
Php files
kalyani66
File Handling in C Programming
File Handling in C Programming
RavindraSalunke3
Filesystems Lisbon 2018
Filesystems Lisbon 2018
Frank de Jonge
File handling in C++
File handling in C++
Hitesh Kumar
Ch3(working with file)
Ch3(working with file)
Chhom Karath
Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3
Gheyath M. Othman
Advance C Programming UNIT 4-FILE HANDLING IN C.pdf
Advance C Programming UNIT 4-FILE HANDLING IN C.pdf
sangeeta borde
Log into your netlab workstation then ssh to server.cnt1015.local wi.docx
Log into your netlab workstation then ssh to server.cnt1015.local wi.docx
desteinbrook
Having Fun Programming!
Having Fun Programming!
Aaron Patterson
Automate the boring stuff with python
Automate the boring stuff with python
DEEPAKSINGHBIST1
Java File I/O
Java File I/O
Canterbury HS
Filing system in PHP
Filing system in PHP
Mudasir Syed
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
Ranjan Raja
Java 7 Features and Enhancements
Java 7 Features and Enhancements
Gagan Agrawal
Can someone put this code in a zip file. I tried running it last tim.pdf
Can someone put this code in a zip file. I tried running it last tim.pdf
fedosys
file_handling_in_c.ppt
file_handling_in_c.ppt
yuvrajkeshri
General Functions
General Functions
BabuDevanandam
Linux commands
Linux commands
shekhar70
Similar to Fake your files - MemFs
(20)
DIWE - File handling with PHP
DIWE - File handling with PHP
Description 1) Create a Lab2 folder for this project2.docx
Description 1) Create a Lab2 folder for this project2.docx
Php files
Php files
File Handling in C Programming
File Handling in C Programming
Filesystems Lisbon 2018
Filesystems Lisbon 2018
File handling in C++
File handling in C++
Ch3(working with file)
Ch3(working with file)
Web Development Course: PHP lecture 3
Web Development Course: PHP lecture 3
Advance C Programming UNIT 4-FILE HANDLING IN C.pdf
Advance C Programming UNIT 4-FILE HANDLING IN C.pdf
Log into your netlab workstation then ssh to server.cnt1015.local wi.docx
Log into your netlab workstation then ssh to server.cnt1015.local wi.docx
Having Fun Programming!
Having Fun Programming!
Automate the boring stuff with python
Automate the boring stuff with python
Java File I/O
Java File I/O
Filing system in PHP
Filing system in PHP
Linux Command Line - By Ranjan Raja
Linux Command Line - By Ranjan Raja
Java 7 Features and Enhancements
Java 7 Features and Enhancements
Can someone put this code in a zip file. I tried running it last tim.pdf
Can someone put this code in a zip file. I tried running it last tim.pdf
file_handling_in_c.ppt
file_handling_in_c.ppt
General Functions
General Functions
Linux commands
Linux commands
More from Simon Courtois
Conseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussi
Simon Courtois
Organize your assets with Rails
Organize your assets with Rails
Simon Courtois
Speed your Rails app creation with templates
Speed your Rails app creation with templates
Simon Courtois
Dependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSort
Simon Courtois
How Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCII
Simon Courtois
Get Slim!
Get Slim!
Simon Courtois
Multi tenant/lang application with Ruby on Rails
Multi tenant/lang application with Ruby on Rails
Simon Courtois
Rails is like Burger King
Rails is like Burger King
Simon Courtois
REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)
Simon Courtois
Ruby and DCI
Ruby and DCI
Simon Courtois
Cells
Cells
Simon Courtois
Mustdown
Mustdown
Simon Courtois
Vos Regexps sont fausses !
Vos Regexps sont fausses !
Simon Courtois
Ariane
Ariane
Simon Courtois
Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?
Simon Courtois
Commander
Commander
Simon Courtois
More from Simon Courtois
(16)
Conseils pour un lancement Product Hunt réussi
Conseils pour un lancement Product Hunt réussi
Organize your assets with Rails
Organize your assets with Rails
Speed your Rails app creation with templates
Speed your Rails app creation with templates
Dependency sorting in Ruby with TSort
Dependency sorting in Ruby with TSort
How Unidecoder Transliterates UTF-8 to ASCII
How Unidecoder Transliterates UTF-8 to ASCII
Get Slim!
Get Slim!
Multi tenant/lang application with Ruby on Rails
Multi tenant/lang application with Ruby on Rails
Rails is like Burger King
Rails is like Burger King
REST with Her (and let Her take care of the REST)
REST with Her (and let Her take care of the REST)
Ruby and DCI
Ruby and DCI
Cells
Cells
Mustdown
Mustdown
Vos Regexps sont fausses !
Vos Regexps sont fausses !
Ariane
Ariane
Pourquoi Ruby on Rails ça déchire ?
Pourquoi Ruby on Rails ça déchire ?
Commander
Commander
Recently uploaded
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
giselly40
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
Puma Security, LLC
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
hans926745
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
The Digital Insurer
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
naman860154
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Miguel Araújo
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
wesley chun
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Delhi Call girls
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
debabhi2
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Delhi Call girls
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Igalia
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
UK Journal
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
sudhanshuwaghmare1
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
wesley chun
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Neo4j
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
vu2urc
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Antenna Manufacturer Coco
Recently uploaded
(20)
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
How to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
Fake your files - MemFs
1.
Fake your files Simon
Courtois - @happynoff
2.
How to test
files manipulation ?
3.
class FileMaker def create(path) FileUtils.touch(path) end end it
"creates the given file" do file_maker.create('thing.txt') end
4.
class FileMaker def create(path) FileUtils.touch(path) end end it
"creates the given file" do file_maker.create('thing.txt') expect(File.exists?(‘thing.txt’)).to be_true end
5.
class FileMaker def create(path) FileUtils.touch(path) end end it
"creates the given file" do FileUtils.rm('thing.txt') file_maker.create('thing.txt') expect(File.exists?(‘thing.txt’)).to be_true end
6.
Read-only file system
?
7.
class FileMaker def create(path) FileUtils.touch(path) end end it
"creates the given file" do file_maker.create('thing.txt') end
8.
class FileMaker def create(path) FileUtils.touch(path) end end it
"creates the given file" do expect(FileUtils).to receive(:touch) .with(‘thing.txt') .and_return(true) file_maker.create('thing.txt') end
9.
Boooh! Test behavior not implementation
10.
Enters a solution FakeFS
11.
class FileMaker def create(path) FileUtils.touch(path) end end it
"creates the given file" do file_maker.create('thing.txt') expect(File.exists?('thing.txt')).to be_true end
12.
class FileMaker def create(path) FileUtils.touch(path) end end it
"creates the given file" do FakeFS do file_maker.create('thing.txt') expect(File.exists?('thing.txt')).to be_true end end
13.
class FileMaker def create(path) FileUtils.touch(path,
noop: true) end end it "creates the given file" do FakeFS do file_maker.create('thing.txt') expect(File.exists?('thing.txt')).to be_true be_false end end
14.
BOOM! That’s a red
dot
15.
FakeFS overwrites FileUtils and ignores
options
16.
Try MemFS
17.
class FileMaker def create(path) FileUtils.touch(path,
noop: true) end end it "creates the given file" do file_maker.create('thing.txt') expect(File.exists?('thing.txt')).to be_false end
18.
class FileMaker def create(path) FileUtils.touch(path,
noop: true) end end it "creates the given file" do MemFs.activate do file_maker.create('thing.txt') expect(File.exists?('thing.txt')).to be_false end end
19.
MemFs doesn’t overwrite FileUtils only
low-level classes
20.
File.open('thing.txt') do |f| f.puts
'hello' end ! File.read('thing.txt') # => "hellon" File.symlink('thing.txt', 'thing-link.txt') File.symlink?('thing-link.txt') # => true File.stat('thing.txt').ctime # => 2014-02-04 19:00:00 +0100 File.chmod(0777, 'thing.txt')
21.
Some resources
22.
http://github.com/defunkt/fakefs http://github.com/simonc/memfs
23.
Questions ?
24.
Thank you Simon Courtois
- @happynoff
Download now