contrast / exceptional

This URL has Read+Write access

Eoghan McCabe (author)
Thu Jul 09 07:05:55 -0700 2009
commit  fc75a8b99a5dce282f67905d7d2e2f18a21fec8a
tree    88ffcb04f37eeb7c85fc2b309c1263daf06af2e8
parent  0157bb1526fb173fd9b29bbedcfd6a66b2dc36fd
exceptional / spec / bootstrap_spec.rb
100644 59 lines (42 sloc) 2.078 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
47
48
49
50
51
52
53
54
55
56
57
58
59
require File.dirname(__FILE__) + '/spec_helper'
 
 
describe Exceptional::Bootstrap do
 
 
  describe "setup" do
 
    TEST_ENVIRONMENT= "development"
 
    it "should initialize the config and log" do
      Exceptional.should_receive(:setup_config)
      Exceptional.should_receive(:setup_log)
 
      Exceptional.bootstrap(TEST_ENVIRONMENT, File.dirname(__FILE__))
    end
 
    it "should authenticate if enabled" do
      Exceptional.should_receive(:setup_config)
      Exceptional.should_receive(:setup_log)
      Exceptional.should_receive(:enabled?).and_return(true)
      Exceptional.should_receive(:authenticate).and_return(true)
      STDERR.should_not_receive(:puts) #Should be no errors to report
 
      Exceptional.bootstrap(TEST_ENVIRONMENT, File.dirname(__FILE__))
    end
 
    it "should not authenticate if not enabled" do
      Exceptional.should_receive(:setup_config)
      Exceptional.should_receive(:setup_log)
      Exceptional.should_receive(:enabled?).and_return(false)
      Exceptional.should_not_receive(:authenticate)
      STDERR.should_not_receive(:puts) # Will silently not enable itself
 
 
      Exceptional.bootstrap(TEST_ENVIRONMENT, File.dirname(__FILE__))
    end
 
    it "should report to STDERR if authentication fails" do
      Exceptional.should_receive(:setup_config)
      Exceptional.should_receive(:setup_log)
      Exceptional.should_receive(:enabled?).and_return(true)
      Exceptional.should_receive(:authenticate).and_return(false)
      STDERR.should_receive(:puts) #Should be no errors to report
 
      Exceptional.bootstrap(TEST_ENVIRONMENT, File.dirname(__FILE__))
    end
 
    it "should report to STDERR if error during config initialization" do
      Exceptional.should_receive(:setup_config).and_raise(Exceptional::Config::ConfigurationException)
      Exceptional.should_not_receive(:setup_log)
      Exceptional.should_not_receive(:authenticate).and_return(false)
      STDERR.should_receive(:puts).twice() #Should be no errors to report
 
      Exceptional.bootstrap(TEST_ENVIRONMENT, File.dirname(__FILE__))
    end
  end
end