I want to use ci_reporter to generate report xml, and then let jenkins publish error message.
I added this into gemfile
gem "ci_reporter"
Put following code into Rakefile
require 'ci/reporter/rake/rspec'
task :rspec => 'ci:setup:rspec'
Created a task file and put following code in lib/ci_report.rake
namespace :ci do
task :all => ['ci:setup:rspec', 'rspec']
end
Then typed rake ci:all in terminal, but it threw this error
rake aborted!
LoadError: cannot load such file -- ci/reporter/rake/rspec
What did I miss?
update
After searching, I still felt confused. However, I found anther gem called rspec_junit_formatter. It works perfectly!
Related
I am trying to run a ruby file that updates the database using the rake task . But overtime I run the code, I get an error saying :
rake aborted!
cannot load such file -- app/services/insert_data
The ruby file 'insert_data' is located under the app directory in a folder named 'services'
Here is the rake task I created to run it:
require 'app/services/insert_data'
namespace :record_generate do
task :test do
ruby "app/services/insert_data"
end
end
Please help in removing this error.
To be able to use Rails environment within a rake task you need to declare that:
namespace :record_generate do
task :test => :environment do |_, args|
ruby "app/services/insert_data"
end
end
I think you should try placing your app/services/insert_data inside the script directory. I'm assuming that your ruby file is not a rails model with logic. I would try this.
Get your file and place it in the /script/ directory.
Place these line of code at the top of your file
#! /usr/bin/env ruby
require_relative "../config/environment"
Now on your command line you can do execute this:
rails runner name_of_your_file
That is one way of doing it. If you specifically need to use a rake task I can try posting an answer for that too.
Inside your task :test block try -
Rake.application.rake_require "#{Rails.root}/app/services/insert_data"
I am doing resque in Rails. In the Rails project, I have a file name setup.rb and helper.rb in the same directory. In setup.rb I have
require './helper'
When I tried to run bundle exec rake resque:work QUEUE="*" or rake resque:work QUEUE="*" I got error. The error is:
No such file to load -- ./helper
When I tried to rails console, Dir.chdir to that directory and type in require './helper' it return true, which means it works fine. I cannot explain why the setup.rb cannot require './helper'.
try using Rails.root for the file path and make it absolute instead of relative
Build-in rake tasks work fine, but my new custom one, in Project/lib/tasks/payments.rb doesn't get loaded:
namespace :payments do
desc "Tally payments at the end of the month"
task :compute => :environment do
BillingPeriod.compute_new_period
end
end
$ rake payments:compute
(in /Users/rob/Code/Apps/skyfarm)
rake aborted!
Don't know how to build task 'payments:compute'
It works fine if I load the file application.rb:
require 'lib/tasks/payments.rb'
...but it breaks other things:
$ rails s
./lib/tasks/payments.rb:1: undefined method `namespace' for main:Object (NoMethodError)
Change the file extension from .rb to .rake.
In this specific case, not having a .rake extension caused the error. However, I had the same issue with a Rails 4.2 app today, and it was because I did not have a desc for my rake task, so make sure if you're writing your own task (i.e. not generating one) that you add a desc.
For more information: http://guides.rubyonrails.org/command_line.html#custom-rake-tasks
As per the Rails guide 2.10 Custom Rake Tasks
Custom rake tasks have a .rake extension and are placed in Rails.root/lib/tasks.
But you have .rb extension.
I am trying to install the spree gem using the following instructions http://spreecommerce.com/resources/quick-start
I am getting following error on step 4.6(Populating the Database)
$ rake db:bootstrap
.....
.......
rake aborted!
couldn't parse YAML at line 6 column 50
....
.....
I am using ruby 1.9.2p0, rails 3.0.3 and spree 0.40.2.
Can anyone please tell me what could be the problem?
There's probably an error in a YAML file, not surprisingly. It's likely a fixture used in the bootstrapping process.
You can always run rake with the --trace option to get a better sense of what it was trying to do. Have a look through your fixture files to see if any are invalid, especially at the position indicated.
In boot.rb file inside config directory of my rails project home I added following and it worked.
require 'yaml'
YAML::ENGINE.yamler= 'syck'
I followed instruction from http://www.ruby-forum.com/topic/1002689
I'm developing an application using rails 2.3.5, gitorious and deploy with vlad, the OS is Linux Mint 9 Isadora.
vlad:setup and vlad:update are ok.
But when I vlad:migrate and have the same error than if I ssh on the server and try a rake gems:install
rake aborted!
no such file to load -- ya2yaml
/var/www/path/to/releases/20100622030150/Rakefile:10
(See full trace by running task with --trace)
My config/environment.rb is good:
RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
# Bootstrap the Rails environment, frameworks, and default configuration
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
config.gem "haml"
I have a custom task in lib/tasks/db_fixtures.rake that requires ya2yaml:
namespace :export do
desc 'Create YAML test fixtures from data in an existing database.
Defaults to development database. Set RAILS_ENV to override.'
require 'rubygems'
require 'ya2yaml'
task :fixtures => [:environment] do
When I rename this file it is not loaded by rake and I don't have the error anymore when I rake gems:install
So my guess is that it looks like rake gems:install tries to load the libs in my custom tasks before installing the gems for some reason and throw me an error.
What would be a solution?
Thanks,
this might work? delay the requires on your rake task by moving them into the task itself
task :fixtures => [:environment] do
require 'rubygems'
require 'ya2yaml'
# ...
by default running rake tasks 'loads' all of the rake files