Sha256: 1c7009c95361a24a36fa20fcc7ddd2fb14bb8564a3e52c6eceaca03af566dd83
Contents?: true
Size: 1.73 KB
Versions: 11
Compression:
Stored size: 1.73 KB
Contents
require 'spec_helper' require 'rack/mock' require 'rollbar/request_data_extractor' class ExtractorDummy include Rollbar::RequestDataExtractor end describe Rollbar::RequestDataExtractor do subject { ExtractorDummy.new } let(:env) do Rack::MockRequest.env_for('/', 'HTTP_HOST' => 'localhost:81', 'HTTP_X_FORWARDED_HOST' => 'example.org:9292') end describe '#extract_request_data_from_rack' do let(:scrubber) { double } it 'returns a Hash object' do scrubber_config = { :scrub_fields => kind_of(Array), :scrub_user => Rollbar.configuration.scrub_user, :scrub_password => Rollbar.configuration.scrub_password, :randomize_scrub_length => Rollbar.configuration.randomize_scrub_length } expect(Rollbar::Scrubbers::URL).to receive(:new).with(scrubber_config).and_return(scrubber) expect(scrubber).to receive(:call).with(kind_of(String)) result = subject.extract_request_data_from_rack(env) expect(result).to be_kind_of(Hash) end end describe '#rollbar_scrubbed_value' do context 'with random scrub length' do before do allow(Rollbar.configuration).to receive(:randomize_scrub_length).and_return(true) end let(:value) { 'herecomesaverylongvalue' } it 'randomizes the scrubbed string' do expect(subject.rollbar_scrubbed(value)).to match(/\*{3,8}/) end end context 'with no-random scrub length' do before do allow(Rollbar.configuration).to receive(:randomize_scrub_length).and_return(false) end let(:value) { 'herecomesaverylongvalue' } it 'randomizes the scrubbed string' do expect(subject.rollbar_scrubbed(value)).to match(/\*{#{value.length}}/) end end end end
Version data entries
11 entries across 11 versions & 1 rubygems