joshmcarthur / spree-import-products

A Spree extension to allow users to batch upload Products from a CSV file using Delayed Job
http://spreecommerce.com/extensions/103-import-products
BSD 3-Clause "New" or "Revised" License
80 stars 99 forks source link

Adding Tests #12

Open joshmcarthur opened 12 years ago

joshmcarthur commented 12 years ago

Hi everyone,

I'm adding this issue to ask if anyone is able to help me out to get spree-import-products covered by specs. I've spent the last few weeks trying to get my head around the best way to do the following things:

  1. Testing for multiple versions of Spree: I'm keen to maintain backwards compatibility with Spree, ideally back to the version for which I built this extension (0.30, I believe). The challenges I've faced here include architecting the extension to work with different versions, and, in particular, how to generate some sort of test app that I can test the extension with. Spree's generators for test apps seem to have changed over versions, so it's not a simple command I can run, and different versions seem to have different requirements of the extension.
  2. Writing concise, useful specs that cover the majority of the code base: while I've written RSpec specs before on more than one occasion, I've not yet managed to write specs for an application that I'm happy with in terms of conciseness and usefulness.

So far, I've had a nice strategy suggested to me to use a Versionfile to manage backwards compatibility. This would involve having a branch dedicated to each version of Spree that should be supported. This simplifies generating sandbox Spree apps for running specs against, and code that is specific to one or more versions (Such as deface support).

I would appreciate any offers to either try and get a testing infrastructure set up that myself and others can run specs against, to add specs yourself, to help me out, or generally to offer opinions and advice. I'll continue to monitor and feedback on this issue as I carry on trying to get a testing infrastructure in place.

autotelik commented 12 years ago

Hi Josh, I have a fair amount of specs and coverage for a active record import/export project which grew out of some Spree work so has specific Spree loader, tasks and specs.

https://github.com/autotelik/interact

You may be able to use these specs as a basis for your own - there is a number of csv files with spree test data,(plus .xls files which can easily be converted to csv)

Also as this is a non spree gem, I've written some test helpers that dynamically generate a Spree database and load the spree gem, so no need to manually create a Spree app each time .. which may help with the different version situation.

Also wondered whether perhaps you fancied working on a combined solution together. My project currently focused on rake tasks but could be nice to also have a Spree extension making it available through the /admin section.

Either way, feel free to copy/use/steal/borrow any of the specs that might help you.

And Merry Christmas !

tom