-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfig_spec.rb
61 lines (49 loc) · 1.58 KB
/
config_spec.rb
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
60
61
require 'minitest/autorun'
require 'podcast_press/config'
describe PodcastPress::Config do
CONFIG_FILE = 'podcast_press_config.rb'
describe "when a property is set" do
before do
File.open(CONFIG_FILE, 'w') {|f| f << "set title: 'Hello'"}
end
after { File.delete CONFIG_FILE }
it "returns the settings as a hash" do
PodcastPress::Config.get.must_equal({title: 'Hello'})
end
end
describe "when previousely set values are called" do
before do
File.open(CONFIG_FILE, 'w') do |f|
f << %Q{set title: "Hello" \n}
f << %q{set artist: "#{get(:title)}"}
end
end
after { File.delete CONFIG_FILE }
it "returns the settings as a hash" do
hash = PodcastPress::Config.get
hash[:artist].must_equal "Hello"
end
end
describe "when getting episode_number with a min_digits option" do
before do
File.open(CONFIG_FILE, 'w') do |f|
f << %Q{set episode_number: 3 \n}
f << %q{set title: "#{get :episode_number, min_digits: 3}"}
end
end
it "returns a number with zeros for padding to reach the minimum number of digits" do
PodcastPress::Config.get[:title].must_equal '003'
end
end
describe "calling #get with a hash of existing settings" do
before do
File.open(CONFIG_FILE, 'w') do |f|
f << %q{set title: "#{get :predefined}"}
end
@settings = PodcastPress::Config.get(predefined: 'pre-defined value')
end
it "lets users get those settings in the config file" do
@settings[:title].must_equal 'pre-defined value'
end
end
end