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
Report
Share
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
presentation ICT roal in 21st century education
presentation ICT roal in 21st century education
jfdjdjcjdnsjd
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
Enterprise Knowledge
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Enterprise Knowledge
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
The Digital Insurer
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Remote DBA Services
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
apidays
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
The Digital Insurer
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
HampshireHUG
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
sudhanshuwaghmare1
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
UK Journal
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
hans926745
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
wesley chun
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Maria Levchenko
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
Delhi Call girls
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
ThousandEyes
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Drew Madelung
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
lior mazor
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc
Recently uploaded
(20)
presentation ICT roal in 21st century education
presentation ICT roal in 21st century education
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Tech Trends Report 2024 Future Today Institute.pdf
Tech Trends Report 2024 Future Today Institute.pdf
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
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