public
Rubygem
Description: Take FogBugz offline with you
Clone URL: git://github.com/francois/fogbugz_offline.git
francois (author)
Thu May 15 12:45:23 -0700 2008
commit  48cc76a33db52c4d500fde1c3ab76bc0f9ef16ea
tree    1d204cde16e600d563274b75f85fe4ff01034618
parent  160f048dde8b65ea59a46a7ac55400d934ec4602
fogbugz_offline / spec / fogbugz_offline_spec.rb
100644 31 lines (25 sloc) 1.16 kb
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
31
require File.dirname(__FILE__) + "/spec_helper"
 
describe FogbugzOffline, "#home_path" do
  before do
    ENV.stub!(:[]).with("HOME").and_return("/home/someuser")
    Pathname.stub!(:new).and_return(@pathname = mock("pathname"))
    @pathname.stub!(:exist?).and_return(true)
    @pathname.stub!(:directory?).and_return(true)
  end
 
  it "should raise an ArgumentError if ENV does not have a key by the name HOME" do
    ENV.should_receive(:[]).with("HOME").and_return(nil)
    lambda { FogbugzOffline.home_path }.should raise_error(ArgumentError)
  end
 
  it "should return a Pathname with the ENV[HOME] value" do
    Pathname.should_receive(:new).with("/home/someuser").and_return(@pathname)
    FogbugzOffline.home_path
  end
 
  it "should raise an ArgumentError if ENV[HOME] does not exist as a path" do
    @pathname.should_receive(:exist?).and_return(false)
    lambda { FogbugzOffline.home_path }.should raise_error(ArgumentError)
  end
 
  it "should raise an ArgumentError if ENV[HOME] is not a directory" do
    @pathname.should_receive(:directory?).and_return(false)
    lambda { FogbugzOffline.home_path }.should raise_error(ArgumentError)
  end
end