memfs 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 07e362c240eee55e823d9e7b0ce0da5fe3d810c0
4
+ data.tar.gz: cb018e417f9972d2244cb9c2a89d0f8c570bb9b7
5
+ SHA512:
6
+ metadata.gz: 57a7489053cf43b9592c02128a01cbd484c2a57c025557f065b2170acc103330415161ca55e43b01cc430ac18adb152a911548ef8b0fad19dffa158e7d25f76b
7
+ data.tar.gz: 99a74244caf5093f89d19ebe975e5773b0cf342e3535da0d3652de482e2982342de495755ee0b40553759605074d35598c963b5b93c092e056fafcdee15ca1d0
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,17 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format=documentation
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 2.0.0
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in memfs.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,8 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+
4
+ guard 'rspec' do
5
+ watch(%r{^spec/.+_spec\.rb$})
6
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
7
+ watch('spec/spec_helper.rb') { "spec" }
8
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Simon COURTOIS
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,128 @@
1
+ # MemFs [![Build Status](https://secure.travis-ci.org/simonc/memfs.png?branch=master)](http://travis-ci.org/simonc/memfs) [![Code Climate](https://codeclimate.com/github/simonc/memfs.png)](https://codeclimate.com/github/simonc/memfs) [![Coverage Status](https://coveralls.io/repos/simonc/memfs/badge.png?branch=master)](https://coveralls.io/r/simonc/memfs?branch=master)
2
+
3
+ MemFs is an in-memory filesystem that can be used for your tests.
4
+
5
+ When you're writing code that manipulates files, directories, symlinks, you need
6
+ to be able to test it without touching your hard drive. MemFs is made for it.
7
+
8
+ MemFs is intended for tests but you can use it for any other scenario needing in
9
+ memory file system.
10
+
11
+ MemFs is greatly inspired by the awesome
12
+ [FakeFs](https://github.com/defunkt/fakefs).
13
+
14
+ The main goal of MemFs is to be 100% compatible with the Ruby libraries like
15
+ FileUtils.
16
+
17
+ For french guys, the answer is yes, the joke in the name is intended ;)
18
+
19
+ ## Take a look
20
+
21
+ Here is a simple example of MemFs usage:
22
+
23
+ ``` ruby
24
+ MemFs.activate!
25
+ File.open('/test-file', 'w') { |f| f.puts "hello world" }
26
+ File.read('/test-file') #=> "hello world\n"
27
+ MemFs.deactivate!
28
+
29
+ File.exists?('/test-file') #=> false
30
+
31
+ # Or with the block syntax
32
+
33
+ MemFs.activate do
34
+ FileUtils.touch('/test-file', verbose: true, noop: true)
35
+ File.exists?('/test-file') #=> true
36
+ end
37
+
38
+ File.exists?('/test-file') #=> false
39
+ ```
40
+
41
+ ## Installation
42
+
43
+ Add this line to your application's Gemfile:
44
+
45
+ gem 'memfs'
46
+
47
+ And then execute:
48
+
49
+ $ bundle
50
+
51
+ Or install it yourself as:
52
+
53
+ $ gem install memfs
54
+
55
+ ## Usage in tests
56
+
57
+ ### Global activation
58
+
59
+ Add the following to your `spec_helper.rb`:
60
+
61
+ ``` ruby
62
+ RSpec.configure do |config|
63
+ config.before do
64
+ MemFs.activate!
65
+ end
66
+
67
+ config.after do
68
+ MemFs.deactivate!
69
+ end
70
+ end
71
+ ```
72
+
73
+ All the spec will be sandboxed in MemFs.
74
+
75
+ ### Local activation
76
+
77
+ You can choose to activate MemFs only for a specific test:
78
+
79
+ ``` ruby
80
+ describe FileCreator do
81
+ describe '.create_file' do
82
+ it "creates a file" do
83
+ MemFs.activate do
84
+ subject.create_file('test.rb')
85
+ expect(File.exists?('test.rb')).to be_true
86
+ end
87
+ end
88
+ end
89
+ end
90
+ ```
91
+
92
+ No real file will be created during the test.
93
+
94
+ You can also use it for a specific `describe` block:
95
+
96
+ ``` ruby
97
+ describe FileCreator do
98
+ before { MemFs.activate! }
99
+ after { MemFs.deactivate! }
100
+
101
+ describe '.create_file' do
102
+ it "creates a file" do
103
+ subject.create_file('test.rb')
104
+ expect(File.exists?('test.rb')).to be_true
105
+ end
106
+ end
107
+ end
108
+ ```
109
+
110
+ ## Requirements
111
+
112
+ * Ruby 2.0+
113
+
114
+ ## Known issues
115
+
116
+ * MemFs doesn't implement IO so FileUtils.copy_stream is still the original one
117
+
118
+ ## TODO
119
+
120
+ * Implement missing methods from `File`, `Dir` and `Stat`
121
+
122
+ ## Contributing
123
+
124
+ 1. Fork it
125
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
126
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
127
+ 4. Push to the branch (`git push origin my-new-feature`)
128
+ 5. Create new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rspec/core/rake_task'
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec