[rspec-users] Basic Rspec operation questions
weyus at att.net
Wed Oct 8 16:41:37 EDT 2008
Zach Dennis wrote:
> # This file is copied to ~/spec when you run 'ruby script/generate rspec'
> # from the project root directory.
> ENV["RAILS_ENV"] = "test"
> require File.expand_path(File.dirname(__FILE__) + "/../config/environment")
> require 'spec'
> require 'spec/rails'
This is exactly what the top of my spec_helper.rb file looks like.
I have several specs, and the success of running them is different
depending on what I do. I'm really just trying to figure out how to
take advantage of the "rake spec" task.
I'm on Windows XP. Rails 2.1.0. Rspec and Rspec-Rails 1.1.8 gems. No
Rspec plugins. Freshly generate rspec stuff using "ruby script/generate
1) If I run each of my specs separately on the command line using "spec
spec/whatever.rb" they run fine.
2) If I run "spec spec/*spec.rb", then all _but one_ run without error
(note that the one that files can be run successfully using a direct
call to it as in #1 above).
3) If I run "rake spec", I get multiple failures, all because the
config/environments/test.rb file is not loaded (I know this because they
fail due to the lack of a variable that is set only in test.rb). The
spec that failed in #2 works in this case.
4) If I run "rake spec RAILS_ENV=test", all _but one_ run without error
(same error as in #2).
I draw the following conclustions:
1) I only get the color output if I use "rake spec" (not sure why)
2) spec loads test.rb by default, but "rake spec" does not and that's
why I have to pass RAILS_ENV=test to the "rake" command.
rspec 1.1.8 gem
rspec-rails 1.1.8 gem
More information about the rspec-users