Skip to content

Commit

Permalink
Add tests for ex07
Browse files Browse the repository at this point in the history
  • Loading branch information
dpatsora committed Sep 10, 2019
1 parent 872c8d1 commit 69f442f
Showing 1 changed file with 64 additions and 0 deletions.
64 changes: 64 additions & 0 deletions courses/ruby/ex07_tests/ex07_tests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
require "minitest/autorun"
require "minitest/pride"

require_relative "ex07"

class Ex07MyAppTest < Minitest::Test
Module.prepend MyApp
def test_class_config
skip
s = MyApp.config
assert_equal s.class, MyApp::Config
MyApp.reset
end

def test_obj_id
skip
a = MyApp.config
b = MyApp.config
assert_equal a.object_id, b.object_id
MyApp.reset
end

def test_default_env
skip
a = MyApp.config
assert_equal a.app_name, "dev app"
MyApp.reset
end

def test_env_production
skip
ENV["MY_APP_ENV"] = "production"
assert_equal MyApp.config.server, "http://httpd.example.org/"
MyApp.reset
end

def test_nested_level_one
skip
ENV["MY_APP_ENV"] = "test"
assert_equal MyApp.config.public.mode, "public"
MyApp.reset
end

def test_nested_level_two
skip
ENV["MY_APP_ENV"] = "test"
assert_equal MyApp.config.private.private.login, "[email protected]"
MyApp.reset
end

def test_erb_default
skip
ENV["MY_APP_ENV"] = "test"
assert_equal MyApp.config.database.user, "root"
MyApp.reset
end

def test_erb_specified
skip
ENV["DATABASE_USER"] = "admin"
assert_equal MyApp.config.database.user, "admin"
MyApp.reset
end
end

0 comments on commit 69f442f

Please sign in to comment.