rspec-file-transfer-matchers 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/History.txt +5 -0
- data/Manifest.txt +8 -0
- data/README.rdoc +162 -0
- data/Rakefile +19 -0
- data/lib/file_transfer_matchers.rb +31 -0
- data/lib/file_transfer_matchers/file_transfer_matcher.rb +100 -0
- data/lib/file_transfer_matchers/file_transfer_matchers.rb +34 -0
- data/spec/file_transfer_matchers_spec.rb +247 -0
- metadata +107 -0
- metadata.gz.sig +0 -0
data.tar.gz.sig
ADDED
Binary file
|
data/History.txt
ADDED
data/Manifest.txt
ADDED
data/README.rdoc
ADDED
@@ -0,0 +1,162 @@
|
|
1
|
+
= FileTransferMatchers
|
2
|
+
|
3
|
+
* Project: https://rubyforge.org/projects/aef/
|
4
|
+
* RDoc: http://aef.rubyforge.org/rspec-file-transfer-matchers/
|
5
|
+
* Github: http://github.com/aef/rspec-file-transfer-matchers/
|
6
|
+
|
7
|
+
== DESCRIPTION:
|
8
|
+
|
9
|
+
FileTransferMatchers are able to verify file movement, copying and deletion in
|
10
|
+
RSpec based automated tests.
|
11
|
+
|
12
|
+
== FEATURES/PROBLEMS:
|
13
|
+
|
14
|
+
* Tested and fully working on:
|
15
|
+
* Ubuntu Linux 8.10 i386_64 (Ruby 1.8.7 and 1.9.1p0)
|
16
|
+
* Debian GNU/Linux 4.0 i386 (Ruby 1.8.6)
|
17
|
+
* On Windows XP i386 (Ruby 1.8.6)
|
18
|
+
|
19
|
+
== SYNOPSIS:
|
20
|
+
|
21
|
+
Load the gem:
|
22
|
+
|
23
|
+
require 'file_transfer_matchers'
|
24
|
+
|
25
|
+
Include the matcher methods into the test case:
|
26
|
+
|
27
|
+
descripe Example do
|
28
|
+
include Aef::FileTransferMatchers
|
29
|
+
...
|
30
|
+
end
|
31
|
+
|
32
|
+
Test file movement:
|
33
|
+
|
34
|
+
it "should move a file" do
|
35
|
+
source = 'abc'
|
36
|
+
target = 'def'
|
37
|
+
|
38
|
+
lamda {
|
39
|
+
FileUtils.mv(source, target)
|
40
|
+
}.should move(source, :to => target)
|
41
|
+
end
|
42
|
+
|
43
|
+
Test file copying:
|
44
|
+
|
45
|
+
it "should copy file" do
|
46
|
+
source = 'abc'
|
47
|
+
target = 'def'
|
48
|
+
|
49
|
+
lamda {
|
50
|
+
FileUtils.cp(source, target)
|
51
|
+
}.should copy(source, :to => target)
|
52
|
+
end
|
53
|
+
|
54
|
+
Test file deletion:
|
55
|
+
|
56
|
+
it "should delete file" do
|
57
|
+
file = 'abc'
|
58
|
+
|
59
|
+
lamda {
|
60
|
+
FileUtils.rm(file)
|
61
|
+
}.should delete(file)
|
62
|
+
end
|
63
|
+
|
64
|
+
If you want to ignore an already existing target for move or copy:
|
65
|
+
|
66
|
+
it "should move a file" do
|
67
|
+
source = 'abc'
|
68
|
+
target = 'def'
|
69
|
+
|
70
|
+
lamda {
|
71
|
+
FileUtils.mv(source, target)
|
72
|
+
}.should move(source, :to => target, :overwrite => true)
|
73
|
+
end
|
74
|
+
|
75
|
+
== REQUIREMENTS:
|
76
|
+
|
77
|
+
* rspec
|
78
|
+
|
79
|
+
=== Additional for automated testing
|
80
|
+
* hoe
|
81
|
+
|
82
|
+
== INSTALL:
|
83
|
+
|
84
|
+
=== Normal
|
85
|
+
|
86
|
+
gem install rspec-file-transfer-matchers
|
87
|
+
|
88
|
+
=== High security (recommended)
|
89
|
+
|
90
|
+
There is a high security installation option available through rubygems. It is
|
91
|
+
highly recommended over the normal installation, although it may be a bit less
|
92
|
+
comfortable. To use the installation method, you will need my public key, which
|
93
|
+
I use for cryptographic signatures on all my gems. You can find the public key
|
94
|
+
and more detailed verification information in the aef-certificates section of my
|
95
|
+
rubyforge project[https://rubyforge.org/frs/?group_id=7890&release_id=31749]
|
96
|
+
|
97
|
+
Add the key to your rubygems' trusted certificates by the following command:
|
98
|
+
|
99
|
+
gem cert --add aef.pem
|
100
|
+
|
101
|
+
Now you can install the gem while automatically verifying it's signature by the
|
102
|
+
following command:
|
103
|
+
|
104
|
+
gem install rspec-file-transfer-matchers --ignore-dependencies -P HighSecurity
|
105
|
+
|
106
|
+
Please notice that you will need other keys for dependent libraries, so you may
|
107
|
+
have to install dependencies manually.
|
108
|
+
|
109
|
+
=== Automated testing
|
110
|
+
|
111
|
+
You can test this package through rspec on your system. First find the path
|
112
|
+
where the gem was installed to:
|
113
|
+
|
114
|
+
gem which rspec-file-transfer-matchers
|
115
|
+
|
116
|
+
Go into the root directory of the installed gem and run the following command
|
117
|
+
to start the test runner:
|
118
|
+
|
119
|
+
rake spec
|
120
|
+
|
121
|
+
On Windows systems you have to run the following instead:
|
122
|
+
|
123
|
+
spec spec/**/*_spec.rb
|
124
|
+
|
125
|
+
If something goes wrong you should be noticed through failing examples.
|
126
|
+
|
127
|
+
== DEVELOPMENT:
|
128
|
+
|
129
|
+
This software is developed in the source code management system git hosted
|
130
|
+
at github.com. You can download the most recent sourcecode through the following
|
131
|
+
command:
|
132
|
+
|
133
|
+
git clone git://github.com/aef/rspec-file-transfer-matchers.git
|
134
|
+
|
135
|
+
Help on making this software better is always very appreciated. If you want your
|
136
|
+
changes to be included in the official release, please send me a patch through
|
137
|
+
the project's tracker[https://rubyforge.org/tracker/?group_id=7890] at
|
138
|
+
rubyforge.org. You can generate a patch-file by the following command:
|
139
|
+
|
140
|
+
git diff > patch.diff
|
141
|
+
|
142
|
+
Please make sure to write tests for your changes and notice that I can't promise
|
143
|
+
to include your changes before reviewing them.
|
144
|
+
|
145
|
+
== LICENSE:
|
146
|
+
|
147
|
+
Copyright 2009 Alexander E. Fischer <aef@raxys.net>
|
148
|
+
|
149
|
+
This file is part of FileTransferMatchers.
|
150
|
+
|
151
|
+
FileTransferMatchers is free software: you can redistribute it and/or modify
|
152
|
+
it under the terms of the GNU General Public License as published by
|
153
|
+
the Free Software Foundation, either version 3 of the License, or
|
154
|
+
(at your option) any later version.
|
155
|
+
|
156
|
+
This program is distributed in the hope that it will be useful,
|
157
|
+
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
158
|
+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
159
|
+
GNU General Public License for more details.
|
160
|
+
|
161
|
+
You should have received a copy of the GNU General Public License
|
162
|
+
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
data/Rakefile
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- ruby -*-
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'hoe'
|
5
|
+
require './lib/file_transfer_matchers.rb'
|
6
|
+
|
7
|
+
Hoe.new('rspec-file-transfer-matchers', Aef::FileTransferMatchers::VERSION) do |p|
|
8
|
+
p.rubyforge_name = 'aef'
|
9
|
+
p.developer('Alexander E. Fischer', 'aef@raxys.net')
|
10
|
+
p.extra_deps = %w{rspec}
|
11
|
+
p.url = 'https://rubyforge.org/projects/aef/'
|
12
|
+
p.readme_file = 'README.rdoc'
|
13
|
+
p.extra_rdoc_files = %w{README.rdoc}
|
14
|
+
p.spec_extras = {
|
15
|
+
:rdoc_options => ['--main', 'README.rdoc', '--inline-source', '--line-numbers', '--title', 'FileTransferMatchers']
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
# vim: syntax=Ruby
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Copyright 2009 Alexander E. Fischer <aef@raxys.net>
|
2
|
+
#
|
3
|
+
# This file is part of FileTransferMatchers.
|
4
|
+
#
|
5
|
+
# FileTransferMatchers is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
# Namespace for projects of Alexander E. Fischer <aef@raxys.net>
|
19
|
+
#
|
20
|
+
# If you want to be able to simply type Example instead of Aef::Example to
|
21
|
+
# address classes in this namespace simply write the following before using the
|
22
|
+
# classes:
|
23
|
+
#
|
24
|
+
# include Aef
|
25
|
+
module Aef
|
26
|
+
|
27
|
+
end
|
28
|
+
|
29
|
+
libdir = File.dirname(__FILE__)
|
30
|
+
require File.join(libdir, 'file_transfer_matchers/file_transfer_matcher')
|
31
|
+
require File.join(libdir, 'file_transfer_matchers/file_transfer_matchers')
|
@@ -0,0 +1,100 @@
|
|
1
|
+
# Copyright 2009 Alexander E. Fischer <aef@raxys.net>
|
2
|
+
#
|
3
|
+
# This file is part of FileTransferMatchers.
|
4
|
+
#
|
5
|
+
# FileTransferMatchers is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
module Aef
|
19
|
+
class FileTransferMatcherError < StandardError; nil end
|
20
|
+
class SourceNotExistentError < FileTransferMatcherError; nil end
|
21
|
+
class TargetAlreadyExistentError < FileTransferMatcherError; nil end
|
22
|
+
class TargetNotExistentError < FileTransferMatcherError; nil end
|
23
|
+
class SourceStillExistentError < FileTransferMatcherError; nil end
|
24
|
+
|
25
|
+
class FileTransferMatcher
|
26
|
+
def initialize(from, options)
|
27
|
+
@from = from
|
28
|
+
@to = options[:to]
|
29
|
+
@copy_mode = options[:copy_mode]
|
30
|
+
@overwrite = options[:overwrite]
|
31
|
+
|
32
|
+
raise 'A target must be given in copy mode' if @copy_mode and not @to
|
33
|
+
end
|
34
|
+
|
35
|
+
def matches?(event_proc)
|
36
|
+
raise_block_syntax_error if block_given?
|
37
|
+
|
38
|
+
raise SourceNotExistentError unless File.exist?(@from)
|
39
|
+
raise TargetAlreadyExistentError if @to and File.exist?(@to) and not @overwrite
|
40
|
+
|
41
|
+
event_proc.call
|
42
|
+
|
43
|
+
raise TargetNotExistentError if @to and not File.exist?(@to)
|
44
|
+
raise SourceStillExistentError if not @copy_mode and File.exist?(@from)
|
45
|
+
|
46
|
+
true
|
47
|
+
rescue FileTransferMatcherError
|
48
|
+
@error = $!
|
49
|
+
false
|
50
|
+
end
|
51
|
+
|
52
|
+
def raise_block_syntax_error
|
53
|
+
raise MatcherError.new(<<-MESSAGE
|
54
|
+
block passed to should or should_not move/copy/delete must use {} instead of do/end
|
55
|
+
MESSAGE
|
56
|
+
)
|
57
|
+
end
|
58
|
+
|
59
|
+
def failure_message
|
60
|
+
case @error
|
61
|
+
when SourceNotExistentError
|
62
|
+
if @copy_mode
|
63
|
+
"File #{@from} could not be copied, as it does not exist"
|
64
|
+
elsif @to
|
65
|
+
"File #{@from} could not be moved, as it does not exist"
|
66
|
+
else
|
67
|
+
"File #{@from} could not be deleted, as it does not exist"
|
68
|
+
end
|
69
|
+
when TargetAlreadyExistentError
|
70
|
+
if @copy_mode
|
71
|
+
"File #{@from} could not be copied, as target #{@to} already exists"
|
72
|
+
else
|
73
|
+
"File #{@from} could not be moved, as target #{@to} already exists"
|
74
|
+
end
|
75
|
+
when TargetNotExistentError
|
76
|
+
if @copy_mode
|
77
|
+
"File #{@from} should have been copied to #{@to}, but target wasn't created"
|
78
|
+
else
|
79
|
+
"File #{@from} should have been moved to #{@to}, but target wasn't created"
|
80
|
+
end
|
81
|
+
when SourceStillExistentError
|
82
|
+
if @to
|
83
|
+
"File #{@from} should have been moved, but source file still exists"
|
84
|
+
else
|
85
|
+
"File #{@from} should have been deleted, but source file still exists"
|
86
|
+
end
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def negative_failure_message
|
91
|
+
if @copy_mode
|
92
|
+
"File #{@from} was copied to #{@to}"
|
93
|
+
elsif @to
|
94
|
+
"File #{@from} was moved to #{@to}"
|
95
|
+
else
|
96
|
+
"File #{@from} was deleted"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# Copyright 2009 Alexander E. Fischer <aef@raxys.net>
|
2
|
+
#
|
3
|
+
# This file is part of FileTransferMatchers.
|
4
|
+
#
|
5
|
+
# FileTransferMatchers is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
module Aef::FileTransferMatchers
|
19
|
+
VERSION = '1.0.0'
|
20
|
+
|
21
|
+
def move(from, options = {}, &block)
|
22
|
+
options[:copy_mode] = false
|
23
|
+
Aef::FileTransferMatcher.new(from, options, &block)
|
24
|
+
end
|
25
|
+
|
26
|
+
def copy(from, options = {}, &block)
|
27
|
+
options[:copy_mode] = true
|
28
|
+
Aef::FileTransferMatcher.new(from, options, &block)
|
29
|
+
end
|
30
|
+
|
31
|
+
def delete(file, &block)
|
32
|
+
Aef::FileTransferMatcher.new(file, :copy_mode => false, &block)
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
# Copyright 2009 Alexander E. Fischer <aef@raxys.net>
|
2
|
+
#
|
3
|
+
# This file is part of FileTransferMatchers.
|
4
|
+
#
|
5
|
+
# FileTransferMatchers is free software: you can redistribute it and/or modify
|
6
|
+
# it under the terms of the GNU General Public License as published by
|
7
|
+
# the Free Software Foundation, either version 3 of the License, or
|
8
|
+
# (at your option) any later version.
|
9
|
+
#
|
10
|
+
# This program is distributed in the hope that it will be useful,
|
11
|
+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
+
# GNU General Public License for more details.
|
14
|
+
#
|
15
|
+
# You should have received a copy of the GNU General Public License
|
16
|
+
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
+
|
18
|
+
require 'fileutils'
|
19
|
+
require 'tmpdir'
|
20
|
+
|
21
|
+
require 'lib/file_transfer_matchers'
|
22
|
+
|
23
|
+
describe Aef::FileTransferMatchers do
|
24
|
+
include Aef::FileTransferMatchers
|
25
|
+
|
26
|
+
before(:each) do
|
27
|
+
# Before ruby 1.8.7, the tmpdir standard library had no method to create
|
28
|
+
# a temporary directory (mktmpdir).
|
29
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('1.8.7')
|
30
|
+
@folder_path = File.join(Dir.tmpdir, 'file_transfer_matcher_spec')
|
31
|
+
Dir.mkdir(@folder_path)
|
32
|
+
else
|
33
|
+
@folder_path = Dir.mktmpdir('file_transfer_matcher_spec')
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
after(:each) do
|
38
|
+
FileUtils.rm_rf(@folder_path)
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should positively recognize a file deletion" do
|
42
|
+
file = File.join(@folder_path, 'toDelete')
|
43
|
+
|
44
|
+
FileUtils.touch(file)
|
45
|
+
|
46
|
+
action = lambda {
|
47
|
+
FileUtils.rm(file)
|
48
|
+
}
|
49
|
+
|
50
|
+
matcher = delete(file)
|
51
|
+
matcher.matches?(action).should be_true
|
52
|
+
matcher.negative_failure_message.should eql(
|
53
|
+
"File #{file} was deleted")
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
it "should positively recognize a file movement" do
|
58
|
+
file = File.join(@folder_path, 'toMove')
|
59
|
+
target = file + '.bak'
|
60
|
+
|
61
|
+
FileUtils.touch(file)
|
62
|
+
|
63
|
+
action = lambda {
|
64
|
+
FileUtils.mv(file, target)
|
65
|
+
}
|
66
|
+
|
67
|
+
matcher = move(file, :to => target)
|
68
|
+
matcher.matches?(action).should be_true
|
69
|
+
matcher.negative_failure_message.should eql(
|
70
|
+
"File #{file} was moved to #{target}")
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should positively recognize a file copying" do
|
74
|
+
file = File.join(@folder_path, 'toCopy')
|
75
|
+
target = file + '.bak'
|
76
|
+
|
77
|
+
FileUtils.touch(file)
|
78
|
+
|
79
|
+
action = lambda {
|
80
|
+
FileUtils.cp(file, target)
|
81
|
+
}
|
82
|
+
|
83
|
+
matcher = copy(file, :to => target)
|
84
|
+
matcher.matches?(action).should be_true
|
85
|
+
matcher.negative_failure_message.should eql(
|
86
|
+
"File #{file} was copied to #{target}")
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should negatively recognize a failed file deletion" do
|
90
|
+
file = File.join(@folder_path, 'toDelete')
|
91
|
+
|
92
|
+
action = lambda {}
|
93
|
+
|
94
|
+
matcher = delete(file)
|
95
|
+
matcher.matches?(action).should be_false
|
96
|
+
matcher.failure_message.should eql(
|
97
|
+
"File #{file} could not be deleted, as it does not exist")
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should negatively recognize if a move source is not existent" do
|
101
|
+
file = File.join(@folder_path, 'toMove')
|
102
|
+
target = file + '.bak'
|
103
|
+
|
104
|
+
action = lambda {}
|
105
|
+
|
106
|
+
matcher = move(file, :to => target)
|
107
|
+
matcher.matches?(action).should be_false
|
108
|
+
matcher.failure_message.should eql(
|
109
|
+
"File #{file} could not be moved, as it does not exist")
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should negatively recognize if a copy source is not existent" do
|
113
|
+
file = File.join(@folder_path, 'toCopy')
|
114
|
+
target = file + '.bak'
|
115
|
+
|
116
|
+
action = lambda {}
|
117
|
+
|
118
|
+
matcher = copy(file, :to => target)
|
119
|
+
matcher.matches?(action).should be_false
|
120
|
+
matcher.failure_message.should eql(
|
121
|
+
"File #{file} could not be copied, as it does not exist")
|
122
|
+
end
|
123
|
+
|
124
|
+
it "should negativly recognize if a move target already exists" do
|
125
|
+
file = File.join(@folder_path, 'toMove')
|
126
|
+
target = file + '.bak'
|
127
|
+
|
128
|
+
FileUtils.touch(file)
|
129
|
+
FileUtils.touch(target)
|
130
|
+
|
131
|
+
action = lambda {
|
132
|
+
FileUtils.mv(file, target)
|
133
|
+
}
|
134
|
+
|
135
|
+
matcher = move(file, :to => target)
|
136
|
+
matcher.matches?(action).should be_false
|
137
|
+
matcher.failure_message.should eql(
|
138
|
+
"File #{file} could not be moved, as target #{target} already exists")
|
139
|
+
end
|
140
|
+
|
141
|
+
it "should positively recognize if a move target already exists but overwrite is active" do
|
142
|
+
file = File.join(@folder_path, 'toMove')
|
143
|
+
target = file + '.bak'
|
144
|
+
|
145
|
+
FileUtils.touch(file)
|
146
|
+
FileUtils.touch(target)
|
147
|
+
|
148
|
+
action = lambda {
|
149
|
+
FileUtils.mv(file, target)
|
150
|
+
}
|
151
|
+
|
152
|
+
matcher = move(file, :to => target, :overwrite => true)
|
153
|
+
matcher.matches?(action).should be_true
|
154
|
+
end
|
155
|
+
|
156
|
+
it "should negativly recognize if a copy target already exists" do
|
157
|
+
file = File.join(@folder_path, 'toCopy')
|
158
|
+
target = file + '.bak'
|
159
|
+
|
160
|
+
FileUtils.touch(file)
|
161
|
+
FileUtils.touch(target)
|
162
|
+
|
163
|
+
action = lambda {
|
164
|
+
FileUtils.cp(file, target)
|
165
|
+
}
|
166
|
+
|
167
|
+
matcher = copy(file, :to => target)
|
168
|
+
matcher.matches?(action).should be_false
|
169
|
+
matcher.failure_message.should eql(
|
170
|
+
"File #{file} could not be copied, as target #{target} already exists")
|
171
|
+
end
|
172
|
+
|
173
|
+
it "should positively recognize if a copy target already exists but overwrite is active" do
|
174
|
+
file = File.join(@folder_path, 'toCopy')
|
175
|
+
target = file + '.bak'
|
176
|
+
|
177
|
+
FileUtils.touch(file)
|
178
|
+
FileUtils.touch(target)
|
179
|
+
|
180
|
+
action = lambda {
|
181
|
+
FileUtils.cp(file, target)
|
182
|
+
}
|
183
|
+
|
184
|
+
matcher = copy(file, :to => target, :overwrite => true)
|
185
|
+
matcher.matches?(action).should be_true
|
186
|
+
end
|
187
|
+
|
188
|
+
it "should negatively recognize if a move target doesn't get created" do
|
189
|
+
file = File.join(@folder_path, 'toMove')
|
190
|
+
target = file + '.bak'
|
191
|
+
|
192
|
+
FileUtils.touch(file)
|
193
|
+
|
194
|
+
action = lambda {}
|
195
|
+
|
196
|
+
matcher = move(file, :to => target)
|
197
|
+
matcher.matches?(action).should be_false
|
198
|
+
matcher.failure_message.should eql(
|
199
|
+
"File #{file} should have been moved to #{target}, but target wasn't created")
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should negatively recognize if a copy target doesn't get created" do
|
203
|
+
file = File.join(@folder_path, 'toCopy')
|
204
|
+
target = file + '.bak'
|
205
|
+
|
206
|
+
FileUtils.touch(file)
|
207
|
+
|
208
|
+
action = lambda {}
|
209
|
+
|
210
|
+
matcher = copy(file, :to => target)
|
211
|
+
matcher.matches?(action).should be_false
|
212
|
+
matcher.failure_message.should eql(
|
213
|
+
"File #{file} should have been copied to #{target}, but target wasn't created")
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should negatively recognize if a move source doesn't get deleted" do
|
217
|
+
file = File.join(@folder_path, 'toCopy')
|
218
|
+
target = file + '.bak'
|
219
|
+
|
220
|
+
FileUtils.touch(file)
|
221
|
+
|
222
|
+
action = lambda {
|
223
|
+
FileUtils.cp(file, target)
|
224
|
+
}
|
225
|
+
|
226
|
+
matcher = move(file, :to => target)
|
227
|
+
matcher.matches?(action).should be_false
|
228
|
+
matcher.failure_message.should eql(
|
229
|
+
"File #{file} should have been moved, but source file still exists")
|
230
|
+
end
|
231
|
+
|
232
|
+
it "should negatively recognize if a file doesn't get deleted" do
|
233
|
+
file = File.join(@folder_path, 'toCopy')
|
234
|
+
target = file + '.bak'
|
235
|
+
|
236
|
+
FileUtils.touch(file)
|
237
|
+
|
238
|
+
action = lambda {
|
239
|
+
FileUtils.cp(file, target)
|
240
|
+
}
|
241
|
+
|
242
|
+
matcher = delete(file)
|
243
|
+
matcher.matches?(action).should be_false
|
244
|
+
matcher.failure_message.should eql(
|
245
|
+
"File #{file} should have been deleted, but source file still exists")
|
246
|
+
end
|
247
|
+
end
|
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: rspec-file-transfer-matchers
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Alexander E. Fischer
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain:
|
11
|
+
- |
|
12
|
+
-----BEGIN CERTIFICATE-----
|
13
|
+
MIIDKDCCAhCgAwIBAgIBADANBgkqhkiG9w0BAQUFADA6MQwwCgYDVQQDDANhZWYx
|
14
|
+
FTATBgoJkiaJk/IsZAEZFgVyYXh5czETMBEGCgmSJomT8ixkARkWA25ldDAeFw0w
|
15
|
+
OTAyMjUyMDM5MDhaFw0xMDAyMjUyMDM5MDhaMDoxDDAKBgNVBAMMA2FlZjEVMBMG
|
16
|
+
CgmSJomT8ixkARkWBXJheHlzMRMwEQYKCZImiZPyLGQBGRYDbmV0MIIBIjANBgkq
|
17
|
+
hkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoYtj0qad5/MpbdttITzBH0h1SNe6eO7R
|
18
|
+
7qVeqNYu6qDQAQ0rYc0JhubJCWYrZEJorHEBhUFU6cdQgQOs78wiJaDgkeU7YfXB
|
19
|
+
q2l125kJ8aHkA1ukrK2/DRzp2AHEmzxHIYpXV5/63h+NWjCP+uKvTELYsotS2MKt
|
20
|
+
3d43E0QajsPZu2ZuNFwkroqeue872gMHUldGOVy5WtSd9ajw2xI/CociY6746dL+
|
21
|
+
pYriV3QaYtR/ezeaLpKBLsc5T1UQ07t7Xs7mI281tdmRvpLdP5dQhjzInfio0CJv
|
22
|
+
1Pf5bZUjGG0K9RW2Gb/tGPSYEETiLMubjH61OwBooXKiWR5cs4/1BQIDAQABozkw
|
23
|
+
NzAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNVHQ4EFgQUSYvjhG2EWnR5kx5l
|
24
|
+
DAewXCkJOVEwDQYJKoZIhvcNAQEFBQADggEBAB2ryDbU4bQtnunKv/AXq4CuO3LS
|
25
|
+
kik9Xhye8E/5dTcsgitCZJXAqx0rHcK0u2EHnjA5CDcdF5JB7XgSvRrQkFWoW/9K
|
26
|
+
lCB4ih+sB2AI2IUiYBeoCGctXdBQ020prqop/oTQEudzFk/gyQ686lp06HdLRt+O
|
27
|
+
HoQjTIab8vmfgIubjPdIRzokMfHbelvhLi+mQfWVghRhs2jpEfdXbL0w5nNw+trp
|
28
|
+
rO70Dw59hduDUOpgpxew+PLbs4vP1tb1QKPG+39C+PZtosbbf1fai0hqYV1txMCx
|
29
|
+
55akF+N8NbO6tpVDy6TMagqa10LfEpiQH6dvDHe/xdAqYOCrXKpmqzwu2PI=
|
30
|
+
-----END CERTIFICATE-----
|
31
|
+
|
32
|
+
date: 2009-04-09 00:00:00 +02:00
|
33
|
+
default_executable:
|
34
|
+
dependencies:
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: rspec
|
37
|
+
type: :runtime
|
38
|
+
version_requirement:
|
39
|
+
version_requirements: !ruby/object:Gem::Requirement
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: "0"
|
44
|
+
version:
|
45
|
+
- !ruby/object:Gem::Dependency
|
46
|
+
name: hoe
|
47
|
+
type: :development
|
48
|
+
version_requirement:
|
49
|
+
version_requirements: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: 1.12.1
|
54
|
+
version:
|
55
|
+
description: FileTransferMatchers are able to verify file movement, copying and deletion in RSpec based automated tests.
|
56
|
+
email:
|
57
|
+
- aef@raxys.net
|
58
|
+
executables: []
|
59
|
+
|
60
|
+
extensions: []
|
61
|
+
|
62
|
+
extra_rdoc_files:
|
63
|
+
- History.txt
|
64
|
+
- Manifest.txt
|
65
|
+
- README.rdoc
|
66
|
+
files:
|
67
|
+
- History.txt
|
68
|
+
- Manifest.txt
|
69
|
+
- README.rdoc
|
70
|
+
- Rakefile
|
71
|
+
- lib/file_transfer_matchers.rb
|
72
|
+
- lib/file_transfer_matchers/file_transfer_matchers.rb
|
73
|
+
- lib/file_transfer_matchers/file_transfer_matcher.rb
|
74
|
+
- spec/file_transfer_matchers_spec.rb
|
75
|
+
has_rdoc: true
|
76
|
+
homepage: https://rubyforge.org/projects/aef/
|
77
|
+
post_install_message:
|
78
|
+
rdoc_options:
|
79
|
+
- --main
|
80
|
+
- README.rdoc
|
81
|
+
- --inline-source
|
82
|
+
- --line-numbers
|
83
|
+
- --title
|
84
|
+
- FileTransferMatchers
|
85
|
+
require_paths:
|
86
|
+
- lib
|
87
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
88
|
+
requirements:
|
89
|
+
- - ">="
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: "0"
|
92
|
+
version:
|
93
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: "0"
|
98
|
+
version:
|
99
|
+
requirements: []
|
100
|
+
|
101
|
+
rubyforge_project: aef
|
102
|
+
rubygems_version: 1.3.1
|
103
|
+
signing_key:
|
104
|
+
specification_version: 2
|
105
|
+
summary: FileTransferMatchers are able to verify file movement, copying and deletion in RSpec based automated tests.
|
106
|
+
test_files: []
|
107
|
+
|
metadata.gz.sig
ADDED
Binary file
|