|
5 | 5 | describe 'Configuration' do
|
6 | 6 |
|
7 | 7 | before :all do
|
| 8 | + CONFIG_FILE = File.expand_path_relative_to_caller("../hatterrc") |
8 | 9 | @maildir_path = "/path/to/maildir"
|
9 |
| - CONFIG_FILE = File.expand_path_relative_to_caller("../.hatterrc") |
10 | 10 | @maildir_format = "maildir"
|
11 |
| - @config = Configuration.new() do |config| |
12 |
| - config.maildir = @maildir_path |
13 |
| - config.maildir_format = @maildir_format |
14 |
| - end |
| 11 | + @termbox_library_path = "/usr/lib/libtermbox.so" |
15 | 12 | end
|
16 | 13 |
|
17 |
| - it "contains all the required configuration settings" do |
18 |
| - @config.maildir?.should be_true |
19 |
| - @config.maildir_format?.should be_true |
| 14 | + it "barfs when required values are missing" do |
| 15 | + config = File.read CONFIG_FILE |
| 16 | + config.gsub!(/maildir/, 'asdf') |
| 17 | + File.open("invalid_config", "w") {|file| file.write config} |
| 18 | + expect {Configuration.instance "invalid_config"}.to raise_error |
| 19 | + FileUtils::rm("invalid_config") |
20 | 20 | end
|
21 | 21 |
|
22 |
| - it "the settings have the correct values" do |
23 |
| - @config.maildir.should eq @maildir_path |
24 |
| - @config.maildir_format.should eq @maildir_format |
| 22 | + it "reads the configuration values from file" do |
| 23 | + config = Configuration.instance |
| 24 | + config.maildir.should eq @maildir_path |
| 25 | + config.maildir_format.should eq @maildir_format |
25 | 26 | end
|
26 | 27 |
|
27 |
| - it "reads the configuration values from file" do |
28 |
| - config = Configuration.from_file CONFIG_FILE |
| 28 | + it "the settings have the correct values" do |
| 29 | + config = Configuration.instance |
29 | 30 | config.maildir.should eq @maildir_path
|
30 | 31 | config.maildir_format.should eq @maildir_format
|
| 32 | + config.termbox_library_path.should eq @termbox_library_path |
31 | 33 | end
|
32 | 34 |
|
33 |
| - it "barfs when required values are missing" do |
34 |
| - config = File.read CONFIG_FILE |
35 |
| - config.gsub!(/maildir/, 'asdf') |
36 |
| - File.open("invalid_config", "w") {|file| file.write config} |
37 |
| - expect {Configuration.from_file("invalid_config")}.to raise_error |
38 |
| - FileUtils::rm("invalid_config") |
| 35 | + it "contains a nested config with colors" do |
| 36 | + config = Configuration.instance |
| 37 | + config.colors.foreground.should eq "green" |
| 38 | + config.colors.foreground.should eq "green" |
39 | 39 | end
|
| 40 | + |
40 | 41 | end
|
0 commit comments