Skip to content

Commit 69f442f

Browse files
committed
Add tests for ex07
1 parent 872c8d1 commit 69f442f

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

courses/ruby/ex07_tests/ex07_tests.rb

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
end
36+
37+
def test_nested_level_one
38+
skip
39+
ENV["MY_APP_ENV"] = "test"
40+
assert_equal MyApp.config.public.mode, "public"
41+
MyApp.reset
42+
end
43+
44+
def test_nested_level_two
45+
skip
46+
ENV["MY_APP_ENV"] = "test"
47+
assert_equal MyApp.config.private.private.login, "[email protected]"
48+
MyApp.reset
49+
end
50+
51+
def test_erb_default
52+
skip
53+
ENV["MY_APP_ENV"] = "test"
54+
assert_equal MyApp.config.database.user, "root"
55+
MyApp.reset
56+
end
57+
58+
def test_erb_specified
59+
skip
60+
ENV["DATABASE_USER"] = "admin"
61+
assert_equal MyApp.config.database.user, "admin"
62+
MyApp.reset
63+
end
64+
end

0 commit comments

Comments
 (0)