How to scale an object in animation?
Create a Bezier Curve and place it on top of your 2 cubes like in the picture





Select the top-left corner adn press E to extrude it and place the new vertex in the top-right corner (use X or Y to keep it at the same height). To get right corners set the Properties > Object Data > Shape > Resolution Preview U to 1.





Keep extruding until you get a rectangular spiral (I did it quickly so it's not straight, but you get the point)





Create a rectangle curve (it has to be a curve, not a mesh!) by using a circle with resolution set to 1 or by using the addon Add Curve: Extra Objects (it's already inBlender, you just need to enable it in the User Preferences).
In the spiral's Properties > Object Data > Geometry > Bevel > Object insert your rectangle and enable Fill Caps





Resize your rectangle and animate the End slider


If you want your corners to be a bit rounded you can increase your Resolution Preview U, but you'll have to play quite a bit with your vetex handles