Sha256: 2a93ba621abeab23ec10881630ee160fc91961e9ec2ba9161d6d2844b015138f

Contents?: true

Size: 1.14 KB

Versions: 10

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'
require 'coach/request_serializer'

describe Coach::RequestSerializer do
  describe '.apply_header_rule' do
    before { described_class.clear_header_rules! }

    let(:header) { 'http_abc' }
    let(:rule) { nil }

    context "with header that has a rule that" do
      before { described_class.sanitize_header(header, &rule) }

      context "does not specify block" do
        it "replaces blacklisted header with default text" do
          sanitized = Coach::RequestSerializer.apply_header_rule(header, 'value')
          expect(sanitized).not_to eq('value')
        end
      end

      context "specifies custom block" do
        let(:rule) { ->(value) { "#{value}#{value}" } }

        it "uses block to compute new filtered value" do
          sanitized = Coach::RequestSerializer.apply_header_rule(header, 'value')
          expect(sanitized).to eq('valuevalue')
        end
      end
    end

    context "with header that has no blacklist rule" do
      it "does not modify value" do
        sanitized = Coach::RequestSerializer.apply_header_rule(header, 'value')
        expect(sanitized).to eq('value')
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
coach-0.4.1 spec/lib/coach/request_serializer_spec.rb
coach-0.4.0 spec/lib/coach/request_serializer_spec.rb
coach-0.3.0 spec/lib/coach/request_serializer_spec.rb
coach-0.2.3 spec/lib/coach/request_serializer_spec.rb
coach-0.2.2 spec/lib/coach/request_serializer_spec.rb
coach-0.2.1 spec/lib/coach/request_serializer_spec.rb
coach-0.2.0 spec/lib/coach/request_serializer_spec.rb
coach-0.0.2 spec/lib/coach/request_serializer_spec.rb
coach-0.0.1 spec/lib/coach/request_serializer_spec.rb
coach-0.0.0 spec/lib/coach/request_serializer_spec.rb