dotify 0.5.1 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,113 +0,0 @@
1
- require 'spec_helper'
2
- require 'dotify/config'
3
- require 'dotify/file_list'
4
-
5
- describe Dotify::FileList do
6
-
7
- describe Dotify::FileList, "#home" do
8
- before do
9
- Dotify::Config.stub(:home).and_return("/home/test")
10
- end
11
- it "should call FileList#list with the correct path" do
12
- Dotify::FileList.should_receive(:paths) \
13
- .with("/home/test/.*").once \
14
- .and_return(['/root/test/.vimrc', '/root/test/.bashrc', '/root/test/.zshrc'])
15
- Dotify::FileList.home
16
- end
17
- it "should drop files that have been specified to be ignored" do
18
- Dotify::FileList.stub(:paths) do
19
- ['/root/test/.gitconfig', '/root/test/.vimrc', '/root/test/.bashrc', '/root/test/.zshrc']
20
- end
21
- Dotify::Config.stub(:ignore).with(:dotfiles).and_return %w[.zshrc .vimrc]
22
- result = Dotify::FileList.home
23
- result.should include '/root/test/.bashrc'
24
- result.should include '/root/test/.gitconfig'
25
- result.should_not include '/root/test/.zshrc'
26
- result.should_not include '/root/test/.vimrc'
27
- end
28
- end
29
-
30
- describe Dotify::FileList, "#dotify" do
31
- it "should call FileList#list with the correct path" do
32
- Dotify::Config.stub(:path).and_return("/home/test/.dotify")
33
- Dotify::FileList.should_receive(:paths) \
34
- .with("/home/test/.dotify/.*").once \
35
- .and_return(['/spec/test/.vimrc', '/spec/test/.bashrc', '/spec/test/.zshrc'])
36
- Dotify::FileList.dotify
37
- end
38
- it "should drop files that have been specified to be ignored" do
39
- Dotify::FileList.stub(:paths) do
40
- ['/dotify/test/.gitconfig', '/dotify/test/.vimrc', '/dotify/test/.bashrc', '/dotify/test/.zshrc']
41
- end
42
- Dotify::Config.stub(:ignore).with(:dotify).and_return %w[.gitconfig .bashrc]
43
- result = Dotify::FileList.dotify
44
- result.should include '/dotify/test/.vimrc'
45
- result.should include '/dotify/test/.zshrc'
46
- result.should_not include '/dotify/test/.bashrc'
47
- result.should_not include '/dotify/test/.gitconfig'
48
- end
49
- end
50
-
51
- describe Dotify::FileList, "#list" do
52
- let(:glob) { '/spec/test/.*' }
53
- it "should pull the glob of dotfiles from a directory" do
54
- Dir.should_receive(:[]).with(glob).and_return(%w[. .. /spec/test/.vimrc /spec/test/.bashrc /spec/test/.zshrc])
55
- Dotify::FileList.list(glob)
56
- end
57
- describe "return values" do
58
- before do
59
- Dir.stub(:[]).with(glob).and_return(%w[. .. /spec/test/.vimrc /spec/test/.bashrc /spec/test/.zshrc])
60
- end
61
- let(:files) { Dotify::FileList.list(glob) }
62
- it "should return the right filenames" do
63
- files.should include '.vimrc'
64
- files.should include '.bashrc'
65
- files.should include '.zshrc'
66
- end
67
- it "should filter out . and .. directories" do
68
- files.should_not include '.'
69
- files.should_not include '..'
70
- end
71
- end
72
- end
73
-
74
- describe Dotify::FileList, "#paths" do
75
- let(:glob) { '/spec/test/.*' }
76
- it "should pull the glob of dotfiles from a directory" do
77
- Dir.should_receive(:[]).with(glob).and_return(%w[. .. /spec/test/.vimrc /spec/test/.bashrc /spec/test/.zshrc])
78
- Dotify::FileList.paths(glob)
79
- end
80
- describe "return values" do
81
- before do
82
- Dir.stub(:[]).with(glob).and_return(%w[. .. /spec/test/.vimrc /spec/test/.bashrc /spec/test/.zshrc])
83
- end
84
- let(:files) { Dotify::FileList.paths(glob) }
85
- it "should return the right directories" do
86
- files.should include '/spec/test/.vimrc'
87
- files.should include '/spec/test/.bashrc'
88
- files.should include '/spec/test/.zshrc'
89
- end
90
- it "should filter out . and .. directories" do
91
- files = Dotify::FileList.paths(glob)
92
- files.should_not include '.'
93
- files.should_not include '..'
94
- end
95
- end
96
- end
97
-
98
- describe Dotify::FileList, "#filenames" do
99
- let(:files) { %w[/spec/test/.vimrc /spec/test/.bashrc /spec/test/.zshrc] }
100
- it "should use Files#filename to change the files" do
101
- Dotify::Files.should_receive(:filename).exactly(files.count).times
102
- Dotify::FileList.filenames(files)
103
- end
104
- it "return only" do
105
- result = Dotify::FileList.filenames(files)
106
- result.should include '.vimrc'
107
- result.should include '.bashrc'
108
- result.should include '.zshrc'
109
- end
110
- end
111
-
112
-
113
- end