Skip to content

Commit ddb288f

Browse files
author
Nuo Yan
committed
updated file pathes in fileedit_spec.rb for use with rake spec
1 parent 614ef55 commit ddb288f

1 file changed

Lines changed: 23 additions & 23 deletions

File tree

chef/spec/unit/fileedit_spec.rb

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,33 @@
22

33
describe FileEdit, "initialiize" do
44
it "should create a new FileEdit object" do
5-
FileEdit.new("../../spec/data/fileedit/hosts").should be_kind_of(FileEdit)
5+
FileEdit.new("./spec/data/fileedit/hosts").should be_kind_of(FileEdit)
66
end
77

88
it "should throw an exception if the input file does not exist" do
99
lambda{FileEdit.new("nonexistfile")}.should raise_error
1010
end
1111

1212
it "should throw an exception if the input file is blank" do
13-
lambda{FileEdit.new("../../spec/data/fileedit/blank")}.should raise_error
13+
lambda{FileEdit.new("./spec/data/fileedit/blank")}.should raise_error
1414
end
1515

1616
end
1717

1818
describe FileEdit, "search_file_replace" do
1919

2020
it "should accept regex passed in as a string (not Regexp object) and replace the match if there is one" do
21-
helper_method("../../spec/data/fileedit/hosts", "localhost", true)
21+
helper_method("./spec/data/fileedit/hosts", "localhost", true)
2222
end
2323

2424

2525
it "should accept regex passed in as a Regexp object and replace the match if there is one" do
26-
helper_method("../../spec/data/fileedit/hosts", /localhost/, true)
26+
helper_method("./spec/data/fileedit/hosts", /localhost/, true)
2727
end
2828

2929

3030
it "should do nothing if there isn't a match" do
31-
helper_method("../../spec/data/fileedit/hosts", /pattern/, false)
31+
helper_method("./spec/data/fileedit/hosts", /pattern/, false)
3232
end
3333

3434

@@ -40,8 +40,8 @@ def helper_method(filename, regex, value)
4040
if value == true
4141
newfile = File.new(filename).readlines
4242
newfile[0].should match(/replacement/)
43-
File.delete("../../spec/data/fileedit/hosts")
44-
File.rename("../../spec/data/fileedit/hosts.old", "../../spec/data/fileedit/hosts")
43+
File.delete("./spec/data/fileedit/hosts")
44+
File.rename("./spec/data/fileedit/hosts.old", "./spec/data/fileedit/hosts")
4545
end
4646
end
4747

@@ -50,53 +50,53 @@ def helper_method(filename, regex, value)
5050
describe FileEdit, "search_file_replace_line" do
5151

5252
it "should search for match and replace the whole line" do
53-
fedit = FileEdit.new("../../spec/data/fileedit/hosts")
53+
fedit = FileEdit.new("./spec/data/fileedit/hosts")
5454
fedit.search_file_replace_line(/localhost/, "replacement line")
5555
fedit.write_file
56-
newfile = File.new("../../spec/data/fileedit/hosts").readlines
56+
newfile = File.new("./spec/data/fileedit/hosts").readlines
5757
newfile[0].should match(/replacement/)
5858
newfile[0].should_not match(/127/)
59-
File.delete("../../spec/data/fileedit/hosts")
60-
File.rename("../../spec/data/fileedit/hosts.old", "../../spec/data/fileedit/hosts")
59+
File.delete("./spec/data/fileedit/hosts")
60+
File.rename("./spec/data/fileedit/hosts.old", "./spec/data/fileedit/hosts")
6161
end
6262

6363
end
6464

6565
describe FileEdit, "search_file_delete" do
6666
it "should search for match and delete the match" do
67-
fedit = FileEdit.new("../../spec/data/fileedit/hosts")
67+
fedit = FileEdit.new("./spec/data/fileedit/hosts")
6868
fedit.search_file_delete(/localhost/)
6969
fedit.write_file
70-
newfile = File.new("../../spec/data/fileedit/hosts").readlines
70+
newfile = File.new("./spec/data/fileedit/hosts").readlines
7171
newfile[0].should_not match(/localhost/)
7272
newfile[0].should match(/127/)
73-
File.delete("../../spec/data/fileedit/hosts")
74-
File.rename("../../spec/data/fileedit/hosts.old", "../../spec/data/fileedit/hosts")
73+
File.delete("./spec/data/fileedit/hosts")
74+
File.rename("./spec/data/fileedit/hosts.old", "./spec/data/fileedit/hosts")
7575
end
7676
end
7777

7878
describe FileEdit, "search_file_delete_line" do
7979
it "should search for match and delete the matching line" do
80-
fedit = FileEdit.new("../../spec/data/fileedit/hosts")
80+
fedit = FileEdit.new("./spec/data/fileedit/hosts")
8181
fedit.search_file_delete_line(/localhost/)
8282
fedit.write_file
83-
newfile = File.new("../../spec/data/fileedit/hosts").readlines
83+
newfile = File.new("./spec/data/fileedit/hosts").readlines
8484
newfile[0].should_not match(/localhost/)
8585
newfile[0].should match(/broadcasthost/)
86-
File.delete("../../spec/data/fileedit/hosts")
87-
File.rename("../../spec/data/fileedit/hosts.old", "../../spec/data/fileedit/hosts")
86+
File.delete("./spec/data/fileedit/hosts")
87+
File.rename("./spec/data/fileedit/hosts.old", "./spec/data/fileedit/hosts")
8888
end
8989
end
9090

9191
describe FileEdit, "insert_line_after_match" do
9292
it "should search for match and insert the given line after the matching line" do
93-
fedit = FileEdit.new("../../spec/data/fileedit/hosts")
93+
fedit = FileEdit.new("./spec/data/fileedit/hosts")
9494
fedit.insert_line_after_match(/localhost/, "new line inserted")
9595
fedit.write_file
96-
newfile = File.new("../../spec/data/fileedit/hosts").readlines
96+
newfile = File.new("./spec/data/fileedit/hosts").readlines
9797
newfile[1].should match(/new/)
98-
File.delete("../../spec/data/fileedit/hosts")
99-
File.rename("../../spec/data/fileedit/hosts.old", "../../spec/data/fileedit/hosts")
98+
File.delete("./spec/data/fileedit/hosts")
99+
File.rename("./spec/data/fileedit/hosts.old", "./spec/data/fileedit/hosts")
100100
end
101101

102102
end

0 commit comments

Comments
 (0)