fun_with_testing 0.0.4 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,109 +0,0 @@
1
- module FunWith
2
- module Testing
3
- module Assertions
4
- module FunWithFiles
5
- def assert_fwf_filepath( file, message = "" )
6
- message = build_message( message, "File <#{file}> should be a FunWith::Files::FilePath")
7
-
8
- safe_assert_block message do
9
- file.is_a?( FunWith::Files::FilePath )
10
- end
11
- end
12
-
13
- def assert_file( file, message = "" )
14
- assert_fwf_filepath( file, message )
15
-
16
- message = build_message( message, "File should exist at <#{file}>." )
17
-
18
- safe_assert_block message do
19
- file.exist?
20
- end
21
- end
22
-
23
- def assert_no_file( file, message = "" )
24
- assert_fwf_filepath( file, message )
25
-
26
- message = build_message( message, "No file/directory should exist at <#{file}>." )
27
-
28
- safe_assert_block message do
29
- ! file.exist?
30
- end
31
- end
32
-
33
- def assert_directory( file, message = "" )
34
- assert_fwf_filepath( file, message )
35
-
36
- message = build_message( message, "<#{file}> should be a directory." )
37
-
38
-
39
- safe_assert_block message do
40
- file.directory?
41
- end
42
- end
43
-
44
- def assert_not_directory( file, message = "" )
45
- assert_fwf_filepath( file, message )
46
-
47
- message = build_message( message, "<#{file}> shouldn't be a directory." )
48
-
49
-
50
- safe_assert_block message do
51
- ! file.directory?
52
- end
53
- end
54
-
55
- def assert_empty_file( file, message = "" )
56
- assert_fwf_filepath( file, message )
57
-
58
- message = build_message( message, "Empty file should exist at <#{file}>." )
59
-
60
- safe_assert_block message do
61
- file.exist? && file.empty?
62
- end
63
- end
64
-
65
- def assert_empty_directory( file, message = "" )
66
- assert_fwf_filepath( file, message )
67
-
68
- message = build_message( message, "Empty directory should exist at <#{file}>." )
69
-
70
- safe_assert_block message do
71
- file.directory? && file.empty?
72
- end
73
- end
74
-
75
- def assert_file_has_content( file, message = "" )
76
- assert_fwf_filepath( file, message )
77
-
78
- message = build_message( message, "File should exist at <#{file}>, and have content." )
79
-
80
- safe_assert_block message do
81
- file.exist? && !file.empty?
82
- end
83
- end
84
-
85
- alias :assert_file_not_empty :assert_file_has_content
86
-
87
- def assert_file_contents( file, content, message = "" )
88
- assert_file( file )
89
-
90
- case content
91
- when String
92
- # message = build_message( message, "File <#{file}> contents should be #{content[0..99].inspect}#{'...(truncated)' if content.length > 100}" )
93
- assert_equal( content, file.read, message )
94
- when Regexp
95
- assert_match( content, file.read, message)
96
- end
97
- end
98
-
99
- # Actually, because FilePath responds to =~, assert_match may work for this
100
- # def assert_file_content_matches( file, regex_or_string, times = nil, message = "" )
101
- # if
102
- # if times.nil?
103
- #
104
- # end
105
- # end
106
- end
107
- end
108
- end
109
- end