filetesthelper 0.9.1 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.txt +2 -5
- data/Rakefile.rb +2 -2
- data/lib/filetesthelper.rb +0 -2
- data/spec/FileTestHelper_spec.rb +19 -39
- data/spec/spec.opts +3 -4
- metadata +3 -3
data/README.txt
CHANGED
@@ -2,10 +2,7 @@
|
|
2
2
|
|
3
3
|
A simple helper aimed at reducing the setup effort needed to create directories, files and file content in the scope of an integration test case.
|
4
4
|
|
5
|
-
==
|
6
|
-
gem install filetesthelper
|
7
|
-
|
8
|
-
== Usage
|
5
|
+
== Example
|
9
6
|
|
10
7
|
require 'rubygems'
|
11
8
|
require 'filetesthelper'
|
@@ -26,5 +23,5 @@ A simple helper aimed at reducing the setup effort needed to create directories,
|
|
26
23
|
#When we finish we are back at directory X and the Y directory is deleted with all its contents
|
27
24
|
end
|
28
25
|
|
29
|
-
See the
|
26
|
+
See the specs for more details.
|
30
27
|
|
data/Rakefile.rb
CHANGED
@@ -7,7 +7,7 @@ require 'rake/gempackagetask'
|
|
7
7
|
require 'spec/rake/spectask'
|
8
8
|
|
9
9
|
NAME = 'filetesthelper'
|
10
|
-
PKGVERSION = '0.
|
10
|
+
PKGVERSION = '1.0.0'
|
11
11
|
is_windows = (PLATFORM =~ /win32|cygwin/)
|
12
12
|
SUDO = is_windows ? '' : 'sudo'
|
13
13
|
README = "README.txt"
|
@@ -22,7 +22,7 @@ CLEAN.include ["pkg", "coverage", "doc"]
|
|
22
22
|
spec = Gem::Specification.new do |s|
|
23
23
|
s.name = NAME
|
24
24
|
s.version = PKGVERSION
|
25
|
-
s.author = "Daniel Cadenas
|
25
|
+
s.author = "Daniel Cadenas Ni�n"
|
26
26
|
s.email = "filetesthelper-devel@rubyforge.org"
|
27
27
|
s.homepage = "http://rubyforge.org/projects/filetesthelper/"
|
28
28
|
s.platform = Gem::Platform::RUBY
|
data/lib/filetesthelper.rb
CHANGED
@@ -34,8 +34,6 @@ module FileTestHelper
|
|
34
34
|
|
35
35
|
def create_files_in_working_directory(working_directory, files_with_contents)
|
36
36
|
cd working_directory
|
37
|
-
|
38
|
-
return unless files_with_contents
|
39
37
|
files_with_contents.each do |path, file_contents|
|
40
38
|
fail 'A path is not allowed to start with /' if path =~ /^\//
|
41
39
|
fail 'A path is not allowed to contain ..' if path =~ /\.\./
|
data/spec/FileTestHelper_spec.rb
CHANGED
@@ -4,46 +4,30 @@ require 'spec'
|
|
4
4
|
require 'filetesthelper'
|
5
5
|
include FileTestHelper
|
6
6
|
|
7
|
-
|
8
|
-
'
|
9
|
-
|
10
|
-
|
11
|
-
}
|
12
|
-
|
13
|
-
parameters.each do |parameter_name, parameter|
|
14
|
-
describe FileTestHelper, "when the hash paramater is #{parameter_name}" do
|
15
|
-
it 'should execute the block parameter' do
|
16
|
-
block_runned = false
|
17
|
-
with_files(parameter) {block_runned = true}
|
18
|
-
block_runned.should be_true
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should not use the current directory' do
|
22
|
-
initial_directory = Dir.pwd
|
23
|
-
with_files(parameter) do
|
24
|
-
Dir.pwd.should_not == initial_directory
|
25
|
-
end
|
26
|
-
Dir.pwd.should == initial_directory
|
7
|
+
describe FileTestHelper do
|
8
|
+
it 'should start in an empty working directory' do
|
9
|
+
with_files() do
|
10
|
+
Dir.glob('**/*').size == 0
|
27
11
|
end
|
12
|
+
end
|
28
13
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
14
|
+
it 'should not use the current directory as default' do
|
15
|
+
initial_directory = Dir.pwd
|
16
|
+
with_files() do
|
17
|
+
Dir.pwd.should_not == initial_directory
|
33
18
|
end
|
19
|
+
Dir.pwd.should == initial_directory
|
20
|
+
end
|
34
21
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
end
|
40
|
-
working_directory_path.should_not be_empty
|
41
|
-
File.exist?(working_directory_path).should be_false
|
22
|
+
it 'should delete the working directory and its contents after use' do
|
23
|
+
working_directory_path = ''
|
24
|
+
with_files() do
|
25
|
+
working_directory_path = Dir.pwd
|
42
26
|
end
|
27
|
+
working_directory_path.should_not be_empty
|
28
|
+
File.exist?(working_directory_path).should be_false
|
43
29
|
end
|
44
|
-
|
45
|
-
|
46
|
-
describe FileTestHelper do
|
30
|
+
|
47
31
|
it 'should create the files and directories that were specified in a hash' do
|
48
32
|
files_to_create = {'a directory/a file.txt' => '', 'a directory/another file.rb' => '', 'an_empty_directory/' => '', 'a_file' => ''}
|
49
33
|
with_files(files_to_create) do
|
@@ -75,8 +59,4 @@ describe FileTestHelper do
|
|
75
59
|
it 'should throw an error if a path uses ".."' do
|
76
60
|
lambda { with_files('../../dir/filea' => 'content of filea') {}}.should raise_error
|
77
61
|
end
|
78
|
-
|
79
|
-
it 'should not throw an exception when the hash parameter is nil' do
|
80
|
-
lambda { with_files(nil) {}}.should_not raise_error
|
81
|
-
end
|
82
|
-
end
|
62
|
+
end
|
data/spec/spec.opts
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: filetesthelper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
- "Daniel Cadenas Ni\
|
7
|
+
- "Daniel Cadenas Ni\xF3n"
|
8
8
|
autorequire: filetesthelper
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2008-03-
|
12
|
+
date: 2008-03-08 00:00:00 -02:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|