Class: ConfigurableTest

Inherits:
Test::Unit::TestCase
  • Object
show all
Defined in:
lib/six-updater-web/vendor/plugins/active_scaffold/test/misc/configurable_test.rb

Constant Summary collapse

HELLO =
'world'

Instance Method Summary collapse

Instance Method Details

#helloObject

constants and methods for tests to check against



14
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/misc/configurable_test.rb', line 14

def hello; 'world' end

#test_arityObject



88
89
90
91
92
93
94
95
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/misc/configurable_test.rb', line 88

def test_arity
  ConfigurableClass.send :extend, ActiveScaffold::Configurable

  # this is the main style
  assert_equal 'foo', ConfigurableClass.configure {'foo'}
  # but we want to let people accept the configurable class as the first argument, too
  assert_equal 'bar', ConfigurableClass.configure {|a| a.foo}
end

#test_class_configurationObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/misc/configurable_test.rb', line 54

def test_class_configuration
  ConfigurableClass.send :extend, ActiveScaffold::Configurable

  ##
  ## sanity checks
  ##
  # make sure the configure method is available
  assert ConfigurableClass.respond_to?(:configure)
  # make sure real functions still work
  assert_equal 'bar', ConfigurableClass.foo
  # make sure other functions still don't work
  assert_raise NoMethodError do
    ConfigurableClass.i_do_not_exist
  end

  ##
  ## test normal block behaviors
  ##
  # functions
  assert_equal hello, ConfigurableClass.configure {hello}
  # variables
  assert_equal ConfigurableClass, ConfigurableClass.configure {ConfigurableClass}
  # constants
  assert_equal HELLO, ConfigurableClass.configure {HELLO}

  ##
  ## test extra "localized" block behavior
  ##
  # functions
  assert_equal ConfigurableClass.foo, ConfigurableClass.configure {foo}
  # constants - not working
#    assert_equal ConfigurableClass.FOO, ConfigurableClass.configure {FOO}
end

#test_instance_configurationObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/six-updater-web/vendor/plugins/active_scaffold/test/misc/configurable_test.rb', line 17

def test_instance_configuration
  ConfigurableClass.send :include, ActiveScaffold::Configurable

  configurable_class = ConfigurableClass.new

  ##
  ## sanity checks
  ##
  # make sure the configure method is available
  assert ConfigurableClass.respond_to?(:configure)
  # make sure real functions still work
  assert_equal 'bar', configurable_class.foo
  # make sure other functions still don't work
  assert_raise NoMethodError do
    configurable_class.i_do_not_exist
  end

  ##
  ## test normal block behaviors
  ##
  # functions
  assert_equal hello, configurable_class.configure {hello}
  # variables
  assert_equal configurable_class, configurable_class.configure {configurable_class}
  # constants
  assert_equal HELLO, configurable_class.configure {HELLO}

  ##
  ## test extra "localized" block behavior
  ##
  # functions
  assert_equal configurable_class.foo, configurable_class.configure {foo}
  # constants - not working
#    assert_equal configurable_class.FOO, configurable_class.configure {FOO}

end