| | 330 | |
|---|
| | 331 | %w{plurals singulars uncountables}.each do |inflection_type| |
|---|
| | 332 | class_eval " |
|---|
| | 333 | def test_clear_#{inflection_type} |
|---|
| | 334 | cached_values = Inflector.inflections.#{inflection_type} |
|---|
| | 335 | Inflector.inflections.clear :#{inflection_type} |
|---|
| | 336 | assert Inflector.inflections.#{inflection_type}.empty?, \"#{inflection_type} inflections should be empty after clear :#{inflection_type}\" |
|---|
| | 337 | Inflector.inflections.instance_variable_set :@#{inflection_type}, cached_values |
|---|
| | 338 | end |
|---|
| | 339 | " |
|---|
| | 340 | end |
|---|
| | 341 | |
|---|
| | 342 | def test_clear_all |
|---|
| | 343 | cached_values = Inflector.inflections.plurals, Inflector.inflections.singulars, Inflector.inflections.uncountables |
|---|
| | 344 | Inflector.inflections.clear :all |
|---|
| | 345 | assert Inflector.inflections.plurals.empty? |
|---|
| | 346 | assert Inflector.inflections.singulars.empty? |
|---|
| | 347 | assert Inflector.inflections.uncountables.empty? |
|---|
| | 348 | Inflector.inflections.instance_variable_set :@plurals, cached_values[0] |
|---|
| | 349 | Inflector.inflections.instance_variable_set :@singulars, cached_values[1] |
|---|
| | 350 | Inflector.inflections.instance_variable_set :@uncountables, cached_values[2] |
|---|
| | 351 | end |
|---|
| | 352 | |
|---|
| | 353 | def test_clear_with_default |
|---|
| | 354 | cached_values = Inflector.inflections.plurals, Inflector.inflections.singulars, Inflector.inflections.uncountables |
|---|
| | 355 | Inflector.inflections.clear |
|---|
| | 356 | assert Inflector.inflections.plurals.empty? |
|---|
| | 357 | assert Inflector.inflections.singulars.empty? |
|---|
| | 358 | assert Inflector.inflections.uncountables.empty? |
|---|
| | 359 | Inflector.inflections.instance_variable_set :@plurals, cached_values[0] |
|---|
| | 360 | Inflector.inflections.instance_variable_set :@singulars, cached_values[1] |
|---|
| | 361 | Inflector.inflections.instance_variable_set :@uncountables, cached_values[2] |
|---|
| | 362 | end |
|---|