Sha256: bd652c57477e1edc501450e6b1c9222e78dba9a372c41c40dd9e6da91f87a252
Contents?: true
Size: 1.56 KB
Versions: 1
Compression:
Stored size: 1.56 KB
Contents
require 'spec_helper' require 'captivus/payload' describe Captivus::Payload do describe ".new" do context "when argument doesn't behave like an exception" do it "raises an argument error" do [ double('exception'), double('exception', :class => double('class')), double('exception', :class => double('class', :name => 'X')), double('exception', :class => double('class'), :message => 'x') ].each do |exception| expect { Captivus::Payload.new exception }.to raise_error(ArgumentError, "Unexpected exception: #{exception.inspect}") end end end end describe "as_json" do it "returns a hash of event and backtrace info" do Timecop.freeze Time.utc(2012, 8, 23, 16, 34, 19) exception = double 'exception', :class => double('class', :name => 'ExceptionType'), :message => 'The exception message.', :backtrace => ['/Users/x.rb:1', '/Users/x.rb:2', '/Users/x.rb:3'] Captivus::Payload.new(exception).as_json.tap do |hash| expect(hash.keys).to match_array ['event', 'backtrace'] hash['event'].tap do |event| expect(event.keys).to match_array ['type', 'message', 'timestamp'] expect(event['type']).to eq 'ExceptionType' expect(event['message']).to eq 'The exception message.' expect(event['timestamp']).to eq '2012-08-23 16:34:19 UTC' end hash['backtrace'].should == Captivus::Backtrace.new(exception).as_json end Timecop.return end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
captivus-0.0.3 | spec/captivus/payload_spec.rb |