1+ # frozen_string_literal: true
2+
13require 'test_helper'
24
35describe Metal do
46 describe '#find_or_create_by_path' do
57 def assert_correctness ( grandchild )
68 assert ( Metal , grandchild )
7- assert_equal " slag" , grandchild . description
9+ assert_equal ' slag' , grandchild . description
810 child = grandchild . parent
911 assert ( Unobtanium , child )
10- assert_equal " frames" , child . description
11- assert_equal " child" , child . value
12+ assert_equal ' frames' , child . description
13+ assert_equal ' child' , child . value
1214 parent = child . parent
1315 assert ( Adamantium , parent )
14- assert_equal " claws" , parent . description
15- assert_equal " parent" , parent . value
16+ assert_equal ' claws' , parent . description
17+ assert_equal ' parent' , parent . value
1618 end
1719
1820 let ( :attr_path ) do
1921 [
20- { value : 'parent' , description : 'claws' , metal_type : 'Adamantium' } ,
21- { value : 'child' , description : 'frames' , metal_type : 'Unobtanium' } ,
22- { value : 'grandchild' , description : 'slag' , metal_type : 'Metal' }
22+ { value : 'parent' , description : 'claws' , metal_type : 'Adamantium' } ,
23+ { value : 'child' , description : 'frames' , metal_type : 'Unobtanium' } ,
24+ { value : 'grandchild' , description : 'slag' , metal_type : 'Metal' }
2325 ]
2426 end
2527
26- before do
27- # ensure the correct root is used in find_or_create_by_path:
28- [ Metal , Adamantium , Unobtanium ] . each do |metal |
29- metal . find_or_create_by_path ( %w( parent child grandchild ) )
28+ if false
29+ before do
30+ # ensure the correct root is used in find_or_create_by_path:
31+ [ Metal , Adamantium , Unobtanium ] . each do |metal |
32+ metal . find_or_create_by_path ( %w[ parent child grandchild ] )
33+ end
3034 end
31- end if false
35+ end
3236
3337 it 'creates children from the proper root' do
3438 assert_correctness ( Metal . find_or_create_by_path ( attr_path ) )
@@ -44,9 +48,9 @@ def assert_correctness(grandchild)
4448 end
4549
4650 it 'maintains the current STI subclass if attributes are not specified' do
47- leaf = Unobtanium . find_or_create_by_path ( %w( a b c d ) )
51+ leaf = Unobtanium . find_or_create_by_path ( %w[ a b c d ] )
4852 assert ( Unobtanium , leaf )
49- assert_equal %w( c b a ) , leaf . ancestors . map ( &:value )
53+ assert_equal %w[ c b a ] , leaf . ancestors . map ( &:value )
5054 leaf . ancestors . each do |anc |
5155 assert ( Unobtanium , anc )
5256 end
0 commit comments