test/unit/client_test.rb in raygun4ruby-2.4.1 vs test/unit/client_test.rb in raygun4ruby-2.5.0

- old
+ new

@@ -34,10 +34,18 @@ # Force NZ time zone for utcOffset tests ENV['TZ'] = 'UTC-13' end + def test_record_breadcrumb_does_not_crash_without_initialized_store + Raygun.record_breadcrumb( + message: 'aliens', + category: 'exceptions', + level: :info + ) + end + def test_api_key_required_message Raygun.configuration.api_key = nil $stderr.expects(:puts).with(Raygun::Client::NO_API_KEY_MESSAGE).once second_client = Raygun::Client.new @@ -137,10 +145,27 @@ expected_tags = configuration_tags + explicit_env_tags + rack_env_tag assert_equal expected_tags, @client.send(:build_payload_hash, test_exception, test_env)[:details][:tags] end + def test_tags_with_proc + configuration_tags = %w{bar} + explicit_env_tags = %w{one two three four} + rack_env_tag = %w{test} + + Raygun.setup do |config| + config.tags = ->(exception, env) { + [env[:foo]] + } + end + + test_env = { tags: explicit_env_tags, foo: 'bar' } + expected_tags = configuration_tags + explicit_env_tags + rack_env_tag + + assert_equal expected_tags, @client.send(:build_payload_hash, test_exception, test_env)[:details][:tags] + end + def test_hostname assert_equal Socket.gethostname, @client.send(:hostname) end def test_unicode @@ -654,25 +679,10 @@ assert_equal breadcrumbs.length, 1 assert breadcrumbs[0].is_a? Hash end - def test_raw_data_rewinds_and_restores_correctly - buffer = StringIO.new('123456789') - rack_env = { - REQUEST_METHOD: 'POST', - 'rack.input' => buffer - } - - buffer.seek(2) - - raw_data = @client.send(:raw_data, rack_env) - - assert_equal '123456789', raw_data - assert_equal buffer.pos, 2 - end - def test_raw_data_does_not_crash_on_buffer_without_pos buffer = StringIO.new('123456789') rack_env = { REQUEST_METHOD: 'POST', 'rack.input' => buffer @@ -680,10 +690,10 @@ buffer.instance_eval('undef :pos') raw_data = @client.send(:raw_data, rack_env) - assert_equal({}, raw_data) + assert_equal('123456789', raw_data) end private def test_exception