开发者

RoR: Testing: undefined local variable or method `be_nil'… but… I included RSpec, spec/spec_helper, spec/matchers, etc

in my environments/test.rb:

config.gem "rspec"
config.gem "rspec-rails"

relevant part of my gemfile:

group :test do
    ...
开发者_运维百科    gem "rspec", "1.3.2"
    gem "rspec-rails", "1.3.2"

in test_helper.rb

require 'test_help' require "bundler/setup" Bundler.require(:test)

require 'factory_girl'
require 'shoulda'
require "shoulda-matchers"
require 'spec'
require 'spec/matchers'

I recently moved all my gems to a gemfile, instead of having everything in config.gem's

in my env/test.rb file, I have to use the two config.gem's or my tests don't run at all.

I've read that including spec_helper will help.... but my tests aren't in the spec folder... they are in the test folder... when I include spec/spec_helper.rb, all of my tests get WARNING: already defined.

EDIT: I found this link: https://github.com/rspec/rspec-rails/issues/93 which told me to do

include RSpec::Matchers

and I got a differente error with this one:

/Users/lprestonsegoiii/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/optparse.rb:314:in `initialize': unhandled exception

EDIT2: I've discovered through using IRB, that the minimum to use the matchers are:

require "spec/spec_helper" 
include RSpec::Matchers

But I still have the duplicate definition issue. hmm.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