我是在Rails应用程序中使用RSpec的新手,我无法让RSpec看到我的模型:(
我在我的Gemfile
中添加了以下行
group :development, :test do
gem rspec-rails
end
并安装了
rails generate rspec::install
然后我在app/models/
目录中创建了一个facebook_page.rb
ActiveModel
class FacebookPage
class << self
# define class variables
attr_accessor :app_id
attr_accessor :app_secret
end
end
现在我正在尝试测试它,所以我在spec/models/
目录中添加了一个facebook_page_spec.rb
describe FacebookPage do
describe ".app_id" do
it "should return the FB_APP_ID environment variable and thus not be null" do
FacebookPage.app_id.should_not be_empty
end
end
end
但当我奔跑时
bundle exec rake spec
我得到以下错误:
/home/geoffroy/.rvm/rubies/ruby-1.9.3-p194/bin/ruby -S rspec ./spec/models/facebook_page_spec.rb
/home/geoffroy/dev/mybandpage/spec/models/facebook_page_spec.rb:1:in `<top (required)> : uninitialized constant FacebookPage (NameError)
RSpec does not seem to load my model file. Is it because it s not a subclass of ActiveRecord ? How can I solve that ?
提前非常感谢,最好
杰弗里