Hope that helps You're adding something called "Factories specs" (plural) to the STATS_DIRECTORIES array, but you call it "Factory specs" (singular) when you add it to TEST_TYPES array -- so when rake:stat hits your test/factories folder, it looks for "Factories specs" in TEST_TYPES, doesn't find it, and assumes it's code, not tests. You need to call it the same thing in both places:
::STATS_DIRECTORIES << %w(Factory\ specs test/factories) if File.exist?('test/factories')
::CodeStatistics::TEST_TYPES << "Factory specs" if File.exist?('test/factories')
calling a class method from scheduler.rake in ruby
will be helpful for those in need When you invoke Rake, you can pass the --trace flag to it. This should give you a backtrace, which I suspect is going to tell you the error is on the line not_flag = all_Active_Games > 0, because all_Active_Games is an ActiveRecord relation, but you're trying to compare it to the integer 0. Bascially, you have a type error. In a static language, this wouldn't even compile. It would also be good to also fix your indentation, choose more descriptive variable names (x -> game)
In Ruby on Rails rake task is calling a function from another rake file
seems to work fine As you can see, I've defined a function inside a rake file. No problem, that works fine. Problem is, when I declare def get_user_input in another rake file. In that case the function gets called from another .rake file Can you suggest anything? . , Moved the functions into a module and the problem gone.
namespace :backtest do
if ENV['date_from'].present? && ENV['date_until'].present?
# get input...
abort 'Sample usage: blah blah...'
desc "Start backtest"
task :start => :environment do
# rest of the code...
When do I have to 'require' a Ruby class in my Rake task?
it should still fix some issue When you see errors like "uninitialized constant" popping up and you're sure you've defined that constant in a file somewhere, make sure you're loading that code in before the method with the error runs. It looks like in this case config/environment wasn't loaded before DB was referenced, so it can't complete.