Skip to content

Commit

Permalink
add config file spec
Browse files Browse the repository at this point in the history
  • Loading branch information
DannyBen committed Jun 12, 2016
1 parent 8860c30 commit 7302f42
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 8 deletions.
8 changes: 0 additions & 8 deletions .madness.yml

This file was deleted.

1 change: 1 addition & 0 deletions lib/madness/settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ def initialize
end

def reset
@config_file = nil
set_defaults
load_from_file if config_file
end
Expand Down
8 changes: 8 additions & 0 deletions spec/fixtures/.madness.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# .madness.yml
---
path: 'to/enlightenment'
port: '1337'
bind: '4.3.2.1'
autoh1: false
highlighter: false
line_numbers: false
16 changes: 16 additions & 0 deletions spec/madness/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,20 @@
expect(config.path).to eq '.'
end

context "with a config file" do
before do
allow(config).to receive(:filename).and_return('spec/fixtures/.madness.yml')
config.reset
end

it "overrides config values" do
expect(config.path).to eq 'to/enlightenment'
expect(config.port).to eq '1337'
expect(config.bind).to eq '4.3.2.1'
expect(config.autoh1).to be false
expect(config.highlighter).to be false
expect(config.line_numbers).to be false
end
end

end

0 comments on commit 7302f42

Please sign in to comment.