-
Notifications
You must be signed in to change notification settings - Fork 75
Testing
Datashift has been developed using RSpec, and these provide good examples of how to use the library and tasks.
It comes with a number of helpers to simpify testing outside of an actual Rails project, including utilities to create a Rails application sandbox.
Specs have their own Gemfile in which you can specify Rails, and any other gem versions
Aim is to **enable standalone testing - no need to install datashift within a host application to test it.
Different Rails versions can be tested easily by simply switching version in spec/Gemfile and running bundle update
Prior to the specs being run, suitable database connections will be created for ActiveRecord, and test models loaded.
You should first specify the versions of active record and Spree, that you want the specs will be run against :
Edit
ruby spec/Gemfile.
Then run :
cd spec
bundle install
A sandbox will be generated in spec/sandbox if no such directory exists.
N.B Manual Step When changing versions you probably need to delete this whole directory spec/sandbox. Next time you run spree specs it will be auto generated using latest Rails versions
The database are created in sqlite3 and are stored in spec/fixtures. When switching versions, of say Spree, you will probably want to and to clear out old versions and retrigger the migrations
rm spec/fixtures/*.sqlite
You will probably also want to remove lock file :
rm spec/Gemfile.lock
I have noticed some odd behaviour the first time the sandbox etc is regenerated, alot of tests fail, so it's like not everything loads correctly during the regeneration process.
Invariably the next time I run the specs they pass, so a fix very low priority.
** N.B You should run the specs from within the specs directory. **
jruby -S bundle exec rspec -c .
A datashift **log **will be written within spec/logs, which hooks into the standard active record logger
/log/datashift.log
spec/logs/datashift_spec.log