spec/rollbar_spec.rb in rollbar-1.5.3 vs spec/rollbar_spec.rb in rollbar-2.0.0

- old
+ new

@@ -2,10 +2,13 @@ require 'logger' require 'socket' require 'spec_helper' require 'girl_friday' +require 'redis' +require 'active_support/core_ext/object' +require 'active_support/json/encoding' begin require 'sucker_punch' require 'sucker_punch/testing/inline' rescue LoadError @@ -470,10 +473,27 @@ payload = notifier.send(:build_payload, 'info', 'message', nil, nil) payload['data'][:server][:root].should == '/path/to/root' payload['data'][:server][:branch].should == 'master' end + + context "with Redis instance in payload and ActiveSupport is enabled" do + let(:redis) { ::Redis.new } + let(:payload) do + { + :key => { + :value => redis + } + } + end + it 'dumps to JSON correctly' do + redis.set('foo', 'bar') + json = notifier.send(:dump_payload, payload) + + expect(json).to be_kind_of(String) + end + end end context 'build_payload_body' do let(:exception) do begin @@ -798,14 +818,17 @@ expect(Rollbar.last_report[:level]).to be_eql('error') end end - it "should work with an IO object as rack.errors" do - logger_mock.should_receive(:info).with('[Rollbar] Success') + # Skip jruby 1.9+ (https://github.com/jruby/jruby/issues/2373) + if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && (not RUBY_VERSION =~ /^1\.9/) + it "should work with an IO object as rack.errors" do + logger_mock.should_receive(:info).with('[Rollbar] Success') - Rollbar.error(exception, :env => { :"rack.errors" => IO.new(2, File::WRONLY) }) + Rollbar.error(exception, :env => { :"rack.errors" => IO.new(2, File::WRONLY) }) + end end it 'should ignore ignored persons' do person_data = { :id => 1, @@ -1197,11 +1220,11 @@ # after a deploy with an gem upgrade. context 'with a payload generated as String' do let(:async_handler) do proc do |payload| # simulate previous gem version - string_payload = MultiJson.dump(payload) + string_payload = Rollbar::JSON.dump(payload) Rollbar.process_payload(string_payload) end end @@ -1359,9 +1382,14 @@ reset_configuration end end context 'enforce_valid_utf8' do + # TODO(jon): all these tests should be removed since they are in + # in spec/rollbar/encoding/encoder.rb. + # + # This should just check that in payload with simple values and + # nested values are each one passed through Rollbar::Encoding.encode context 'with utf8 string and ruby > 1.8' do next unless String.instance_methods.include?(:force_encoding) let(:payload) { { :foo => 'Изменение' } }