public
Rubygem
Description: Take FogBugz offline with you
Clone URL: git://github.com/francois/fogbugz_offline.git
francois (author)
Thu May 15 12:48:24 -0700 2008
commit  f9b6b6fc00020aa8ebb945b0d108b665e6f624a1
tree    e4e3d98e59bed833be2e127364fdca7f2ccec1b4
parent  48cc76a33db52c4d500fde1c3ab76bc0f9ef16ea
fogbugz_offline / spec / fogbugz_offline_spec.rb
100644 46 lines (37 sloc) 1.586 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
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
 
describe FogbugzOffline, "#project_path" do
  before do
    Dir.stub!(:getwd).and_return("/home/me/project")
  end
 
  it "should instantiate a Pathname object" do
    Pathname.should_receive(:new).with(Dir.getwd).and_return(mock("pathname"))
    FogbugzOffline.project_path
  end
 
  it "should return a Pathname on the current working directory" do
    FogbugzOffline.project_path.should == Pathname.new(Dir.getwd)
  end
end