Sha256: 195c74eb955197a6c6aae821b0711f56da6ae82b243145b142ca723ede0b6931

Contents?: true

Size: 850 Bytes

Versions: 5

Compression:

Stored size: 850 Bytes

Contents

RSpec.describe Evil::Client::Middleware::StringifyQuery do
  let(:stack) { described_class.new(app) }
  let(:app)   { double :app }

  def update!(env)
    @result = env
  end

  before  { allow(app).to receive(:call) { |env| update! env } }
  subject { stack.call env }

  context "with a non-empty query:" do
    let(:env) do
      { query: { foo: :FOO, bar: [:BAR], baz: { qux: :QUX }, qux: nil } }
    end

    it "stringifies the query" do
      subject
      expect(@result[:query_string]).to eq "foo=FOO&bar[]=BAR&baz[qux]=QUX&qux="
    end
  end

  context "with empty query:" do
    let(:env) { { query: {} } }

    it "does nothing" do
      subject
      expect(@result).to eq env
    end
  end

  context "without a query:" do
    let(:env) { {} }

    it "does nothing" do
      subject
      expect(@result).to eq env
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
evil-client-0.3.1 spec/unit/evil/client/middleware/stringify_query_spec.rb
evil-client-0.3.0 spec/unit/evil/client/middleware/stringify_query_spec.rb
evil-client-0.2.3 spec/unit/evil/client/middleware/stringify_query_spec.rb
evil-client-0.2.2 spec/unit/evil/client/middleware/stringify_query_spec.rb
evil-client-0.2.1 spec/unit/evil/client/middleware/stringify_query_spec.rb