-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #389 from BBC-News/issue369
fix #369
- Loading branch information
Showing
2 changed files
with
34 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require "_helpers" | ||
|
||
describe "Wraith helpers classes and functions" do | ||
|
||
describe "the convert_to_absolute function" do | ||
it "should return false if no filepath provided" do | ||
expect(convert_to_absolute(nil)).to eq 'false' | ||
end | ||
|
||
it "should convert a relative path to absolute" do | ||
relative = 'my/filepath' | ||
absolute = convert_to_absolute relative | ||
expect(absolute[0]).to eq '/' | ||
expect(absolute.length).to be > relative.length | ||
expect(absolute).to match(/\/(.+)\/(.+)\/my\/filepath/) | ||
end | ||
|
||
it "should leave an absolute path unchanged" do | ||
relative = '/my/filepath' | ||
absolute = convert_to_absolute relative | ||
expect(absolute).to eq relative | ||
end | ||
|
||
it "should leave a Windows-flavoured absolute path unchanged" do | ||
relative = 'C:/Code/Wraith/javascript/global.js' | ||
absolute = convert_to_absolute relative | ||
expect(absolute).to eq relative | ||
end | ||
end | ||
|
||
end |