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