Commit 9a2f97e0339f47ed71be32fed100dc9b485cdb7e

Authored by Nathan Broadbent
1 parent 11f5cd34
Exists in master and in 1 other branch production

Fixed errbit:demo task

Showing 1 changed file with 12 additions and 12 deletions   Show diff stats
lib/tasks/errbit/demo.rake
1 namespace :errbit do 1 namespace :errbit do
2 - 2 +
3 desc "Add a demo app & errors to your database (for testing)" 3 desc "Add a demo app & errors to your database (for testing)"
4 task :demo => :environment do 4 task :demo => :environment do
5 5
6 app = Fabricate(:app, :name => "Demo App #{Time.now.strftime("%N")}") 6 app = Fabricate(:app, :name => "Demo App #{Time.now.strftime("%N")}")
7 - 7 +
8 # Report a number of errors for the application 8 # Report a number of errors for the application
9 app.problems.delete_all 9 app.problems.delete_all
10 - 10 +
11 errors = [{ 11 errors = [{
12 :error_class => "ArgumentError", 12 :error_class => "ArgumentError",
13 :message => "wrong number of arguments (3 for 0)" 13 :message => "wrong number of arguments (3 for 0)"
@@ -27,22 +27,22 @@ namespace :errbit do @@ -27,22 +27,22 @@ namespace :errbit do
27 :error_class => "SyntaxError", 27 :error_class => "SyntaxError",
28 :message => "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('" 28 :message => "unexpected tSTRING_BEG, expecting keyword_do or '{' or '('"
29 }] 29 }]
30 - 30 +
31 RANDOM_METHODS = ActiveSupport.methods.shuffle[1..8] 31 RANDOM_METHODS = ActiveSupport.methods.shuffle[1..8]
32 - 32 +
33 def random_backtrace 33 def random_backtrace
34 backtrace = [] 34 backtrace = []
35 99.times {|t| backtrace << { 35 99.times {|t| backtrace << {
36 'number' => t.hash % 1000, 36 'number' => t.hash % 1000,
37 'file' => "/path/to/file.rb", 37 'file' => "/path/to/file.rb",
38 - 'method' => RANDOM_METHODS.shuffle.first 38 + 'method' => RANDOM_METHODS.shuffle.first.to_s
39 }} 39 }}
40 backtrace 40 backtrace
41 end 41 end
42 - 42 +
43 errors.each do |error_template| 43 errors.each do |error_template|
44 rand(34).times do 44 rand(34).times do
45 - 45 +
46 error_report = error_template.reverse_merge({ 46 error_report = error_template.reverse_merge({
47 :error_class => "StandardError", 47 :error_class => "StandardError",
48 :message => "Oops. Something went wrong!", 48 :message => "Oops. Something went wrong!",
@@ -60,14 +60,14 @@ namespace :errbit do @@ -60,14 +60,14 @@ namespace :errbit do
60 :url => "http://www.example.com/users/jsmith" 60 :url => "http://www.example.com/users/jsmith"
61 } 61 }
62 }) 62 })
63 - 63 +
64 app.report_error!(error_report) 64 app.report_error!(error_report)
65 end 65 end
66 end 66 end
67 -  
68 - 67 +
  68 +
69 Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app))) 69 Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app)))
70 puts "=== Created demo app: '#{app.name}', with example errors." 70 puts "=== Created demo app: '#{app.name}', with example errors."
71 end 71 end
72 - 72 +
73 end 73 end