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
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
Florian Wilhelm
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
UiPathCommunity
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
Fwdays
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
Dilum Bandara
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
Pixlogix Infotech
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
Scott Keck-Warren
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
BookNet Canada
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
Lorenzo Miniero
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
Fwdays
How to write a Business Continuity Plan
How to write a Business Continuity Plan
Databarracks
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
hariprasad279825
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
comworks
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
Miki Katsuragi
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
LoriGlavin3
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
null - The Open Security Community
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
Alan Dix
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
Sergiu Bodiu
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
Sri Ambati
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
Fwdays
Recently uploaded
(20)
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
How to write a Business Continuity Plan
How to write a Business Continuity Plan
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
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