Skip to content

Commit 7e31315

Browse files
committed
Add tests for ex07
1 parent 872c8d1 commit 7e31315

File tree

1 file changed

+71
-0
lines changed

1 file changed

+71
-0
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
require "minitest/autorun"
2+
require "minitest/pride"
3+
4+
require_relative "ex07"
5+
6+
class Ex07MyAppTest < Minitest::Test
7+
Module.prepend MyApp
8+
def test_class_config
9+
skip
10+
s = MyApp.config
11+
assert_equal s.class, MyApp::Config
12+
MyApp.reset
13+
end
14+
15+
def test_obj_id
16+
skip
17+
a = MyApp.config
18+
b = MyApp.config
19+
assert_equal a.object_id, b.object_id
20+
MyApp.reset
21+
end
22+
23+
def test_default_env
24+
skip
25+
a = MyApp.config
26+
assert_equal a.app_name, "dev app"
27+
MyApp.reset
28+
end
29+
30+
def test_env_production
31+
skip
32+
ENV["MY_APP_ENV"] = "production"
33+
assert_equal MyApp.config.server, "http://httpd.example.org/"
34+
MyApp.reset
35+
ENV.delete("MY_APP_ENV")
36+
end
37+
38+
def test_nested_level_one
39+
skip
40+
ENV["MY_APP_ENV"] = "test"
41+
assert_equal MyApp.config.public.mode, "public"
42+
MyApp.reset
43+
ENV.delete("MY_APP_ENV")
44+
end
45+
46+
def test_nested_level_two
47+
skip
48+
ENV["MY_APP_ENV"] = "test"
49+
assert_equal MyApp.config.private.private.login, "any_login@bootcamp.com"
50+
MyApp.reset
51+
ENV.delete("MY_APP_ENV")
52+
end
53+
54+
def test_erb_default
55+
skip
56+
ENV["MY_APP_ENV"] = "test"
57+
assert_equal MyApp.config.database.user, "root"
58+
MyApp.reset
59+
ENV.delete("MY_APP_ENV")
60+
end
61+
62+
def test_erb_specified
63+
skip
64+
ENV["DATABASE_USER"] = "admin"
65+
ENV["MY_APP_ENV"] = "test"
66+
assert_equal MyApp.config.database.user, "admin"
67+
MyApp.reset
68+
ENV.delete("MY_APP_ENV")
69+
ENV.delete("DATABASE_USER")
70+
end
71+
end

0 commit comments

Comments
 (0)