file_sandbox 0.5 → 0.6

Sign up to get free protection for your applications and to get access to all the features.
File without changes
data/README.txt CHANGED
@@ -8,16 +8,14 @@ File sandbox creates a space for your tests to safely hit the file system. It al
8
8
 
9
9
  in rspec :
10
10
 
11
- require 'rubygems'
12
- require 'spec'
13
11
  require 'file_sandbox_behavior'
14
-
12
+
15
13
  describe File do
16
14
  include FileSandbox
17
-
15
+
18
16
  it 'should read the contents of a file' do
19
17
  sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'
20
-
18
+
21
19
  sandbox['/b/a.txt'].contents.should == 'some stuff'
22
20
  File.read(sandbox.root + "/b/a.txt").should == 'some stuff'
23
21
  end
@@ -25,23 +23,22 @@ in rspec :
25
23
 
26
24
  in test unit :
27
25
 
28
- require 'rubygems'
29
26
  require 'test/unit'
30
27
  require 'file_sandbox'
31
-
28
+
32
29
  class MyFileTest < Test::Unit::TestCase
33
30
  include FileSandbox
34
-
31
+
35
32
  def test_read
36
33
  in_sandbox do |sandbox|
37
34
  sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'
38
-
35
+
39
36
  assert_equal 'some stuff', File.read(sandbox.root + '/b/a.txt')
40
37
  assert_equal 'some stuff', sandbox['/b/a.txt'].contents
41
38
  end
42
39
  end
43
40
  end
44
-
41
+
45
42
 
46
43
  == Contact
47
44
 
@@ -51,4 +48,4 @@ License:: LGPL License
51
48
 
52
49
  == Home Page
53
50
 
54
- http://onemanswalk.com
51
+ http://onemanswalk.com
data/Rakefile CHANGED
@@ -1,9 +1,10 @@
1
- require 'rubygems'
2
1
  require 'rake/clean'
3
2
  require 'rake/testtask'
4
- require 'spec/rake/spectask'
3
+ require 'rspec/core/rake_task'
5
4
  require 'hoe'
6
- require './lib/file_sandbox.rb'
5
+
6
+ $LOAD_PATH.unshift File.dirname(__FILE__) + "/lib"
7
+ require 'file_sandbox'
7
8
 
8
9
  desc "Default Task"
9
10
  task :default => [:clean, :test]
@@ -11,8 +12,9 @@ task :default => [:clean, :test]
11
12
  desc "Run all tests"
12
13
  task :test => [:unit, :spec]
13
14
 
14
- Spec::Rake::SpecTask.new(:spec) do |t|
15
- t.spec_files = FileList['examples/*_example.rb']
15
+ desc "Run specs"
16
+ RSpec::Core::RakeTask.new do |t|
17
+ t.pattern = "./examples/*.rb"
16
18
  end
17
19
 
18
20
  Rake::TestTask.new(:unit) do |t|
@@ -20,7 +22,6 @@ Rake::TestTask.new(:unit) do |t|
20
22
  t.verbose = false
21
23
  end
22
24
 
23
-
24
25
  Hoe.new('file_sandbox', FileSandbox::VERSION) do |p|
25
26
  p.rubyforge_name = 'filesandbox'
26
27
  p.summary = p.description = p.paragraphs_of('README.txt', 2).first
@@ -1,14 +1,12 @@
1
1
  $LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
2
- require 'rubygems'
3
- require 'spec'
4
2
  require 'file_sandbox_behavior'
5
3
 
6
4
  describe File do
7
5
  include FileSandbox
8
-
6
+
9
7
  it 'should read the contents of a file' do
10
8
  sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'
11
-
9
+
12
10
  sandbox['/b/a.txt'].contents.should == 'some stuff'
13
11
  File.read(sandbox.root + "/b/a.txt").should == 'some stuff'
14
12
  end
@@ -1,5 +1,4 @@
1
1
  $LOAD_PATH.unshift File.dirname(__FILE__) + "/../lib"
2
- require 'rubygems'
3
2
  require 'test/unit'
4
3
  require 'file_sandbox'
5
4
 
@@ -9,7 +8,7 @@ class MyFileTest < Test::Unit::TestCase
9
8
  def test_read
10
9
  in_sandbox do |sandbox|
11
10
  sandbox.new :file => 'b/a.txt', :with_contents => 'some stuff'
12
-
11
+
13
12
  assert_equal 'some stuff', File.read(sandbox.root + '/b/a.txt')
14
13
  assert_equal 'some stuff', sandbox['/b/a.txt'].contents
15
14
  end
@@ -1,12 +1,11 @@
1
- require 'ftools'
2
1
  require 'fileutils'
3
2
  require 'test/unit/assertions'
4
3
 
5
4
  module FileSandbox
6
- VERSION = "0.5"
7
-
5
+ VERSION = "0.6"
6
+
8
7
  attr_reader :sandbox
9
-
8
+
10
9
  def in_sandbox(&block)
11
10
  raise "I expected to create a sandbox as you passed in a block to me" if !block_given?
12
11
 
@@ -56,7 +55,7 @@ module FileSandbox
56
55
  clean_up
57
56
  FileUtils.mkdir_p @root
58
57
  end
59
-
58
+
60
59
  def [](name)
