diff --git a/lib/hoptoad.rb b/lib/hoptoad.rb index a543639..a226adc 100644 --- a/lib/hoptoad.rb +++ b/lib/hoptoad.rb @@ -10,7 +10,7 @@ module Hoptoad def self.parse_xml(xml) parsed = ActiveSupport::XmlMini.backend.parse(xml)['notice'] - raise ApiVersionError(parsed['version']) unless parsed && parsed['version'].to_s == '2.0' + raise ApiVersionError.new(parsed['version']) unless parsed && parsed['version'].to_s == '2.0' rekeyed = rekey(parsed) rekeyed['fingerprint'] = Digest::MD5.hexdigest(rekeyed['error']['backtrace'].to_s) rekeyed diff --git a/spec/fixtures/hoptoad_test_notice_with_wrong_version.xml b/spec/fixtures/hoptoad_test_notice_with_wrong_version.xml new file mode 100644 index 0000000..5c317f4 --- /dev/null +++ b/spec/fixtures/hoptoad_test_notice_with_wrong_version.xml @@ -0,0 +1,147 @@ + + + APIKEY + + Hoptoad Notifier + 2.3.2 + http://hoptoadapp.com + + + HoptoadTestingException + HoptoadTestingException: Testing hoptoad via "rake hoptoad:test". If you can see this, it works. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + http://example.org/verify + application + verify + + verify + application + + + + text/html + + verify + application + + example.org + http + + 0 + #<StringIO:0x103d9dec0> + + + off + false + /verify + 994f235e3372684bc736dd11842b754d2ddcffc8c2958d33a29527c3217becd6655fa4653a318bc7c34131f9baf2acc0c424ed07e48e0e5e87c6cd34d711e985 + 11 + + + verify + application + + false + password + + + true + + 80 + GET + #<ApplicationController:0x103d2f560> + + false + true + / + + + + + #<StringIO:0x103d9dc90> + + + + + + + /path/to/sample/project + development + + diff --git a/spec/models/notice_spec.rb b/spec/models/notice_spec.rb index 4942520..62a9cf3 100644 --- a/spec/models/notice_spec.rb +++ b/spec/models/notice_spec.rb @@ -132,6 +132,11 @@ describe Notice do @xml = Rails.root.join('spec','fixtures','hoptoad_test_notice_without_request_section.xml').read lambda { Notice.from_xml(@xml) }.should_not raise_error end + + it "should raise ApiVersionError" do + @xml = Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_with_wrong_version.xml').read + expect { Notice.from_xml(@xml) }.to raise_error(Hoptoad::V2::ApiVersionError) + end end describe "key sanitization" do -- libgit2 0.21.2