blob: 18954391a88681ac5f9efc00886d009a812145b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
require "./spec_helper"
# NOTE: these tests are non-exhaustive and may fail, as they depend on the
# state of the filesystem and environment
describe XDGBasedir do
it "finds previously written files using full_path" do
p = XDGBasedir.full_path "xdg_basedir_test_file_1", :data, "w"
unless p
next
end
File.write p, "content"
p = XDGBasedir.full_path "xdg_basedir_test_file_1", :data, "r"
unless p
next
end
s = File.read p
f = File.new p
f.delete
s.should eq("content")
end
it "finds previously written files using dir methods" do
d = XDGBasedir.write_dir :config
unless d
next
end
File.write "#{d}xdg_basedir_test_file_2" , "content"
l = XDGBasedir.read_dirs :config
unless l
next
end
s = File.read "#{l[0]}xdg_basedir_test_file_2"
f = File.new "#{d}xdg_basedir_test_file_2"
f.delete
s.should eq("content")
end
it "fails on bad arguments" do
expect_raises(ArgumentError) { XDGBasedir.write_dir :bad }
expect_raises(ArgumentError) { XDGBasedir.read_dirs :bad }
expect_raises(ArgumentError) { XDGBasedir.full_path "rel_path", :bad }
end
end
|