App can't start on production server due to RSpec missing

Hi,

I just run in the following problem when starting a Rails app on my
production server:

You have rspec rake tasks installed in
/home/thomas/rails_apps/video_on_demand/lib/tasks/rspec.rake,
but rspec can not be found in vendor/gems, vendor/plugins or on the
system.

Obviously I don’t want Rails to load anything related to rspec, how can
I tell Rails that it should not care about RSpec on the production
environment?

A quick fix is to install rspec and rspec-rails gems on production
server, but I don’t get why the app wants them installed.

On Jan 16, 2009, at 2:38 PM, Fernando P. wrote:

Obviously I don’t want Rails to load anything related to rspec, how
can
I tell Rails that it should not care about RSpec on the production
environment?

A quick fix is to install rspec and rspec-rails gems on production
server, but I don’t get why the app wants them installed.

I would delete that rake task file (lib/rspec.rake) if you don’t have
rspec installed.

Scott

I would delete that rake task file (lib/rspec.rake) if you don’t have
rspec installed.

Scott

I run rspec on my dev machine, but obviously not on my production
machine, what would be the nicest way to handle such scenario? At the
top of rspec.rake I could add a check on the environment, I could also
not add this file to my repository but I could forget about this file in
future clones of my repo, etc.

How did you solve this problem?

On Fri, Jan 16, 2009 at 1:38 PM, Fernando P. [email protected]
wrote:

Obviously I don’t want Rails to load anything related to rspec, how can
I tell Rails that it should not care about RSpec on the production
environment?

A quick fix is to install rspec and rspec-rails gems on production
server, but I don’t get why the app wants them installed.

This is a tricky business.

We put that in there in response to a user who works on a team. One
team member had pulled code and tried t run specs and got an error he
didn’t understand, so this is intended to help that developer know he
needs to install rspec.

So now this creates a new problem for you, which is that this means
you have to have rspec installed everywhere you want to run rake
tasks.

I’m open to suggestions for how to best solve for both cases if you have
any.

Cheers,
David

On Fri, Jan 16, 2009 at 10:05 PM, David C.
[email protected]wrote:

system.

any.

Make it print the message to STDERR instead of raising an error? Plus
add a
blurb like “You can ignore this warning if you didn’t intend to run
specs”

Aslak

On Fri, Jan 16, 2009 at 2:38 PM, Fernando P. [email protected]
wrote:

A quick fix is to install rspec and rspec-rails gems on production
server, but I don’t get why the app wants them installed.

Because every Rake file in /lib gets loaded when you run Rake. That’s
your dependency problem; not the app itself.


Have Fun,
Steve E. ([email protected])
ESCAPE POD - The Science Fiction Podcast Magazine
http://www.escapepod.org

On Fri, Jan 16, 2009 at 5:06 PM, Mark W. [email protected] wrote:

On Fri, Jan 16, 2009 at 1:15 PM, Fernando P. [email protected]
wrote:

I run rspec on my dev machine, but obviously not on my production
machine, what would be the nicest way to handle such scenario? At the
top of rspec.rake I could add a check on the environment

That would get my vote.

Unless I"m missing something, that would require this on the CLI:

RAILS_ENV=test rake spec

Therefore, this would not get my vote :slight_smile:

On Fri, Jan 16, 2009 at 4:15 PM, aslak hellesoy
[email protected] wrote:

production server:

So now this creates a new problem for you, which is that this means
you have to have rspec installed everywhere you want to run rake
tasks.

I’m open to suggestions for how to best solve for both cases if you have
any.

Make it print the message to STDERR instead of raising an error? Plus add a
blurb like “You can ignore this warning if you didn’t intend to run specs”

Sounds good- any objections?

On Fri, Jan 16, 2009 at 1:15 PM, Fernando P.
[email protected]wrote:

I run rspec on my dev machine, but obviously not on my production
machine, what would be the nicest way to handle such scenario? At the
top of rspec.rake I could add a check on the environment

That would get my vote.

///ark

On Fri, Jan 16, 2009 at 2:58 PM, David C. [email protected]
wrote:

I tell Rails that it should not care about RSpec on the production
needs to install rspec.

Sounds good- any objections?

That’s what I do in all of my projects…require ‘spec’, rescue
LoadError and print a helpful message.

Pat

On Jan 16, 2009, at 4:15 PM, Fernando P. wrote:

file in
future clones of my repo, etc.

I’d most certainly add it to the repos in the form of a plugin.

What exactly are you worried about? The memory overhead of loading
the rspec code? (I’m not sure exactly how rails works here - does it
simply rspec/lib/ to the $LOAD_PATH? Does it require lib/spec.rb?)

Obviously if your production code is explicitly calling rspec, you’ve
got bigger problems.

Scott

On Fri, Jan 16, 2009 at 3:19 PM, David C.
[email protected]wrote:

Therefore, this would not get my vote :slight_smile:

Because the rake tasks get loaded before the spec task has a chance to
set
RAILS_ENV. But the rakefile wouldn’t check RAILS_ENV=test, but
RAILS_ENV=production (or staging). And wouldn’t it be set that way
before
rake loads its files? (I’m gonna learn something here, whether I want to
or
not!)

///ark

If your using capistrano you could delete this file when deploying.

2009/1/16 Scott T. [email protected]

On Jan 16, 2009, at 4:15 PM, Fernando P. wrote:

I run rspec on my dev machine, but obviously not on my production
machine, what would be the nicest way to handle such scenario? At the

Actually, I run specs on my production machine,
cap deploy:spec
:slight_smile:
since its a different platform from my development,
especially on point releases of the app

Make it print the message to STDERR instead of raising an error? Plus
add a
blurb like “You can ignore this warning if you didn’t intend to run
specs”

Aslak

I like that too, +1 for me.

Obviously if your production code is explicitly calling rspec, you’ve
got bigger problems.
As Stephen said, it’s because rspec.rake located under the lib folder is
trying to load rspec (gem or plugin) without looking at the rails
environment.

On Sat, Jan 17, 2009 at 5:42 AM, Jonathan L.
[email protected]wrote:

since its a different platform from my development,
especially on point releases of the app

Umm, how do you handle that whole rake db:test:prepare thing?

///ark

On Jan 17, 2009, at 2:14 PM, Mark W. wrote:

:slight_smile:
since its a different platform from my development,
especially on point releases of the app

Umm, how do you handle that whole rake db:test:prepare thing?

///ark


rspec-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/rspec-users

I copy the schema from production, the server doesnt have a
development database.
also, my opts default to --format html so i can browse to the results
From my Capfile

task :spec, :roles => :app do
run “cd #{current_path} && rake db:test:prepare
RAILS_ENV=production” # copy schema from production rather than
development
run "cd #{current_path} && rake spec RAILS_ENV=production

public/private/specs.html"
end

A quick fix is to install rspec and rspec-rails gems on production
server, but I don’t get why the app wants them installed.

This is a tricky business.

We put that in there in response to a user who works on a team. One
team member had pulled code and tried t run specs and got an error he
didn’t understand, so this is intended to help that developer know he
needs to install rspec.

So now this creates a new problem for you, which is that this means
you have to have rspec installed everywhere you want to run rake
tasks.

I haven’t followed the ML latety, but it seems that now I don’t have to
install rspec and its friends on the production server anymore.

Andrew P. wrote:

If your using capistrano you could delete this file when deploying.

Or just not version control it:

git rm -rf --cached lib/tasks/rspec.rake
echo “lib/tasks/rspec.rake” >> .gitignore

Scott