diff options
author | katherine <shmibs@shmibbles.me> | 2018-11-19 19:45:08 -0700 |
---|---|---|
committer | katherine <shmibs@shmibbles.me> | 2018-11-19 19:45:08 -0700 |
commit | 9511acbce2bb97526098047ed75fd9de5046bdc8 (patch) | |
tree | 4eb760731a7277d3c7a92b37c78b10a1d7b35b06 /spec | |
download | xdg_basedir-9511acbce2bb97526098047ed75fd9de5046bdc8.tar.gz |
initial commit! ヽ(^o^)丿
Diffstat (limited to 'spec')
-rw-r--r-- | spec/spec_helper.cr | 2 | ||||
-rw-r--r-- | spec/xdg_basedir_spec.cr | 50 |
2 files changed, 52 insertions, 0 deletions
diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr new file mode 100644 index 0000000..38f3f4a --- /dev/null +++ b/spec/spec_helper.cr @@ -0,0 +1,2 @@ +require "spec" +require "../src/xdg_basedir" diff --git a/spec/xdg_basedir_spec.cr b/spec/xdg_basedir_spec.cr new file mode 100644 index 0000000..1895439 --- /dev/null +++ b/spec/xdg_basedir_spec.cr @@ -0,0 +1,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 |