rake

Rails 3.1 engines migrations are not working

牧云@^-^@ 提交于 2019-12-10 13:29:11
问题 I'm creating a rails 3.1 engine with migrations. rake db:migration works fine inside that engine, and inside host app. But I need to include this engine into another rails engine. The second engine contains dummy app for testing, I added to application.rb of that dummy app this line: require 'my_engine' In the console, I can see classes from the first engine. rake -T give me app:my_engine_engine:install:migrations task, but when I'm run this task rake app:my_engine_engine:install:migrations I

Execute system command with Rake outside Bundle scope

旧时模样 提交于 2019-12-10 12:54:03
问题 Let say I have this Rake task: namespace :db do namespace :dump do. desc 'Backup database dump to s3' task :backup => :environment do cmd = ['backup', 'perform', '-t project_backup', "-c #{Rails.root.join 'lib', 'backup', 'config.rb'}"] system(*cmd) # ...I've tried `` & exec() sa well, same thing end end end Backup gem is stand alone ruby gem application which dependencies needs to be isolated from application bundler. In other words it cannot be part of Gemfile . This gem is simply installed

Testing a method defined in a rake task

蹲街弑〆低调 提交于 2019-12-10 12:39:20
问题 I want to test a method defined in a rake task. rake file #lib/tasks/simple_task.rake namespace :xyz do task :simple_task => :environment do begin if task_needs_to_run? puts "Lets run this..." #some code which I don't wish to test ... end end end def task_needs_to_run? # code that needs testing return 2 > 1 end end Now, I want to test this method, task_needs_to_run? in a test file How do I do this ? Additional note: I would ideally want test another private method in the rake task as well...

Rake db:setup or rake db:create applying wrong username/wrong database

我与影子孤独终老i 提交于 2019-12-10 11:17:54
问题 Using Mac OSX Yosemite (10.10.4): rails -v => Rails 4.2.3 ruby -v => ruby 2.2.2p95 Followed a combination of these instructions: https://www.digitalocean.com/community/tutorials/how-to-setup-ruby-on-rails-with-postgres and these instructions: http://blog.endpoint.com/2014/03/setup-rails-environment-with-postgresql.html bash: $createuser -P -d -e project (This was successful) $password: aPassword $re-enter password: aPassword $rails new project --database=postgresql $cd project/config/database

Hot deploy Ruby just like PHP: FTP upload file and valid immediately

我的梦境 提交于 2019-12-10 11:13:04
问题 Is it possible to hot deploy Ruby just like PHP? Normally I used FTP to upload the PHP file, then it will be available automatically. Can Ruby hot deploy its file like this? Your comment welcome. 回答1: Are you talking about a ruby on rails application ? If so, when deploying a rails application in production mode, the all application gets loaded in memory. So changing the files won't affect the running application. For hot restarting a rails application you will need to use solution such as:

Rake task failing to load :environment properly

[亡魂溺海] 提交于 2019-12-10 10:31:31
问题 I'm running a custom rake task... namespace :import do desc "Import terms of service as HTML from stdin" task :terms => :environment do html = STDIN.read settings = ApplicationWideSetting.first settings.terms_and_conditions = html if settings.save puts "Updated terms of service" else puts "There was an error updating terms of service" end end end The model ApplicationWideSetting is reported as undefined when running the task in the production environment. However, when running the task on

Rspec Rake Task: How to parse a parameter?

醉酒当歌 提交于 2019-12-10 10:16:10
问题 I have a rake task which generates a new User. Values of email, password and password_confirmation (confirm) needs to be typed in through the command line. This is my rake task code: namespace :db do namespace :setup do desc "Create Admin User" task :admin => :environment do ui = HighLine.new email = ui.ask("Email: ") password = ui.ask("Enter password: ") { |q| q.echo = false } confirm = ui.ask("Confirm password: ") { |q| q.echo = false } user = User.new(email: email, password: password,

How to programmatically determine the installed version of IE from a script

笑着哭i 提交于 2019-12-10 04:04:45
问题 We have an automated testing cluster based on selenium-grid. To manage the cluster, I have built a collection of Rake (Ruby) tasks which can start, restart, ping, and stop nodes. I'm testing our application across a number of browsers including IE6, IE7, and IE8. This means each node in the cluster has to be aware of which version of IE is installed so that it can claim the correct selenium-grid profile name (eg: "IE6 on Windows XP" vs. "IE8 on Windows Vista" ), so that certain tests can be

How to manage migrations for a rails engine + dummy app

丶灬走出姿态 提交于 2019-12-10 03:36:21
问题 I just joined a project developing a rails engine, that also has a dummy app for testing. foo/ foo/spec/dummy/ There are identical migrations in foo/db/migrate/ foo/spec/dummy/db/migrate/ If I rake db:migrate from the dummy app, all is well. If I do the same from the engine (current directory = foo) I get an error about multiple migrations with the same name. Q1) Are the Rakefiles borked? (should db:migrate recurse down to the dummy app?) Q2) Should the migrations only be in one directory? If

Ruby - Executing tests in a random order with rake

℡╲_俬逩灬. 提交于 2019-12-10 03:24:36
问题 How can I have the tests for my Rails app to be executed in a random order? Is there a simple solution using rake? 回答1: Here you go, define this in lib/tasks/tasks.rb namespace :test do namespace :randomize do desc "Randomize tests" Rake::TestTask.new(:all => "db:test:prepare") do |t| t.libs << "test" t.test_files = Rake::FileList[ 'test/unit/**/*_test.rb', 'test/functional/**/*_test.rb', 'test/integration/**/*_test.rb' ].shuffle t.verbose = true end end end Run: rake test:randomize:all Keep