From 9511acbce2bb97526098047ed75fd9de5046bdc8 Mon Sep 17 00:00:00 2001 From: katherine Date: Mon, 19 Nov 2018 19:45:08 -0700 Subject: =?UTF-8?q?initial=20commit!=20=E3=83=BD(^o^)=E4=B8=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- spec/spec_helper.cr | 2 ++ spec/xdg_basedir_spec.cr | 50 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+) create mode 100644 spec/spec_helper.cr create mode 100644 spec/xdg_basedir_spec.cr (limited to 'spec') 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 -- cgit v1.2.3