From 03d328d1acba86a202c8d22a69db362e61c54fab Mon Sep 17 00:00:00 2001 From: Artur Moczulski Date: Mon, 30 Jul 2018 00:02:03 +0000 Subject: [PATCH] #139: don't test scrubbing on ruby 1.8 --- spec/rollbar/scrubbers/url_spec.rb | 105 +++++++++++++++-------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/spec/rollbar/scrubbers/url_spec.rb b/spec/rollbar/scrubbers/url_spec.rb index 8c93c300..f5d8bfb4 100644 --- a/spec/rollbar/scrubbers/url_spec.rb +++ b/spec/rollbar/scrubbers/url_spec.rb @@ -143,66 +143,69 @@ let(:whitelist) { true } - context 'cannot scrub URLs' do - next if Rollbar::LanguageSupport.can_scrub_url? - - let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' } - - it 'returns the URL without any change' do - expect(subject.call(options)).to be_eql(url) - end - end + context 'with ruby different from 1.8' do + next unless Rollbar::LanguageSupport.can_scrub_url? - context 'scrubbing user and password' do - let(:options) do - { - :url => url, - :scrub_fields => [], - :scrub_password => true, - :scrub_user => true, - :whitelist => whitelist - } - end - - let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' } - - it 'returns the URL without any change' do - expected_url = /http:\/\/\*{3,8}:\*{3,8}@foo.com\/some-interesting\-path#fragment/ - - expect(subject.call(options)).to match(expected_url) + context 'cannot scrub URLs' do + + let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' } + + it 'returns the URL without any change' do + expect(subject.call(options)).to be_eql(url) + end end - end - - context 'with params to be filtered' do - let(:options) do - { - :url => url, - :scrub_fields => [:dont_scrub], - :scrub_password => false, - :scrub_user => false, - :whitelist => whitelist - } + + context 'scrubbing user and password' do + + let(:options) do + { + :url => url, + :scrub_fields => [], + :scrub_password => true, + :scrub_user => true, + :whitelist => whitelist + } + end + + let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' } + + it 'returns the URL without any change' do + expected_url = /http:\/\/\*{3,8}:\*{3,8}@foo.com\/some-interesting\-path#fragment/ + + expect(subject.call(options)).to match(expected_url) + end end - let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password=mypassword&secret=somevalue&dont_scrub=foo#fragment' } - - it 'returns the URL with some params filtered' do - expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=\*{3,8}&password=\*{3,8}&secret=\*{3,8}&dont_scrub=foo#fragment/ - - expect(subject.call(options)).to match(expected_url) - end - - context 'having array params' do - let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password[]=mypassword&password[]=otherpassword&secret=somevalue&dont_scrub=foo#fragment' } - + context 'with params to be filtered' do + let(:options) do + { + :url => url, + :scrub_fields => [:dont_scrub], + :scrub_password => false, + :scrub_user => false, + :whitelist => whitelist + } + end + + let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password=mypassword&secret=somevalue&dont_scrub=foo#fragment' } + it 'returns the URL with some params filtered' do - expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=\*{3,8}&password\[\]=\*{3,8}&password\[\]=\*{3,8}&secret=\*{3,8}&dont_scrub=foo#fragment/ - + expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=\*{3,8}&password=\*{3,8}&secret=\*{3,8}&dont_scrub=foo#fragment/ + expect(subject.call(options)).to match(expected_url) end + + context 'having array params' do + let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password[]=mypassword&password[]=otherpassword&secret=somevalue&dont_scrub=foo#fragment' } + + it 'returns the URL with some params filtered' do + expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=\*{3,8}&password\[\]=\*{3,8}&password\[\]=\*{3,8}&secret=\*{3,8}&dont_scrub=foo#fragment/ + + expect(subject.call(options)).to match(expected_url) + end + end end end - end end end