Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for ex07
Browse files Browse the repository at this point in the history
dpatsora committed Sep 10, 2019

Verified

This commit was signed with the committer’s verified signature.
1 parent 872c8d1 commit 7e31315
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions courses/ruby/ex07_tests/ex07_tests.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
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
ENV.delete("MY_APP_ENV")
end

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

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

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

def test_erb_specified
skip
ENV["DATABASE_USER"] = "admin"
ENV["MY_APP_ENV"] = "test"
assert_equal MyApp.config.database.user, "admin"
MyApp.reset
ENV.delete("MY_APP_ENV")
ENV.delete("DATABASE_USER")
end
end

0 comments on commit 7e31315

Please sign in to comment.