Module: FilePattern::Assertions

Includes:
Test::Unit::Assertions
Included in:
FilePattern
Defined in:
app/models/file_pattern.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#assert_invariantObject

conditions that are always true (at least atomically)


169
170
171
# File 'app/models/file_pattern.rb', line 169

def assert_invariant
	fail "end of assert_invariant "
end

#assert_naming_convention_match(path) ⇒ Object

assert_post_conditions


188
189
190
191
192
193
194
195
196
197
198
199
200
# File 'app/models/file_pattern.rb', line 188

def assert_naming_convention_match(path)
	path=File.expand_path(path)
	assert_equal(path[-self[:suffix].size, self[:suffix].size], self[:suffix], caller_lines)
	sub_directory=File.dirname(path)
	expected_sub_directory=self[:sub_directory][0..-2] # drops trailing /
	message="expected_sub_directory=#{expected_sub_directory}\nsub_directory=#{sub_directory}"
	assert_not_nil(sub_directory[-expected_sub_directory.size,expected_sub_directory.size], message+caller_lines)
	assert_equal(sub_directory[-expected_sub_directory.size,expected_sub_directory.size], expected_sub_directory, message+caller_lines)
	message="self=#{self}\nsub_directory=#{sub_directory}\nexpected_sub_directory=#{expected_sub_directory}"
	message+="\n self.sub_directory_match(path)=#{self.sub_directory_match(path)}"
	assert(self.sub_directory_match(path), message+caller_lines)
	message="self=#{self.inspect}, path=#{path.inspect}"
end

#assert_post_conditionsObject

assertions true after class (and nested module Examples) is defined


184
185
186
187
# File 'app/models/file_pattern.rb', line 184

def assert_post_conditions
	message+="\ndefault FilePattern.project_root_dir?=#{FilePattern.project_root_dir?.inspect}"
	assert_not_empty(@project_root_dir, message)
end

#assert_pre_conditions(message = '') ⇒ Object

conditions true while class is being defined assertions true after class (and nested module Examples) is defined


174
175
176
177
178
179
180
181
182
# File 'app/models/file_pattern.rb', line 174

def assert_pre_conditions(message='')
	message+="\n self=#{self.inspect}\n self=#{self.inspect}"
	assert_not_equal('{}',self.inspect, message)
	assert_not_nil(self, message)
	assert_instance_of(FilePattern, self, message)
	assert(!self.keys.empty?, message)
	assert_not_empty(self.values, message)
#	fail message+"end of assert_pre_conditions "
end