1
在黃瓜中,我的種子數據通過幾個rake任務加載。這些都不是工作:不知道如何構建任務 - 黃瓜
Spree::Core::Engine.load_seed if defined?(Spree::Core)
Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
Rake::Task['alchemy:db:seed'].invoke
當我運行的大禮包的耙任務之一,我得到:
Don't know how to build task 'db:load_dir' (RuntimeError)
當我運行的鍊金術的耙任務之一,我得到:
Don't know how to build task 'alchemy:db:seed' (RuntimeError)
的測試數據庫存在。我跑了rake db:test:prepare
,它似乎是從我的檢查中設置的。讓我們進入鉤子:
# features/support/hooks.rb
Before do
load File.join(Rails.root, 'db', 'seeds.rb')
end
這將進入根目錄並獲取種子數據。我決定試試這個:
# features/support/hooks.rb
before do
# load File.join(Rails.root, 'db', 'seeds.rb')
Rake::Task['alchemy:db:seed'].invoke
end
錯誤是:
Don't know how to build task 'alchemy:db:seed' (RuntimeError)
我無法弄清楚,爲什麼耙任務不黃瓜工作。
我的Gemfile如下:
source 'https://rubygems.org'
ruby '2.1.2'
gem 'rails', '4.0.6'
gem 'pg'
gem 'redis-rails'
gem 'redis-rack-cache'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'thin'
gem 'durable_decorator_rails', github: 'jumph4x/durable_decorator_rails'
gem 'newrelic_rpm'
gem 'rake'
gem 'spree', '2.2.2'
gem 'spree_gateway', github: 'spree/spree_gateway', branch: '2-2-stable'
gem 'spree_auth_devise', github: 'spree/spree_auth_devise', branch: '2-2-stable'
gem 'spree_bootstrap_frontend', github: '200Creative/spree_bootstrap_frontend', branch: '2-2-stable'
gem 'alchemy_cms', github: 'magiclabs/alchemy_cms'
gem 'spree_alchemy', github: 'tesserakt/spree_alchemy'
group :doc do
gem 'sdoc', '~> 0.4.0'
end
group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'meta_request'
end
group :test do
gem 'simplecov', require: false
gem 'cucumber-rails', require: false
gem "cucumber-websteps"
gem 'database_cleaner'
gem "selenium-webdriver"
gem "capybara-webkit"
end
group :development, :test do
gem "factory_girl_rails", "~> 4.0"
gem "rspec-rails"
gem 'rspec-its'
gem 'shoulda-matchers', require: false
end
這是我的ENV支持文件:
# features/support/env.rb
require 'cucumber/rails'
ActionController::Base.allow_rescue = false
begin
DatabaseCleaner.strategy = :transaction
rescue NameError
raise 'You need to add database_cleaner to your' \
'Gemfile (in the :test group) if you wish to use it.'
end
Cucumber::Rails::Database.javascript_strategy = :truncation
Capybara.register_driver :chrome do |app|
Capybara::Selenium::Driver.new(app, browser: :chrome)
end
Capybara.javascript_driver = :chrome
該rails的版本,你運行?耙子任務'db:test:prepare'從哪裏來?這不是一個標準的Rails任務。所以我會仔細檢查測試數據庫是否真的存在。你可以試試'RAILS_ENV = test rake db:setup',看看輸出是什麼。 – awenkhh
Rails 4.0.6,我試過RAILS_ENV = test。嘗試你的建議。 – BenMorganIO
@awenkhh在'for main:Object'之前,你的編輯引起了'未定義的方法'。將切換回來。 – BenMorganIO