Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests for ex07 #27

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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