In cucumber, my seed data is loaded up via several rake tasks. None of which are working:
Spree::Core::Engine.load_seed if defined?(Spree::Core)
Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
Rake::Task['alchemy:db:seed'].invoke
When I run one of spree's rake tasks I get:
Don't know how to build task 'db:load_dir' (RuntimeError)
When I run one of alchemy's rake tasks I get:
Don't know how to build task 'alchemy:db:seed' (RuntimeError)
The testing database exists. I have ran rake db:test:prepare and it appears to be setup from my inspections. Lets move onto the hooks:
# features/support/hooks.rb
Before do
load File.join(Rails.root, 'db', 'seeds.rb')
end
This goes to the root and gets me the seed data. I decided to try this:
# features/support/hooks.rb
before do
# load File.join(Rails.root, 'db', 'seeds.rb')
Rake::Task['alchemy:db:seed'].invoke
end
The error was:
Don't know how to build task 'alchemy:db:seed' (RuntimeError)
I'm unable to figure out why the rake tasks are not working in cucumber.
My Gemfile is as follows:
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
And this is my env support file:
# 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
Rake doesn't load tasks by default, you can check for yourself:
irb(main):002:0> require 'rake'
=> true
irb(main):003:0> Rake::Task.tasks
=> []
So it doesn't "know" how to run your task. You need to tell Rails to load them:
Rails.application.load_tasks
Spree::Core::Engine.load_seed if defined?(Spree::Core)
Spree::Auth::Engine.load_seed if defined?(Spree::Auth)
It seems that the test database is missing. So as already written in the comment above, the solution is to create the database and run the migrations with
RAILS_ENV=test rake db:setup
Happy to help :)
Related
I'm trying to install fat free crm with ruby on rails on Windows 7, but when I put the command
rake db:create RAILS_ENV=production
it says
rake aborted!
LoadError: cannot load such -- 2.1/pg_ext
Normally, it would say what gem I should install, but not in this case.
How can I solve this error?
Edit:
A friend of mine suggested to uncomment mysql2 and comment pg on the Gemfile file in the proyect like this:
gem 'mysql2'
#gem 'sqlite3'
#gem 'pg'
But now I get this:
Unable to load the EventMachine C extension; To use the pure-ruby reactor, requi
re 'em/pure_ruby'
C:/Ruby21/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require': ca
nnot load such file -- 2.1/rubyeventmachine (LoadError)
Have any ideas of why this happends?
Here is my Gemfile:
source 'https://rubygems.org'
# Uncomment the database that you have configured in config/database.yml
# ----------------------------------------------------------------------
gem 'mysql2'
# gem 'sqlite3'
# gem 'pg'
# Removes a gem dependency
def remove(name)
#dependencies.reject! {|d| d.name == name }
end
# Replaces an existing gem dependency (e.g. from gemspec) with an alternate source.
def gem(name, *args)
remove(name)
super
end
# Bundler no longer treats runtime dependencies as base dependencies.
# The following code restores this behaviour.
# (See https://github.com/carlhuda/bundler/issues/1041)
spec = Bundler.load_gemspec( File.expand_path("../fat_free_crm.gemspec", __FILE__) )
spec.runtime_dependencies.each do |dep|
gem dep.name, *(dep.requirement.as_list)
end
# Remove premailer auto-require
gem 'premailer', :require => false
# Remove fat_free_crm dependency, to stop it from being auto-required too early.
remove 'fat_free_crm'
group :development do
# don't load these gems in travis
unless ENV["CI"]
gem 'thin'
gem 'quiet_assets'
gem 'capistrano'
gem 'capistrano-bundler'
gem 'capistrano-rails'
gem 'capistrano-rvm'
#~ gem 'capistrano-chruby'
#~ gem 'capistrano-rbenv'
gem 'guard'
gem 'guard-rspec'
gem 'guard-rails'
gem 'rb-inotify', :require => false
gem 'rb-fsevent', :require => false
gem 'rb-fchange', :require => false
end
end
group :development, :test do
gem 'rspec-rails', '~> 2'
gem 'headless'
gem 'debugger', :platforms => 'mri_19' unless ENV["CI"]
gem 'byebug', :platforms => ['mri_20', 'mri_21'] unless ENV["CI"]
gem 'pry-rails' unless ENV["CI"]
end
group :test do
gem 'capybara'
gem 'selenium-webdriver'
gem 'database_cleaner'
gem "acts_as_fu"
gem 'factory_girl_rails'
gem 'zeus' unless ENV["CI"]
gem 'coveralls', :require => false
gem 'timecop'
end
group :heroku do
gem 'unicorn', :platform => :ruby
gem 'rails_12factor'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'
gem 'uglifier', '>= 1.0.3'
gem 'execjs'
gem 'therubyracer', :platform => :ruby unless ENV["CI"]
end
gem 'turbo-sprockets-rails3'
It sounds like you are missing the pg gem from your Gemfile. Is it in the development group?
Can you post your Gemfile?
Uncomment #gem pg.
Unable to load the EventMachine C extension; To use the pure-ruby reactor, require 'em/pure_ruby' is a separate error. Where did you get that Gemfile?
I have almost read every question and doc about deployment to heroku, and this is not my first time, but now in a very weird scnario when I deploy I can't create the database:
Running `rake db:create --trace` attached to terminal... up, run.8982
** Invoke db:create (first_time)
** Invoke db:load_config (first_time)
** Execute db:load_config
** Execute db:create
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `initialize'
/app/vendor/bundle/ruby/1.9.1/gems/activerecord-4.1.2/lib/active_record/connection_adapters/postgresql_adapter.rb:888:in `new'
.
.
.
.
Couldn't create database for {"adapter"=>"postgresql", "host"=>"ec2-23-23-244-144.compute-1.amazonaws.com", "encoding"=>"unicode", "database"=>"d80e387p61nnl1", "pool"=>5, "template"=>"template0", "username"=>"******", "password"=>"********", "port"=>5432}
It's not this:
FactoryGirl screws up rake db:migrate process
I took out everything related to Factory girl pretty much, everything in the spec file.
Not this either:
Rails 4.0.1 on Heroku, can't create database
this is my gemfile:
source 'https://rubygems.org'
ruby '1.9.3'
gem 'rails', '4.1.2'
#Assets
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'jquery-ui-rails'
gem 'jquery-turbolinks'
gem 'turbolinks'
gem "autoprefixer-rails"
#jQuery
gem 'magnific-popup-rails'
gem 'ckeditor'
gem 'gmaps4rails'
gem "select2-rails"
gem 'chosen-rails'
gem 'jquery-tokeninput-rails'
gem 'jquery-timepicker-rails'
gem 'easy_as_pie'
gem 'modernizr-rails'
gem "font-awesome-rails"
gem 'jquery-slimscroll-rails'
gem 'jquery-placeholder-rails'
gem 'autosize-rails'
gem 'newrelic_rpm'
#frontend
gem 'rails_12factor', group: :production
gem 'friendly_id', '~> 5.0.0' # Note: You MUST use 5.0.0 or greater for Rails 4.0+
gem 'rack-cors', :require => 'rack/cors'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'bootstrap-sass'
gem 'devise'
gem 'high_voltage'
gem 'thin'
gem 'lodash-rails'
#Database
gem 'ransack'
gem 'pg'
gem 'pg_search'
gem 'simple_form'
# gem 'ng-rails-csrf'
gem 'wiselinks'
# Development Only
group :development do
gem 'binding_of_caller', :platforms=>[:mri_19]
gem 'rails_layout'
gem 'meta_request'
gem 'better_errors'
gem 'hirb' #use Hirb.enable to enable it / text to Column
gem 'awesome_print', :require => 'ap'
gem 'railroady' #run this command: rake diagram:all
gem "bullet" # it always works unless you remove the initilzer
gem "reek" # run this : reek .
gem 'brakeman', :require => false # run this : brakeman [appPath] -o output_file
gem 'traceroute' # to check unUsed and Unreachable routes > rake traceroute
gem 'quiet_assets' #takes away the Asset messages in the Log
gem 'annotate', ">=2.6.0"
gem "letter_opener", :group => :development
gem 'rails_apps_pages'
end
group :development, :test do
gem 'rspec-rails'
end
group :test do
gem 'capybara'
gem 'database_cleaner'
gem 'launchy'
gem 'selenium-webdriver'
end
gem 'ffaker'
gem 'populator'
gem 'activeadmin', github: 'gregbell/active_admin'
# gem "meta_search", '>= 1.1.0.pre'
#rails Legacy Gems
gem 'protected_attributes'
gem 'rails-observers'
gem 'actionpack-page_caching'
gem 'actionpack-action_caching'
#Images:
gem 'carrierwave'
gem 'rmagick', :require => false
gem 'kaminari'
# gem "bower-rails", "~> 0.8.3"
# gem 'react-rails', '~> 0.10.0.0'
# gem 'react-rails', '~> 1.0.0.pre', github: 'reactjs/react-rails'
# gem "therubyracer", :platforms => :ruby
# gem "therubyrhino", :platforms => :jruby
gem 'activerecord-reputation-system'
gem 'acts-as-taggable-on'
gem 'markable'
gem 'country_select', github: 'stefanpenner/country_select'
gem 'rails4-autocomplete'
# gem 'linkedin' hasie 3.3.0 error
#messaging
gem 'mailboxer'
IN my Heroku Logs, this what I found:
Notice: server is listening on all interfaces (0.0.0.0). Consider using 127.0.0.1 (--binding option)
2014-09-07T17:20:38.089695+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-09-07T17:20:38.089697+00:00 app[web.1]: Exiting
2014-09-07T17:20:38.357403+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:247:in `require': No such file to load -- mini_magick (LoadError)
2014-09-07T17:20:38.357406+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-4.1.2/lib/active_support/dependencies.rb:247:in `block in require'
any help would be veryyy very much appreciated.
There are few lessons to be learnt from this problem that I came across, but first let's answer and then explain what was going on.
Short answer:
Despite removing the tests that was considered to cause the rake to break, there were other things left out that needed to be removed and it was causing problems:
1- In the application.rbthis was happening:
config.generators do |g|
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
routing_specs: false,
controller_specs: false,
request_specs: false
g.fixture_replacement :factory_girl, dir: "spec/factories"
end
2- In seed.rb file this was happening:
# user = CreateAdminService.new.call
# puts 'CREATED ADMIN USER: ' << user.email
The lesson:
1- Don't use auto app generators. In my case I was using #RailsComposer.
2- Bower on Rails is a bad decision, it can turn a very simple app to a crazy amazin jungle
I am updating a Rails application from 3.2.12 to 4.0.0.beta1. I had a few minor issues but I could get the app running and all tests passing again. The problem is when I try to precompile all the assets for deployment, I get the following error:
vagrant#precise64:/vagrant$ RAILS_ENV=production bundle exec rake assets:precompile
rake aborted!
No such file to load -- bootstrap_flash_helper
/vagrant/config/environment.rb:5:in `<top (required)>'
Tasks: TOP => environment
(See full trace by running task with --trace)
Here is my Gemfile:
source 'https://rubygems.org'
gem 'rails', '4.0.0.beta1'
gem 'pg'
gem 'github_api'
gem 'haml-rails'
gem 'jquery-rails'
gem 'simple_form', github: 'plataformatec/simple_form'
gem 'devise', github: 'plataformatec/devise', branch: 'rails4'
gem 'omniauth'
gem 'omniauth-github'
gem 'rails-backbone', '~> 0.9.10'
gem 'inherited_resources'
gem 'app_configuration'
gem 'unicorn'
gem 'foreman'
gem 'coveralls', require: false
group :assets do
gem 'sprockets-rails', github: 'rails/sprockets-rails'
gem 'coffee-rails', github: 'rails/coffee-rails'
gem 'therubyracer', platforms: :ruby
gem 'less-rails', github: 'metaskills/less-rails'
gem 'twitter-bootstrap-rails'
gem 'uglifier', '>= 1.0.3'
end
group :development do
gem 'better_errors'
gem 'binding_of_caller'
gem 'meta_request'
end
group :test, :development do
# Debugging
gem 'pry'
gem 'debugger'
gem 'debugger-pry'
gem 'pry-nav'
gem 'pry-stack_explorer'
# Testing
gem 'timecop'
gem 'rspec-rails'
gem 'shoulda-matchers'
gem 'factory_girl_rails'
gem 'faker'
# gem 'cucumber-rails', '~>1.3.0', :require => false
gem 'database_cleaner', github: 'bmabey/database_cleaner'
end
The project is open source (work in progress), here is the github repository https://github.com/wolox/mgmt
Any idea about what I missing?
Thanks
I had a similar issue, then I found that group :assets doesn't exist anymore. After clonning your repo, I deleted the group :assets from your Gemfile, then your assets precompiled ok!
The :assets group is not loaded in the production environment by default, you can change this in your config/application.rb (https://github.com/Wolox/mgmt/blob/master/config/application.rb#L7 in your repo)
The advised practice is to compile your assets in development and then push the /public/assets directory to production once you're satisfied nothing breaks.
Use this line instead, and you should be fine:
RAILS_ENV=development bundle exec rake assets:precompile
When running 'heroku run rake' I get this error:
no such file to load -- faker
/app/lib/tasks/sample_data.rake:1:in `require'
/app/lib/tasks/sample_data.rake:1:in `<top (required)>'
I have gem 'faker', '0.3.1' under group :development, :test do in Gemfile.
I have require 'faker' in sample_data.rake
source 'https://rubygems.org'
gem 'rails', '3.2.11'
gem 'gravatar_image_tag', '0.1.0'
group :development, :test do
gem 'sqlite3', '1.3.5'
gem 'rspec-rails', '2.8'
gem 'guard-spork', '1.2.0'
gem 'faker', '0.3.1'
gem 'spork', '0.8.4'
gem 'will_paginate', '3.0'
gem 'webrat', '0.7.1'
gem 'capybara', '1.1.2'
gem 'annotate', '2.5.0'
gem 'factory_girl_rails', '1.0'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '3.2.5'
gem 'coffee-rails', '3.2.2'
gem 'uglifier', '1.2.3'
end
gem 'jquery-rails', '2.0.2'
group :production do
gem 'pg', '0.12.2'
end
Heroku does not install test or development gems by default.
If you want to load fake in your production, you should remove gem 'faker', '0.3.1' from the group :development, :test do and place it outside any group:
source 'https://rubygems.org'
gem 'rails', '3.2.11'
gem 'gravatar_image_tag', '0.1.0'
gem 'faker', '0.3.1'
group :development, :test do
gem 'sqlite3', '1.3.5'
...
However, if you don't want to load fake, you must ensure that your require fake will be required only when the task is invoked:
task :sample_data => :environment do
require 'faker' #must be inside the task.
...
end
Hope it helps.
EDIT
You can tell Bundler to not load the Gem by:
gem 'faker', '0.3.1', :require => false
I got this issue with the "Rub on Rails 3 Tutorial".
Per gabrielhilals answer, the fix was to move require 'faker' to inside the task
before fix:
require 'faker'
namespace :db do
desc "Fill database with sample data"
task :populate => :environment do
...
...
end
end
after fix:
namespace :db do
require 'faker'
desc "Fill database with sample data"
task :populate => :environment do
...
...
end
end
I'm going through the Rails 3 in Action eBook and they've put a lot of emphasis on testing but I can't seem to get Cucumber to work for some reason.
I keep getting a Rake aborted! Stack level too deep error when I use to rake cucumber:ok command.
Anyone know what might be causing this?
Here's my gem file:
source 'http://rubygems.org'
gem 'rails', '3.1.1.rc1'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'sqlite3'
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', " ~> 3.1.0"
gem 'coffee-rails', "~> 3.1.0"
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
group :test, :development do
gem 'rspec-rails', '~> 2.5'
end
group :test do
gem 'cucumber-rails'
gem 'capybara'
gem 'database_cleaner'
end
Use
bundle exec rake cucumber:ok