1 require File.expand_path(File.dirname(__FILE__) + '/edgecase')
3 class AboutScope < EdgeCase::Koan
20 def test_dog_is_not_available_in_the_current_scope
21 assert_raise(___(NameError)) do
26 def test_you_can_reference_nested_classes_using_the_scope_operator
29 assert_equal __(:jims_dog), fido.identify
30 assert_equal __(:joes_dog), rover.identify
32 assert_equal __(true), fido.class != rover.class
33 assert_equal __(true), Jims::Dog != Joes::Dog
36 # ------------------------------------------------------------------
41 def test_bare_bones_class_names_assume_the_current_scope
42 assert_equal __(true), AboutScope::String == String
45 def test_nested_string_is_not_the_same_as_the_system_string
46 assert_equal __(false), String == "HI".class
49 def test_use_the_prefix_scope_operator_to_force_the_global_scope
50 assert_equal __(true), ::String == "HI".class
53 # ------------------------------------------------------------------
57 def test_constants_are_defined_with_an_initial_uppercase_letter
58 assert_equal __(3.1416), PI
61 # ------------------------------------------------------------------
65 def test_class_names_are_just_constants
66 assert_equal __(true), MyString == ::String
67 assert_equal __(true), MyString == "HI".class
70 def test_constants_can_be_looked_up_explicitly
71 assert_equal __(true), PI == AboutScope.const_get("PI")
72 assert_equal __(true), MyString == AboutScope.const_get("MyString")
75 def test_you_can_get_a_list_of_constants_for_any_class_or_module
76 assert_equal __(["Dog"], [:Dog]), Jims.constants
77 assert Object.constants.size > _n_(10)