Module: DefaultTests2

Includes:
DefaultTests1, ExampleCall
Included in:
DefaultTests3
Defined in:
app/models/default_test_case.rb

Overview

DefaultTests1

Instance Method Summary collapse

Methods included from ExampleCall

#assert_optional_method, #each_example, #existing_call, #named_object?

Methods included from DefaultTests1

#test_case_pre_conditions

Methods included from DefaultTests0

#related_files?

Instance Method Details

#assert_environmentObject


90
91
92
93
94
95
96
97
98
99
100
101
102
# File 'app/models/default_test_case.rb', line 90

def assert_environment
  warn {assert_equal(TestCase, self.class.superclass)}
  message= "self=#{self.inspect}"
  puts message
  message+= "\nself.included_modules=#{self.included_modules.inspect}"
  assert_include(self.included_modules, Test::Unit::Assertions, message)
  assert_include(self.included_modules, DefaultTests0, message)
  assert_respond_to(TE, :model_class?, message)
  assert_include(TE.model_class?.included_modules, Test::Unit::Assertions, message)
  assert_include(TE.model_class?.included_modules, Regexp::Assertions, message)
#?  assert_include(TE.model_class?.included_modules, Regexp::Assertions::ClassMethods, message)
  assert_include(TE.model_class?.included_modules, Regexp::Examples, message)
end

#test_aaa_environmentObject

assert_environment


103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'app/models/default_test_case.rb', line 103

def test_aaa_environment
  info "$VERBOSE=#{$VERBOSE.inspect}"
  included_module_names=model_class?.included_modules.map{|m| m.name}
  info "included_module_names=#{included_module_names.inspect}"
  assert_include(self.class.included_modules, Test::Unit::Assertions)
#	assert_include(TE.model_class?.methods(true), :explain_assert_respond_to, "Need to require ../../test/assertions/ruby_assertions.rb in #{TE.assertions_pathname?}")
	assert_not_include(self.methods(false), :explain_assert_respond_to)
	assert_not_include(self.class.methods(false), :explain_assert_respond_to)
	assert_equal([], self.class.methods(false))
#	puts "model_class?::Examples.inspect=#{model_class?::Examples.inspect}"
#	puts "model_class?::Examples.constants.inspect=#{model_class?::Examples.constants.inspect}"
#	puts "model_class?::Examples.instance_methods.inspect=#{model_class?::Examples.instance_methods.inspect}"
#	puts "model_class?::Examples.methods.inspect=#{model_class?::Examples.methods.inspect}"
#	puts "model_class?::Assertions.inspect=#{model_class?::Assertions.inspect}"
#	puts "model_class?::Assertions.constants.inspect=#{model_class?::Assertions.constants.inspect}"
#	puts "model_class?::Assertions.instance_methods.inspect=#{model_class?::Assertions.instance_methods.inspect}"
#	puts "model_class?::Assertions.methods.inspect=#{model_class?::Assertions.methods.inspect}"
	message="Define a class named #{TE.model_name?} or redefine model_name? to return correct class name."
	message+="\nself.class.name=#{self.class.name}"
	message+="\nmodel_name?=#{TE.model_name?}"
	message+="\nmodel_class?=#{model_class?}"
	message+="\nor require '#{TE.model_pathname?}'"
	assert_not_nil(self.class.name, message)
	assert_not_nil(TE.model_name?, message)
	assert_not_nil(model_class?, message)
	assert_include(model_class?.included_modules, model_class?::Assertions, "Need to include #{model_class?::Assertions}")
	assert_include(model_class?.included_modules, Test::Unit::Assertions)
#	assert_equal('Test::Unit::Assertions', self.class.name)
#	assert_equal([MiniTest::Assertions], self.class.included_modules)
#	assert_equal([Module, Object, Test::Unit::Assertions, MiniTest::Assertions, PP::ObjectMixin, Kernel, BasicObject], self.class.ancestors)
#	fail "got to end of related_files ."
    constant_objects=model_class?.constants.map{|c| model_class?.class_eval(c.to_s)}
#verbose    info "constant_objects=#{constant_objects}"
   examples=constant_objects.select{|c| c.instance_of?(model_class?)}
   info "examples=#{examples}"
	if examples.empty? then
      warn "There are no example constants of type #{model_class?} in #{model_class?}::Examples.\nconstant_objects=#{constant_objects.inspect}"
	end #if
end

#test_assert_invariantObject

assert_pre_conditions


158
159
160
# File 'app/models/default_test_case.rb', line 158

def test_assert_invariant
#  each_example {|e| existing_call(e, :assert_invariant)}
end

#test_assert_post_conditionsObject

def assert_invariant


161
162
163
# File 'app/models/default_test_case.rb', line 161

def test_assert_post_conditions
  each_example {|e| existing_call(e, :assert_post_conditions)}
end

#test_assert_pre_conditionsObject

ClassMethods


155
156
157
# File 'app/models/default_test_case.rb', line 155

def test_assert_pre_conditions
  each_example {|e| existing_call(e, :assert_pre_conditions)}
end

#test_class_assert_invariantObject

class_assert_pre_conditions


146
147
148
149
# File 'app/models/default_test_case.rb', line 146

def test_class_assert_invariant
#  existing_call(model_class?, :assert_invariant)
#	fail "got to end of default test."
end

#test_class_assert_post_conditionsObject

def assert_invariant


150
151
152
153
# File 'app/models/default_test_case.rb', line 150

def test_class_assert_post_conditions
  existing_call(model_class?, :assert_post_conditions)
#	fail "got to end of default test."
end

#test_class_assert_pre_conditionsObject

test_aaa_environment


142
143
144
145
# File 'app/models/default_test_case.rb', line 142

def test_class_assert_pre_conditions
  existing_call(model_class?, :assert_pre_conditions)
#	fail "got to end of default test."
end