61
60
  SandboxFile.new(File.join(@root, name))
62
61
  end
@@ -74,17 +73,17 @@ module FileSandbox
74
73
  file.content = (options.delete(:with_content) || options.delete(:with_contents) || '')
75
74
  end
76
75
  end
77
-
76
+
78
77
  raise "unexpected keys '#{options.keys.join(', ')}'" unless options.empty?
79
-
78
+
80
79
  dir || file
81
80
  end
82
-
81
+
83
82
  def remove(options)
84
83
  name = File.join(@root, options[:file])
85
84
  FileUtils.remove_file name
86
85
  end
87
-
86
+
88
87
  # usage assert :file=>'my file.rb', :has_contents=>'some stuff'
89
88
  def assert(options)
90
89
  name = File.join(@root, options[:file])
@@ -105,7 +104,7 @@ module FileSandbox
105
104
 
106
105
  class SandboxFile
107
106
  attr_reader :path
108
-
107
+
109
108
  def initialize(path)
110
109
  @path = path
111
110
  end
@@ -117,12 +116,12 @@ module FileSandbox
117
116
  def content
118
117
  File.read path
119
118
  end
120
-
119
+
121
120
  def content=(content)
122
121
  FileUtils.mkdir_p File.dirname(@path)
123
122
  File.open(@path, "w") {|f| f << content}
124
123
  end
125
-
124
+
126
125
  def binary_content=(content)
127
126
  FileUtils.mkdir_p File.dirname(@path)
128
127
  File.open(@path, "wb") {|f| f << content}
@@ -135,15 +134,15 @@ module FileSandbox
135
134
  alias exists? exist?
136
135
  alias contents content
137
136
  alias contents= content=
138
- alias binary_contents= binary_content=
137
+ alias binary_contents= binary_content=
139
138
  end
140
-
139
+
141
140
  private
142
-
141
+
143
142
  def silence_warnings
144
143
  old_verbose, $VERBOSE = $VERBOSE, nil
145
144
  yield
146
145
  ensure
147
146
  $VERBOSE = old_verbose
148
147
  end
149
- end
148
+ end
@@ -1,4 +1,4 @@
1
- require File.dirname(__FILE__) + '/file_sandbox'
1
+ require 'file_sandbox'
2
2
 
3
3
  module FileSandbox
4
4
  def self.included(spec)
@@ -13,6 +13,7 @@ class FileSandboxTest < Test::Unit::TestCase
13
13
  end
14
14
 
15
15
  def test_sandbox_cleans_up_file
16
+ name = nil
16
17
  in_sandbox do |sandbox|
17
18
  name = sandbox.root + "/a.txt"
18
19
 
metadata CHANGED
@@ -1,7 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: file_sandbox
3
3
  version: !ruby/object:Gem::Version
4
- version: "0.5"
4
+ prerelease:
5
+ version: "0.6"
5
6
  platform: ruby
6
7
  authors:
7
8
  - Jeremy Stell-Smith
@@ -9,19 +10,30 @@ autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2008-08-07 00:00:00 -07:00
13
- default_executable:
13
+ date: 2012-03-20 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
- name: hoe
16
+ name: rdoc
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ~>
22
+ - !ruby/object:Gem::Version
23
+ version: "3.10"
17
24
  type: :development
18
- version_requirement:
19
- version_requirements: !ruby/object:Gem::Requirement
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: hoe
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
20
31
  requirements:
21
- - - ">="
32
+ - - ~>
22
33
  - !ruby/object:Gem::Version
23
- version: 1.7.0
24
- version:
34
+ version: "2.16"
35
+ type: :development
36
+ version_requirements: *id002
25
37
  description: File sandbox creates a space for your tests to safely hit the file system. It also makes it easier for them to do so. By cleaning up after them.
26
38
  email: jeremystellsmith@gmail.com
27
39
  executables: []
@@ -42,8 +54,10 @@ files:
42
54
  - lib/file_sandbox.rb
43
55
  - lib/file_sandbox_behavior.rb
44
56
  - test/file_sandbox_test.rb
45
- has_rdoc: true
57
+ - .gemtest
46
58
  homepage: http://onemanswalk.com
59
+ licenses: []
60
+
47
61
  post_install_message:
48
62
  rdoc_options:
49
63
  - --main
@@ -51,23 +65,23 @@ rdoc_options:
51
65
  require_paths:
52
66
  - lib
53
67
  required_ruby_version: !ruby/object:Gem::Requirement
68
+ none: false
54
69
  requirements:
55
70
  - - ">="
56
71
  - !ruby/object:Gem::Version
57
72
  version: "0"
58
- version:
59
73
  required_rubygems_version: !ruby/object:Gem::Requirement
74
+ none: false
60
75
  requirements:
61
76
  - - ">="
62
77
  - !ruby/object:Gem::Version
63
78
  version: "0"
64
- version:
65
79
  requirements: []
66
80
 
67
81
  rubyforge_project: filesandbox
68
- rubygems_version: 1.2.0
82
+ rubygems_version: 1.8.16
69
83
  signing_key:
70
- specification_version: 2
84
+ specification_version: 3
71
85
  summary: File sandbox creates a space for your tests to safely hit the file system. It also makes it easier for them to do so. By cleaning up after them.
72
86
  test_files: []
73
87