How to use end method of Copyable Package

Best Howitzer_ruby code snippet using Copyable.end

copyable_associations_spec.rb

Source:copyable_associations_spec.rb Github

copy

Full Screen

...11 })12 associations({13 copyable_pet_sitting_patronages: :copy,14 })15 end16 end17 undefine_copyable_in CopyablePetSittingPatronage18 class CopyablePetSittingPatronage < ActiveRecord::Base19 copyable do20 disable_all_callbacks_and_observers_except_validate21 columns({22 copyable_pet_id: :copy,23 copyable_pet_sitter_id: :copy,24 })25 associations({26 })27 end28 end29 end30 it 'should produce copies of the associated records' do31 pet1 = CopyablePet.create!(name: 'Pet1', kind: 'cat', birth_year: 2010)32 pet2 = CopyablePet.create!(name: 'Pet2', kind: 'cat', birth_year: 2011)33 pet3 = CopyablePet.create!(name: 'Pet3', kind: 'cat', birth_year: 2012)34 sitter1 = CopyablePetSitter.create!(name: 'Sitter1')35 sitter2 = CopyablePetSitter.create!(name: 'Sitter2')36 sitter3 = CopyablePetSitter.create!(name: 'Sitter3')37 sitter4 = CopyablePetSitter.create!(name: 'Sitter4')38 patronage1 = CopyablePetSittingPatronage.create!(39 copyable_pet_id: pet1.id,40 copyable_pet_sitter_id: sitter2.id)41 patronage2 = CopyablePetSittingPatronage.create!(42 copyable_pet_id: pet2.id,43 copyable_pet_sitter_id: sitter2.id)44 patronage3 = CopyablePetSittingPatronage.create!(45 copyable_pet_id: pet3.id,46 copyable_pet_sitter_id: sitter4.id)47 sitter2.reload48 expect(sitter2.copyable_pet_sitting_patronages.size).to eq(2)49 copied_sitter = sitter2.create_copy!50 expect(copied_sitter.copyable_pet_sitting_patronages.size).to eq(2)51 expect(copied_sitter.copyable_pets.map(&:name)).to match_array(['Pet1', 'Pet2'])52 end53 end54 context 'do not copy' do55 before(:each) do56 undefine_copyable_in CopyablePetSitter57 class CopyablePetSitter < ActiveRecord::Base58 copyable do59 disable_all_callbacks_and_observers_except_validate60 columns({61 name: :copy,62 })63 associations({64 copyable_pet_sitting_patronages: :do_not_copy,65 })66 end67 end68 undefine_copyable_in CopyablePetSittingPatronage69 class CopyablePetSittingPatronage < ActiveRecord::Base70 copyable do71 disable_all_callbacks_and_observers_except_validate72 columns({73 copyable_pet_id: :copy,74 copyable_pet_sitter_id: :copy,75 })76 associations({77 })78 end79 end80 end81 it 'should not produce copies of the associated records' do82 pet1 = CopyablePet.create!(name: 'Pet1', kind: 'cat', birth_year: 2010)83 pet2 = CopyablePet.create!(name: 'Pet2', kind: 'cat', birth_year: 2011)84 pet3 = CopyablePet.create!(name: 'Pet3', kind: 'cat', birth_year: 2012)85 sitter1 = CopyablePetSitter.create!(name: 'Sitter1')86 sitter2 = CopyablePetSitter.create!(name: 'Sitter2')87 sitter3 = CopyablePetSitter.create!(name: 'Sitter3')88 sitter4 = CopyablePetSitter.create!(name: 'Sitter4')89 patronage1 = CopyablePetSittingPatronage.create!(90 copyable_pet_id: pet1.id,91 copyable_pet_sitter_id: sitter2.id)92 patronage2 = CopyablePetSittingPatronage.create!(93 copyable_pet_id: pet2.id,94 copyable_pet_sitter_id: sitter2.id)95 patronage3 = CopyablePetSittingPatronage.create!(96 copyable_pet_id: pet3.id,97 copyable_pet_sitter_id: sitter4.id)98 sitter2.reload99 expect(sitter2.copyable_pet_sitting_patronages.size).to eq(2)100 expect(CopyablePetSittingPatronage.count).to eq(3)101 copied_sitter = sitter2.create_copy!102 expect(copied_sitter.copyable_pet_sitting_patronages.size).to eq(0)103 expect(CopyablePetSittingPatronage.count).to eq(3)104 end105 end106 context 'copying a has one relationship' do107 before(:each) do108 undefine_copyable_in CopyablePetProfile109 class CopyablePetProfile < ActiveRecord::Base110 copyable do111 disable_all_callbacks_and_observers_except_validate112 columns({113 description: :copy,114 nickname: :copy,115 copyable_pet_id: lambda { |orig| 177777 }, # random bogus CopyablePet id since we don't need a real CopyablePet record for this test116 })117 associations({118 copyable_address: :copy,119 })120 end121 end122 undefine_copyable_in CopyableAddress123 class CopyableAddress < ActiveRecord::Base124 copyable do125 disable_all_callbacks_and_observers_except_validate126 columns({127 address1: :copy,128 address2: :copy,129 city: :copy,130 state: :copy,131 copyable_pet_profile_id: :copy,132 })133 associations({134 })135 end136 end137 end138 it 'should produce a copy of the associated record' do139 profile1 = CopyablePetProfile.create!(description: 'Prof1',140 copyable_pet_id: 177777)141 profile2 = CopyablePetProfile.create!(description: 'Prof2',142 copyable_pet_id: 188888)143 profile3 = CopyablePetProfile.create!(description: 'Prof3',144 copyable_pet_id: 199999)145 address1 = CopyableAddress.create!(address1: 'Add1',146 city: 'Cambridge',147 state: 'MA',148 copyable_pet_profile_id: profile1.id)149 address2 = CopyableAddress.create!(address1: 'Add2',150 city: 'Boston',151 state: 'MA',152 copyable_pet_profile_id: profile2.id)153 address3 = CopyableAddress.create!(address1: 'Add3',154 city: 'Somerville',155 state: 'MA',156 copyable_pet_profile_id: profile3.id)157 expect(CopyablePetProfile.count).to eq(3)158 expect(CopyableAddress.count).to eq(3)159 copied_profile = profile1.create_copy!160 expect(CopyablePetProfile.count).to eq(4)161 expect(CopyableAddress.count).to eq(4)162 expect(copied_profile.copyable_address.address1).to eq('Add1')163 expect(copied_profile.copyable_address.city).to eq('Cambridge')164 end165 it 'should not copy the associated record if it is nil' do166 profile1 = CopyablePetProfile.create!(description: 'Prof1',167 copyable_pet_id: 56565656) # bogus id168 expect(CopyablePetProfile.count).to eq(1)169 expect(CopyableAddress.count).to eq(0)170 copied_profile = profile1.create_copy!171 expect(CopyablePetProfile.count).to eq(2)172 expect(CopyableAddress.count).to eq(0)173 expect(copied_profile.copyable_address).to be_nil174 end175 end176 context 'copying a has and belongs to many relationship' do177 before(:each) do178 undefine_copyable_in CopyablePetFood179 class CopyablePetFood < ActiveRecord::Base180 copyable do181 disable_all_callbacks_and_observers_except_validate182 columns({183 name: :copy,184 })185 associations({186 copyable_pets: :copy_only_habtm_join_records,187 })188 end189 end190 end191 it 'should produce a copy of the associations but not the records' do192 pet1 = CopyablePet.create!(name: 'Pet1', kind: 'cat', birth_year: 2010)193 pet2 = CopyablePet.create!(name: 'Pet2', kind: 'cat', birth_year: 2011)194 pet3 = CopyablePet.create!(name: 'Pet3', kind: 'cat', birth_year: 2012)195 food1 = CopyablePetFood.create!(name: 'Food1')196 food2 = CopyablePetFood.create!(name: 'Food2')197 food3 = CopyablePetFood.create!(name: 'Food3')198 food4 = CopyablePetFood.create!(name: 'Food4')199 food1.copyable_pets << pet1200 food1.copyable_pets << pet2201 food3.copyable_pets << pet3202 copied_food1 = food1.create_copy!203 copied_food2 = food2.create_copy!204 copied_food3 = food3.create_copy!205 expect(copied_food1.copyable_pets.map(&:name)).to match_array(['Pet1', 'Pet2'])206 expect(copied_food2.copyable_pets.map(&:name)).to match_array([])207 expect(copied_food3.copyable_pets.map(&:name)).to match_array(['Pet3'])208 expect(pet1.copyable_pet_foods.size).to eq(2)209 expect(CopyablePet.count).to eq(3)210 end211 end212 context 'copying a polymorphic has many' do213 before(:each) do214 undefine_copyable_in CopyableProduct215 class CopyableProduct < ActiveRecord::Base216 copyable do217 disable_all_callbacks_and_observers_except_validate218 columns({219 name: :copy,220 })221 associations({222 copyable_pictures: :copy,223 })224 end225 end226 undefine_copyable_in CopyablePicture227 class CopyablePicture < ActiveRecord::Base228 copyable do229 disable_all_callbacks_and_observers_except_validate230 columns({231 name: :copy,232 imageable_id: :copy,233 imageable_type: :copy,234 picture_album_id: :copy,235 })236 associations({237 })238 end239 end240 end241 it 'should produce a copy of the associations' do242 product1 = CopyableProduct.create!(name: 'camera')243 picture1 = CopyablePicture.create!(name: 'photo1')244 picture2 = CopyablePicture.create!(name: 'photo2')245 product1.copyable_pictures << picture1246 product1.copyable_pictures << picture2247 expect(CopyableProduct.count).to eq(1)248 expect(CopyablePicture.count).to eq(2)249 copied_product = product1.create_copy!250 expect(CopyableProduct.count).to eq(2)251 expect(CopyablePicture.count).to eq(4)252 expect(copied_product.copyable_pictures.size).to eq(2)253 expect(copied_product.copyable_pictures.map(&:id)).not_to match_array(product1.copyable_pictures.map(&:id))254 end255 end256 context 'with a custom foreign key' do257 before(:each) do258 undefine_copyable_in CopyablePicture259 class CopyablePicture < ActiveRecord::Base260 copyable do261 disable_all_callbacks_and_observers_except_validate262 columns({263 name: :copy,264 imageable_id: :copy,265 imageable_type: :copy,266 picture_album_id: :copy,267 })268 associations({269 })270 end271 end272 undefine_copyable_in CopyableAlbum273 class CopyableAlbum < ActiveRecord::Base274 copyable do275 disable_all_callbacks_and_observers_except_validate276 columns({277 name: :copy,278 })279 associations({280 copyable_pictures: :copy,281 })282 end283 end284 end285 it 'should produce copies of the associated records without an error' do286 album = CopyableAlbum.create!(name: 'an album')287 picture1 = CopyablePicture.create!(name: 'photo1')288 picture2 = CopyablePicture.create!(name: 'photo2', copyable_album: album)289 picture3 = CopyablePicture.create!(name: 'photo3', copyable_album: album)290 expect(CopyableAlbum.count).to eq(1)291 expect(CopyablePicture.count).to eq(3)292 copied_album = album.create_copy!293 expect(CopyableAlbum.count).to eq(2)294 expect(CopyablePicture.count).to eq(5)295 expect(copied_album.copyable_pictures.map(&:name)).to match_array(['photo2', 'photo3'])296 end297 it 'should update polymorphic belongs_to associations correctly' do298 # This tests how the update_other_belongs_to_associations method handles299 # polymorphic assocations. Even though the steps of this example may be300 # similar (or exactly the same) as another example, the behavior that this301 # example describes is different and is a significant part of the302 # correctness of the software.303 album = CopyableAlbum.create!(name: 'an album')304 picture1 = CopyablePicture.create!(name: 'photo1')305 picture2 = CopyablePicture.create!(name: 'photo2', copyable_album: album)306 picture3 = CopyablePicture.create!(name: 'photo3', copyable_album: album)307 expect(CopyableAlbum.count).to eq(1)308 expect(CopyablePicture.count).to eq(3)309 copied_album = album.create_copy!310 expect(CopyableAlbum.count).to eq(2)311 expect(CopyablePicture.count).to eq(5)312 expect(copied_album.copyable_pictures.map(&:name)).to match_array(['photo2', 'photo3'])313 end314 end315 context 'copying a has many relationship with a missing copyable declaration' do316 before(:each) do317 undefine_copyable_in CopyablePetSitter318 class CopyablePetSitter < ActiveRecord::Base319 copyable do320 disable_all_callbacks_and_observers_except_validate321 columns({322 name: :copy,323 })324 associations({325 copyable_pet_sitting_patronages: :copy,326 })327 end328 end329 undefine_copyable_in CopyablePetSittingPatronage330 class CopyablePetSittingPatronage < ActiveRecord::Base331 undef create_copy!332 # MISSING copyable do333 # disable_all_callbacks_and_observers_except_validate334 # columns({335 # copyable_pet_id: :copy,336 # copyable_pet_sitter_id: :copy,337 # })338 # associations({339 # })340 # end341 end342 end343 it 'should raise an informative error' do344 pet1 = CopyablePet.create!(name: 'Pet1', kind: 'cat', birth_year: 2010)345 sitter1 = CopyablePetSitter.create!(name: 'Sitter1')346 patronage1 = CopyablePetSittingPatronage.create!(347 copyable_pet_id: pet1.id,348 copyable_pet_sitter_id: sitter1.id)349 expect {350 sitter1.create_copy!351 }.to raise_error(Copyable::CopyableError)352 end353 end354end...

Full Screen

Full Screen

deep_structure_copy_spec.rb

Source:deep_structure_copy_spec.rb Github

copy

Full Screen

...11 associations({12 copyable_vehicles: :copy,13 copyable_amenities: :copy,14 })15 end16 end17 undefine_copyable_in CopyableVehicle18 class CopyableVehicle < ActiveRecord::Base19 copyable do20 disable_all_callbacks_and_observers_except_validate21 columns({22 name: :copy,23 copyable_owner_id: :copy,24 })25 associations({26 copyable_amenities: :copy,27 })28 end29 end30 undefine_copyable_in CopyableAmenity31 class CopyableAmenity < ActiveRecord::Base32 copyable do33 disable_all_callbacks_and_observers_except_validate34 columns({35 name: :copy,36 copyable_vehicle_id: :copy,37 copyable_owner_id: :copy,38 })39 associations({40 copyable_warranty: :copy,41 })42 end43 end44 undefine_copyable_in CopyableWarranty45 class CopyableWarranty < ActiveRecord::Base46 copyable do47 disable_all_callbacks_and_observers_except_validate48 columns({49 name: :copy,50 copyable_amenity_id: :copy,51 })52 associations({53 })54 end55 end56 end57 describe 'a tree structure' do58 before(:each) do59 # We are avoiding using owners to avoid the denormalized aspect60 # of the data model and keep this a simple tree.61 @vehicle1 = CopyableVehicle.create!(name: 'Corvette')62 @amenity1 = CopyableAmenity.create!(name: 'moon roof', copyable_vehicle: @vehicle1)63 @warranty1 = CopyableWarranty.create!(name: 'moon roof warranty', copyable_amenity: @amenity1)64 @amenity2 = CopyableAmenity.create!(name: 'twitter', copyable_vehicle: @vehicle1)65 @warranty2 = CopyableWarranty.create!(name: 'twitter warranty', copyable_amenity: @amenity2)66 @amenity3 = CopyableAmenity.create!(name: 'jazz', copyable_vehicle: @vehicle1)67 @warranty3 = CopyableWarranty.create!(name: 'jazz warranty', copyable_amenity: @amenity3)68 end69 it 'should copy the entire tree as directed' do70 @vehicle2 = @vehicle1.create_copy!71 expect(CopyableVehicle.count).to eq(2)72 expect(CopyableAmenity.count).to eq(6)73 expect(CopyableWarranty.count).to eq(6)74 expect(@vehicle2.name).to eq('Corvette')75 expect(@vehicle2.copyable_amenities.map(&:name)).to match_array(76 ['moon roof', 'twitter', 'jazz'])77 expect(@vehicle2.copyable_amenities.map(&:copyable_warranty).map(&:name)).to match_array(78 ['moon roof warranty', 'twitter warranty', 'jazz warranty'])79 end80 it 'should skip branches of the tree when directed' do81 @vehicle2 = @vehicle1.create_copy!(skip_associations: [:copyable_amenities])82 expect(CopyableVehicle.count).to eq(2)83 expect(CopyableAmenity.count).to eq(3) # No new ones created84 expect(CopyableWarranty.count).to eq(3) # Because the amenities weren't copied either85 end86 it 'should skip nested branches of the tree when directed' do87 @vehicle2 = @vehicle1.create_copy!(skip_associations: [:copyable_warranty])88 expect(CopyableVehicle.count).to eq(2)89 expect(CopyableAmenity.count).to eq(6)90 expect(CopyableWarranty.count).to eq(3) # No new ones created91 end92 it 'should create the expected records if copied multiple times' do93 # this test makes sure the SingleCopyEnforcer isn't too eager94 @vehicle1.create_copy!95 expect(CopyableVehicle.count).to eq(2)96 expect(CopyableAmenity.count).to eq(6)97 expect(CopyableWarranty.count).to eq(6)98 @vehicle1.create_copy!99 expect(CopyableVehicle.count).to eq(3)100 expect(CopyableAmenity.count).to eq(9)101 expect(CopyableWarranty.count).to eq(9)102 @vehicle1.create_copy!103 expect(CopyableVehicle.count).to eq(4)104 expect(CopyableAmenity.count).to eq(12)105 expect(CopyableWarranty.count).to eq(12)106 end107 end108 describe 'a denormalized structure' do109 context 'having one redundant association' do110 before(:each) do111 @joe = CopyableOwner.create!(name: 'Joe')112 @porsche = CopyableVehicle.create!(name: 'Porsche', copyable_owner: @joe)113 @moon_roof = CopyableAmenity.create!(name: 'moon roof',114 copyable_vehicle: @porsche,115 copyable_owner: @joe)116 end117 it 'should copy the records without copying any given record more than once' do118 @copy_of_joe = @joe.create_copy!119 expect(CopyableOwner.count).to eq(2)120 expect(CopyableVehicle.count).to eq(2)121 expect(CopyableAmenity.count).to eq(2)122 end123 context 'with a global override, can copy vehicle with new owner' do124 before(:each) do125 @jane = CopyableOwner.create!(name: 'Jane')126 end127 it 'should copy the records correctly' do128 @copy_of_joes_car = @porsche.create_copy!(global_override: { copyable_owner_id: @jane.id })129 expect(CopyableVehicle.count).to eq(2)130 expect(CopyableAmenity.count).to eq(2)131 expect(@copy_of_joes_car.copyable_owner_id).to eq(@jane.id)132 expect(@copy_of_joes_car.copyable_amenities.map(&:copyable_owner_id).uniq).to eq([@jane.id])133 end134 end135 end136 context 'with many models, some having redundant associations' do137 before(:each) do138 @joe = CopyableOwner.create!(name: 'Joe')139 @porsche = CopyableVehicle.create!(name: 'Porsche', copyable_owner: @joe)140 @moon_roof = CopyableAmenity.create!(141 name: 'moon roof',142 copyable_vehicle: @porsche,143 copyable_owner: @joe)144 @mustang = CopyableVehicle.create!(name: 'Mustang', copyable_owner: @joe)145 @air_conditioning = CopyableAmenity.create!(146 name: 'air conditioning',147 copyable_vehicle: @mustang,148 copyable_owner: @joe)149 @air_conditioning_warranty = CopyableWarranty.create!(150 name: 'air conditioning warranty',151 copyable_amenity: @air_conditioning)152 @corvette = CopyableVehicle.create!(name: 'Corvette', copyable_owner: @joe)153 @pillows = CopyableAmenity.create!(154 name: 'pillows',155 copyable_vehicle: @corvette,156 copyable_owner: @joe)157 @pillow_warranty = CopyableWarranty.create!(name: 'pillow warranty', copyable_amenity: @pillows)158 @airbags = CopyableAmenity.create!(159 name: 'airbags',160 copyable_vehicle: @corvette,161 copyable_owner: @joe)162 @airbag_warranty = CopyableWarranty.create!(name: 'airbag warranty', copyable_amenity: @airbags)163 @radio = CopyableAmenity.create!(164 name: 'satellite radio',165 copyable_vehicle: @corvette,166 copyable_owner: @joe)167 end168 it 'should copy the records without copying any given record more than once' do169 @copy_of_joe = @joe.create_copy!170 expect(CopyableOwner.count).to eq(2)171 expect(CopyableVehicle.count).to eq(6)172 expect(CopyableAmenity.count).to eq(10)173 expect(CopyableWarranty.count).to eq(6)174 expect(@copy_of_joe.copyable_vehicles.map(&:name)).to match_array([175 'Porsche', 'Mustang', 'Corvette'])176 expect(@copy_of_joe.copyable_amenities.map(&:name)).to match_array([177 'moon roof', 'air conditioning', 'pillows', 'airbags', 'satellite radio'])178 end179 end180 end181end...

Full Screen

Full Screen

syntax_checking_spec.rb

Source:syntax_checking_spec.rb Github

copy

Full Screen

...10 model_definition = lambda do11 undefine_copyable_in CopyableCoin12 class CopyableCoin < ActiveRecord::Base13 copyable14 end15 end16 expect(model_definition).to raise_error(Copyable::CopyableError)17 end18 it 'should throw an error when passed an empty block' do19 model_definition = lambda do20 undefine_copyable_in CopyableCoin21 class CopyableCoin < ActiveRecord::Base22 copyable do23 end24 end25 end26 expect(model_definition).to raise_error(Copyable::DeclarationError)27 end28 it 'should not throw an error when all required declarations are present' do29 model_definition = lambda do30 undefine_copyable_in CopyableCoin31 class CopyableCoin < ActiveRecord::Base32 copyable do33 disable_all_callbacks_and_observers_except_validate34 columns({35 kind: :copy,36 year: :copy,37 })38 associations({39 })40 end41 end42 end43 expect(model_definition).to_not raise_error44 end45 it 'should not throw an error when all declarations are present' do46 model_definition = lambda do47 undefine_copyable_in CopyableCoin48 class CopyableCoin < ActiveRecord::Base49 copyable do50 disable_all_callbacks_and_observers_except_validate51 columns({52 kind: :copy,53 year: :copy,54 })55 associations({56 })57 after_copy do |original_model, new_model|58 end59 end60 end61 end62 expect(model_definition).to_not raise_error63 end64 it 'should throw an error when an unknown declaration is present' do65 model_definition = lambda do66 undefine_copyable_in CopyableCoin67 class CopyableCoin < ActiveRecord::Base68 copyable do69 disable_all_callbacks_and_observers_except_validate70 columns({71 kind: :copy,72 year: :copy,73 })74 associations({75 })76 what_the_heck_is_this_doing_here77 end78 end79 end80 expect(model_definition).to raise_error(Copyable::DeclarationError)81 end82 it 'should throw an error if a required declaration is missing' do83 model_definition = lambda do84 undefine_copyable_in CopyableCoin85 class CopyableCoin < ActiveRecord::Base86 copyable do87 # MISSING disable_all_callbacks_and_observers_except_validate88 columns({89 kind: :copy,90 year: :copy,91 })92 associations({93 })94 end95 end96 end97 expect(model_definition).to raise_error(Copyable::DeclarationError)98 model_definition = lambda do99 undefine_copyable_in CopyableCoin100 class CopyableCoin < ActiveRecord::Base101 copyable do102 disable_all_callbacks_and_observers_except_validate103 # MISSING columns({104 # kind: :copy,105 # year: :copy,106 # })107 associations({108 })109 end110 end111 end112 expect(model_definition).to raise_error(Copyable::DeclarationError)113 model_definition = lambda do114 undefine_copyable_in CopyableCoin115 class CopyableCoin < ActiveRecord::Base116 copyable do117 disable_all_callbacks_and_observers_except_validate118 columns({119 kind: :copy,120 year: :copy,121 })122 # MISSING associations({123 # })124 end125 end126 end127 expect(model_definition).to raise_error(Copyable::DeclarationError)128 end129 end130 #*****************************************************************************131 # COLUMNS132 context 'copyable:columns' do133 context 'when missing columns' do134 before(:each) do135 @model_definition = lambda do136 undefine_copyable_in CopyableCoin137 class CopyableCoin < ActiveRecord::Base138 copyable do139 disable_all_callbacks_and_observers_except_validate140 columns({141 kind: :copy,142 })143 associations({144 })145 end146 end147 end148 end149 it 'should throw an error' do150 expect(@model_definition).to raise_error(Copyable::ColumnError)151 end152 end153 context 'with unknown columns' do154 before(:each) do155 @model_definition = lambda do156 undefine_copyable_in CopyableCoin157 class CopyableCoin < ActiveRecord::Base158 copyable do159 disable_all_callbacks_and_observers_except_validate160 columns({161 what_is_this_column_doing_here: :copy,162 kind: :copy,163 year: :copy,164 })165 associations({166 })167 end168 end169 end170 end171 it 'should throw an error' do172 expect(@model_definition).to raise_error(Copyable::ColumnError)173 end174 end175 end176 #*****************************************************************************177 # ASSOCIATIONS178 context 'copyable:associations' do179 context 'when missing associations' do180 before(:each) do181 @model_definition = lambda do182 class CopyablePet < ActiveRecord::Base183 copyable do184 disable_all_callbacks_and_observers_except_validate185 columns({186 name: :copy,187 kind: :copy,188 birth_year: :copy,189 })190 associations({191 # MISSING copyable_toys: :copy,192 copyable_pet_tag: :copy,193 copyable_pet_profile: :copy,194 copyable_pet_foods: :copy,195 copyable_pet_sitting_patronages: :copy,196 })197 end198 end199 end200 end201 it 'should throw an error' do202 expect(@model_definition).to raise_error(Copyable::AssociationError)203 end204 end205 context 'with unknown associations' do206 before(:each) do207 @model_definition = lambda do208 class CopyablePet < ActiveRecord::Base209 copyable do210 disable_all_callbacks_and_observers_except_validate211 columns({212 name: :copy,213 kind: :copy,214 birth_year: :copy,215 })216 associations({217 this_assoc_should_not_be_here: :copy,218 copyable_toys: :copy,219 copyable_pet_tag: :copy,220 copyable_pet_profile: :copy,221 copyable_pet_foods: :copy,222 copyable_pet_sitting_patronages: :copy,223 })224 end225 end226 end227 end228 it 'should throw an error' do229 expect(@model_definition).to raise_error(Copyable::AssociationError)230 end231 end232 end233end...

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful