From dc29b9db61c7342c01f0cefcee6f7a97295c4654 Mon Sep 17 00:00:00 2001 From: Cyril Mougel Date: Tue, 7 May 2013 19:23:23 +0200 Subject: [PATCH] Add test to generate xml from Airbrake gem and test it directly --- Gemfile | 1 + Gemfile.lock | 5 +++++ spec/models/error_report_spec.rb | 31 +++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 0 deletions(-) diff --git a/Gemfile b/Gemfile index 85064de..5b5c392 100644 --- a/Gemfile +++ b/Gemfile @@ -78,6 +78,7 @@ gem 'yajl-ruby', :require => "yajl" group :development, :test do gem 'rspec-rails', '~> 2.6' gem 'webmock', :require => false + gem 'airbrake', :require => false unless ENV["CI"] gem 'ruby-debug', :platform => :mri_18 gem 'debugger', :platform => :mri_19 diff --git a/Gemfile.lock b/Gemfile.lock index 891b698..40995c3 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -47,6 +47,10 @@ GEM i18n (= 0.6.1) multi_json (~> 1.0) addressable (2.3.2) + airbrake (3.1.12) + activesupport + builder + json arel (3.0.2) bcrypt-ruby (3.0.1) better_errors (0.7.0) @@ -363,6 +367,7 @@ PLATFORMS DEPENDENCIES SystemTimer actionmailer_inline_css (~> 1.3.0) + airbrake better_errors binding_of_caller bitbucket_rest_api diff --git a/spec/models/error_report_spec.rb b/spec/models/error_report_spec.rb index ebb7527..e0f47c4 100644 --- a/spec/models/error_report_spec.rb +++ b/spec/models/error_report_spec.rb @@ -1,4 +1,20 @@ require 'spec_helper' +require 'airbrake/version' +require 'airbrake/backtrace' +require 'airbrake/notice' + +# MonkeyPatch to instanciate a Airbrake::Notice without configure +# Airbrake +# +module Airbrake + API_VERSION = '2.4' + + class Notice + def framework + 'rails' + end + end +end describe ErrorReport do context "with notice without line of backtrace" do @@ -38,6 +54,21 @@ describe ErrorReport do app.reload.problems.count }.by(1) end + context "with notice generate by Airbrake gem" do + let(:xml) { Airbrake::Notice.new( + :exception => Exception.new, + :api_key => 'API_KEY', + :project_root => Rails.root + ).to_xml } + it 'save a notice' do + expect { + error_report.generate_notice! + }.to change { + app.reload.problems.count + }.by(1) + end + end + describe "notice create" do before { error_report.generate_notice! } subject { error_report.notice } -- libgit2 0.21.2