I can't make RSpec 1.0.8 run in Rails 1.2.3

I followed the directions on the site:

ruby script/plugin install
svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec
ruby script/plugin install
svn://rubyforge.org/var/svn/rspec/tags/REL_1_0_8/rspec_on_rails
ruby script/generate rspec

And apparently everything was ok. But when I do a “rake spec” on the app
folder none of the Rails models are visible. Here is the error:

(in C:/Projects/Rails/Workspace/MPS)
./spec/report_class_spec.rb:4: uninitialized constant ReportClass
(NameError)

I just have this on report_class_spec.rb:

describe ReportClass, ‘#new’ do
end

ReportClass was already created on app/models. When I add the following
line at the top of the file it complains about ActiveRecord
(uninitialized constant)

require File.dirname(FILE) + ‘/…/app/models/report_class’

Thanks in advance,

Daniel

  Be smarter than spam. See how smart SpamGuard is at giving junk 

email the boot with the All-new Yahoo! Mail at

I recently installed RSpec into a new project and didn’t approach the
install the same way. I’m using the same version of Rails and did the
following:

gem install rspec
ruby script/plugin install
svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec_on_rails
ruby script/generate rspec

After that it worked just fine.

I wouldn’t specify the actual version unless you need an earlier release
for some reason.

With Regards,

// Signed //

Cody P. Skidmore

On 10/5/07, Daniel M. [email protected] wrote:

I followed the directions on the site:

ruby script/plugin install
svn://rubyforge.org/var/svn/rspec/tags/CURRENT/rspec
ruby script/plugin install
svn://rubyforge.org/var/svn/rspec/tags/REL_1_0_8/rspec_on_rails
ruby script/generate rspec

First - the directions on the site should guide you to use either
CURRENT for both or REL_1_0_8 for both.

And apparently everything was ok. But when I do a “rake spec” on the app
folder none of the Rails models are visible. Here is the error:

What do you mean “rake spec on the app folder”? You should be in the
project root. Are you?

(in C:/Projects/Rails/Workspace/MPS)
./spec/report_class_spec.rb:4: uninitialized constant ReportClass
(NameError)

Well - not sure why your’e geting a name error, but a model spec
should be in spec/models:

spec/models/report_class_spec.rb

HTH,
David

I removed both plugins and reinstalled them using the CURRENT tag. Then
ran the ‘ruby script/generate rspec’ and finally the ‘rake spec’, but I
get the same error. Here is the full trace:

C:\Projects\Rails\Workspace\MPS>rake spec --trace
C:0:Warning: require_gem is obsolete. Use gem instead.
(in C:/Projects/Rails/Workspace/MPS)
** Invoke spec (first_time)
** Invoke db:test:prepare (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:test:prepare
** Invoke db:test:clone (first_time)
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
** Invoke db:test:purge (first_time)
** Invoke environment
** Execute db:test:purge
** Execute db:test:clone
** Invoke db:schema:load (first_time)
** Invoke environment
** Execute db:schema:load
** Execute spec
./spec/models/report_class_spec.rb:4: uninitialized constant ReportClass
(NameError) from
C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.r
b:106:in load' from C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.r b:106:inload_specs’ from
C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.r
b:105:in each' from C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.r b:105:inload_specs’ from
C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.r
b:49:in prepare!' from C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/behaviour_runner.r b:19:inrun’ from
C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/command_line.rb:17
:in run' from C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:1 81:inparse_options_file’
… 7 levels…
from
C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:1
55:in parse' from C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/option_parser.rb:8 8:increate_behaviour_runner’ from
C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib/spec/runner/command_line.rb:14
:in `run’ from
C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/bin/spec:3
rake aborted!
Command ruby
-I"C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/lib"
“C:/Projects/Rails/Workspace/MPS/vendor/plugins/rspec/bin/spec”
“spec/models/report_class_spec.rb” --options
“C:/Projects/Rails/Workspace/MPS/config/…/spec/spec.opts” failed

On 10/5/07, Cody P. Skidmore [email protected] wrote:

I wouldn’t specify the actual version unless you need an earlier release
for some reason.

Actually - that goes against our recommendation. Relying on gems that
may or may not be aligned across versions or machines leads to
unexpected and unhappy results. We strongly recommend you install both
plugins of the same version in each app.

Cheers,
David

This will sound silly but adding

require File.dirname(FILE) + ‘/…/spec_helper’

at the very top of my tests fixed the problem. Thanks for your help.

Daniel

On 10/10/07, Daniel M. [email protected] wrote:

This will sound silly but adding

require File.dirname(FILE) + ‘/…/spec_helper’

at the very top of my tests fixed the problem. Thanks for your help.

Sorry man - should have seen that from the first post. Though you
might consider pastie next time around - makes things easier to see
separate from the email.

http://pastie.caboo.se/

Cheers,
David

No worries, thanks for the link. Daniel