The user.rb file starts with:
class User < ActiveRecord::Base
The user_spec.rb file starts with:
describe User do
When I run the test (using rake spec, bundle exec autotest, rspec
spec/user_spec.rb )
I get the error:
`const_missing': uninitialized constant User (NameError)
within the following trace:
loading autotest/rspec2
bundle exec /Users/Sam/.rvm/rubies/ruby-1.8.7-p330/bin/ruby -S
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/bin/rspec
--tty
'/Users/Sam/Documents/Development/Friend-Mapper/friend_mapper_rails/spec/user_spec.rb'
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/lib/rspec/core/backward_compatibility.rb:20:in
`const_missing': uninitialized constant User (NameError)
from
/Users/Sam/Documents/Development/Friend-Mapper/friend_mapper_rails/spec/user_spec.rb:1
from
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/lib/rspec/core/configuration.rb:386:in
`load'
from
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/lib/rspec/core/configuration.rb:386:in
`load_spec_files'
from
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/lib/rspec/core/configuration.rb:386:in
`map'
from
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/lib/rspec/core/configuration.rb:386:in
`load_spec_files'
from
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/lib/rspec/core/command_line.rb:18:in
`run'
from
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/lib/rspec/core/runner.rb:55:in
`run_in_process'
from
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/lib/rspec/core/runner.rb:46:in
`run'
from
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/lib/rspec/core/runner.rb:10:in
`autorun'
from
/Users/Sam/.rvm/gems/ruby-1.8.7-p330/bundler/gems/rspec-core-011b1ce34016/bin/rspec:4
I tried a sample app (http://relishapp.com/rspec/file/twominutetutorial)
which worked fine. I suspect that the issue is that rspec is not loading
up the files from my rails project. Which configurations do I need to
fix for this to work?
Thanks!
--
Posted via http://www.ruby-forum.com/.
_______________________________________________
rspec-users mailing list
rspec...@rubyforge.org
http://rubyforge.org/mailman/listinfo/rspec-users
Rails 3.0.3
Ruby 1.8.7
Gemfile:
gem "rspec-rails", ">= 2.0.0.beta.10", :git =>
"git://github.com/rspec/rspec-rails.git"
gem "rspec", ">= 2.0.0.beta.10", :git =>
"git://github.com/rspec/rspec.git"
gem "rspec-core", ">= 2.0.0.beta.10", :git =>
"git://github.com/rspec/rspec-core.git"
gem "rspec-expectations", ">= 2.0.0.beta.10", :git =>
"git://github.com/rspec/rspec-expectations.git"
gem "rspec-mocks", ">= 2.0.0.beta.10", :git =>
"git://github.com/rspec/rspec-mocks.git"
On Feb 20, 5:07 pm, Samantha John <li...@ruby-forum.com> wrote:
> Additional info:
>
> Rails 3.0.3
> Ruby 1.8.7
>
> Gemfile:
> gem "rspec-rails", ">= 2.0.0.beta.10", :git =>
> "git://github.com/rspec/rspec-rails.git"
> gem "rspec", ">= 2.0.0.beta.10", :git =>
> "git://github.com/rspec/rspec.git"
> gem "rspec-core", ">= 2.0.0.beta.10", :git =>
> "git://github.com/rspec/rspec-core.git"
> gem "rspec-expectations", ">= 2.0.0.beta.10", :git =>
> "git://github.com/rspec/rspec-expectations.git"
> gem "rspec-mocks", ">= 2.0.0.beta.10", :git =>
> "git://github.com/rspec/rspec-mocks.git"
>
> --
> Posted viahttp://www.ruby-forum.com/.
> _______________________________________________
> rspec-users mailing list
> rspec-us...@rubyforge.orghttp://rubyforge.org/mailman/listinfo/rspec-users
Hi Samantha, since you're using Rails, you'll need to run the "rspec
rails installer". Take a look at the "Configure" section on this page:
http://relishapp.com/rspec/rspec-rails
Let us know if that works.
> I am new to rspec.
Welcome!
When you run the rspec:install generator, it creates a spec/spec_helper.rb file that loads the Rails environment. This file needs to be required from your user_spec.rb file, which should be spec/models/user_spec.rb, not spec/user_spec.rb.
HTH,
David
Sam