2013-02-28 48 views
0

我正在構建基於社交流gem(Rails引擎)的應用程序。我有一個Rakefile。我在我的Gemfile中包含了factory-girl gem,但由於某些原因,rake任務在該類上失敗。爲rails引擎運行測試時出錯

寶石中有很多測試,我想執行。 Rails應用程序住在:/用戶/肖恩/ Dropbox的/流暢/ sstest

的故障代碼寶石:

# Helpers for building the post activity 
# 
class ActivityObjectSpecHelper < ActiveRecord::Base 
    set_table_name "activity_objects" 
end 

class PostSpecHelper < ActiveRecord::Base 
    set_table_name "posts" 

    belongs_to :activity_object_spec_helper, :foreign_key => "activity_object_id" 
end 

Factory.define :activity_object_spec_helper do |a| 
    a.object_type "Post" 
    a.description "Post spec helper" 
end 

Factory.define :post_spec_helper do |p| 
    p.association :activity_object_spec_helper 
end 




/Users/sean/.rvm/gems/ruby-1.9.3-p327/gems/social_stream-base- 1.1.4/spec/factories/activity.rb:13:in `<top (required)>': uninitialized constant Factory (NameError) 
from /Users/sean/Dropbox/fluent/sstest/spec/spec_helper.rb:22:in `block in <top (required)>' 

Rake文件

#!/usr/bin/env rake 

require 'rspec/core' 
require 'rspec/core/rake_task' 
require 'resque/tasks' 

require File.expand_path('../config/application', __FILE__) 

Resque.after_fork = Proc.new { ActiveRecord::Base.establish_connection } if Resque.present? 

# Include social_stream-base spec 
def bsp(str) 
    base_spec_path = File.join(Gem::Specification.find_by_name('social_stream- base').full_gem_path, 'spec/') 
    File.join(base_spec_path, str) 
end 
RSpec::Core::RakeTask.new(:spec) do |s| 
    s.pattern = ['./spec/**/*_spec.rb', 
      bsp('./controllers/users_controller_spec.rb'), 
      bsp('./controllers/notifications_controller_spec.rb'), 
      bsp('./controllers/likes_controller_spec.rb'), 
      bsp('./controllers/profiles_controller_spec.rb'), 
      bsp('./controllers/comments_controller_spec.rb'), 
      bsp('./controllers/frontpage_controller_spec.rb'), 
      bsp('./controllers/posts_controller_spec.rb'), 
      bsp('./controllers/representations_spec.rb'), 
      bsp('./controllers/groups_controller_spec.rb'), 
      bsp('./controllers/settings_controller_spec.rb'), 
      bsp('./models/profile_spec.rb'), 
      bsp('./models/user_spec.rb'), 
      bsp('./models/tie_spec.rb'), 
      bsp('./models/activity_spec.rb'), 
      bsp('./models/actor_spec.rb'), 
      bsp('./models/group_spec.rb'), 
      bsp('./models/like_spec.rb'), 
      bsp('./models/post_spec.rb') 
     ] 
end 

task :default => [ :spec, 'assets:precompile' ] 

Sstest::Application.load_tasks 

回答