why is spec rake task failing when there is no test db?

I have a couple of request specs (just the ones that get created by default). Here is what I do:

SCENARIO 1:

1. drop the corresponding test database
2. run rake spec:requests and i get

.../ruby-1.9.3-p362/bin/rake spec:requests --trace
Testing started at 10:51 AM ...
** Invoke spec:requests (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
FATAL:  database "sample_test" does not exist



If I run rake spec:requests from the shell (outside of RM), the test DB is created and tests are run to completion successfully.

SCENARIO 2:

1. drop/create the test database "sample_test" (i.e, it is an empty DB at this point)
2. run rake task spec:requests and now I get:

** Invoke spec:requests (first_time)
** Invoke test:prepare (first_time)
** Invoke db:test:prepare (first_time)
** Invoke db:abort_if_pending_migrations (first_time)
** Invoke environment (first_time)
** Execute environment
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:abort_if_pending_migrations
You have 37 pending migrations:
<list of migrations show here>
Run `rake db:migrate` to update your database then try again.


Again, if I run rake spec:requests from the shell (outside of RM), the tests are run to completion successfully.


I looked at various configuration settings under 'Edit Configurations' for spec:requests / spec and could not find any setting that controls this behavior (executing a sequence of tasks with dependencies). Is this configurable? Any idea why the "rake spec:requests" command works fine from the shell but not from RM?

thanks,
Murat
1 comment

this was due to an error on my part. I had inadvertently set RAILS_ENV=test in the environment variables for spec:requests configuration. Changing it to development resolved the issue. Running the command from outside RM was working because the default environment there was development.

-Murat

0

Please sign in to leave a comment.