public
Rubygem
Description: Take FogBugz offline with you
Clone URL: git://github.com/francois/fogbugz_offline.git
Search Repo:
FogbugzOffline#home_path specifications.
francois (author)
Thu May 15 12:45:23 -0700 2008
commit  48cc76a33db52c4d500fde1c3ab76bc0f9ef16ea
tree    1d204cde16e600d563274b75f85fe4ff01034618
parent  160f048dde8b65ea59a46a7ac55400d934ec4602
...
2
3
4
 
 
5
6
7
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
8
9
10
...
2
3
4
5
6
7
 
 
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
0
@@ -2,9 +2,27 @@
0
 require "fogbugz_offline/connection"
0
 require "fogbugz_offline/commands"
0
 
0
+require "pathname"
0
+
0
 module FogbugzOffline
0
- def self.config
0
- FogbugzOffline::Config.instance
0
+ def self.home_path
0
+ raise ArgumentError, "$HOME is undefined -- cannot proceed. Define it in your environment." unless ENV["HOME"]
0
+ pathname = Pathname.new(ENV["HOME"])
0
+ raise ArgumentError, "$HOME is defined as #{pathname}, but does not exist." unless pathname.exist?
0
+ raise ArgumentError, "$HOME is defined as #{pathname}, but is not a directory." unless pathname.directory?
0
+ pathname
0
+ end
0
+
0
+ def self.project_path
0
+ Pathname.new(Dir.getwd)
0
+ end
0
+
0
+ def self.global
0
+ FogbugzOffline::Config.new(home_path + ".fogbugz_offline/config.yml")
0
+ end
0
+
0
+ def self.local
0
+ FogbugzOffline::Config.new(project_path + ".fogbugz_offline/config.yml")
0
   end
0
 
0
   def self.connection_to(url)
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
0
@@ -1 +1,31 @@
0
+require File.dirname(__FILE__) + "/spec_helper"
0
+
0
+describe FogbugzOffline, "#home_path" do
0
+ before do
0
+ ENV.stub!(:[]).with("HOME").and_return("/home/someuser")
0
+ Pathname.stub!(:new).and_return(@pathname = mock("pathname"))
0
+ @pathname.stub!(:exist?).and_return(true)
0
+ @pathname.stub!(:directory?).and_return(true)
0
+ end
0
+
0
+ it "should raise an ArgumentError if ENV does not have a key by the name HOME" do
0
+ ENV.should_receive(:[]).with("HOME").and_return(nil)
0
+ lambda { FogbugzOffline.home_path }.should raise_error(ArgumentError)
0
+ end
0
+
0
+ it "should return a Pathname with the ENV[HOME] value" do
0
+ Pathname.should_receive(:new).with("/home/someuser").and_return(@pathname)
0
+ FogbugzOffline.home_path
0
+ end
0
+
0
+ it "should raise an ArgumentError if ENV[HOME] does not exist as a path" do
0
+ @pathname.should_receive(:exist?).and_return(false)
0
+ lambda { FogbugzOffline.home_path }.should raise_error(ArgumentError)
0
+ end
0
+
0
+ it "should raise an ArgumentError if ENV[HOME] is not a directory" do
0
+ @pathname.should_receive(:directory?).and_return(false)
0
+ lambda { FogbugzOffline.home_path }.should raise_error(ArgumentError)
0
+ end
0
+end

Comments

    No one has commented yet.