Domanda

Voglio testare un metodo definito in un'attività di rastrello.

File di rastrello

#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

Ora voglio testare questo metodo, task_needs_to_run? In un file di test come faccio a farlo?

Nota aggiuntiva: Idealmente vorrei testare anche un altro metodo privato nell'attività del rastrello ... ma posso preoccuparmi più tardi.

Nessuna soluzione corretta

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top