2012-05-11 41 views
0

我正在關注ruby on rails tutorials 3.2 by Michael Hartl,但是當我將gem 'factory_girl_rails', '1.4.0'放入我的gemfile並運行bundle install時,它顯示「bundle complete」,因爲gem已經加載到我的PC中。我的問題是它不是在spec文件夾中生成factories.rb文件。出了什麼問題?Factories.rb文件未加載

Gemfile

source 'https://rubygems.org' 

gem 'rails',   '3.2.3' 
gem 'bootstrap-sass', '2.0.0' 
gem 'bcrypt-ruby', '3.0.1' 

group :development, :test do 
    gem 'sqlite3',  '1.3.5' 
    gem 'rspec-rails', '2.9.0' 
    gem 'annotate', '~> 2.4.1.beta' 
end 

# Gems used only for assets and not required 
# in production environments by default. 

group :assets do 
    gem 'sass-rails', '3.2.4' 
    gem 'coffee-rails', '3.2.2' 
    gem 'uglifier',  '1.2.3' 
end 

gem 'jquery-rails', '2.0.0' 

group :test do 
    gem 'capybara',   '1.1.2' 
    gem 'factory_girl_rails', '1.4.0' 
end 

group :production do 
    gem 'pg', '0.12.2' 
end 

routes.rb

SAMPLEApp::Application.routes.draw do 
    resources :users 

    root to: 'static_pages#home' 

    match '/signup', to: 'users#new' 
    match '/help', to: 'static_pages#help' 
    match '/about', to: 'static_pages#about' 
    match '/contact', to: 'static_pages#contact' 
end 
+0

非常感謝你霍爾格就來回編輯 –

+0

沒有什麼可擔心的傢伙,我只是整理出錯誤 –

回答

2

運行bundle install不會將任何文件添加到您的Rails應用程序。它只會下載它需要使用的合適的庫。有時候這些庫會附帶一個軌道生成器,您可以運行諸如rails generate some_library:install之類的東西。我不認爲factory_girl_rails就是這種情況。您可能需要手動添加文件。

+0

錯誤僅僅是打字錯誤謝謝 –

+0

如果安裝RSpec的和FG,標準發電機創造的投機/工廠/ modelname.rb。但它是唯一自動創建的 – Ineu

+0

'factories.rb'由RSpec創建,我猜。 – uday