<commit_before>require 'spec_helper'

describe Muster::Rack do
  let(:application) { lambda{|env| [200, {'Content-Type' => 'text/plain'}, '']} }
  let(:environment) { Rack::MockRequest.env_for('/?name=value&order=name') }
  let(:options)     { {} }
  let(:middleware)  { Muster::Rack.new(application, Muster::Strategies::Hash, options) }

  it 'parse query string with strategy' do
    middleware.call(environment)

    environment[Muster::Rack::QUERY].should == {'name' => 'value', 'order' => 'name'}
  end

  it 'accepts options for middlewhere' do
    options[:field] = :name

    middleware.call(environment)

    environment[Muster::Rack::QUERY].should == {'name' => 'value'}
  end

  it 'accepts a strategy instance' do
    strategy = Muster::Strategies::Hash.new(:field => :name)
    Muster::Rack.new(application, strategy).call(environment)

    environment[Muster::Rack::QUERY].should == {'name' => 'value'}
  end

  it 'merges multiple strategies into one result' do
    Muster::Rack.new(application, Muster::Strategies::Hash, :field => :name).call(environment)
    environment[Muster::Rack::QUERY].should == {'name' => 'value'}

    Muster::Rack.new(application, Muster::Strategies::Hash, :field => :order).call(environment)
    environment[Muster::Rack::QUERY].should == {'name' => 'value', 'order' => 'name'}
  end

  it 'supports indifferent access' do
    strategy = Muster::Strategies::Hash.new(:field => :name)
    Muster::Rack.new(application, strategy).call(environment)

    environment[Muster::Rack::QUERY]['name'].should eq 'value'
    environment[Muster::Rack::QUERY][:name].should eq 'value'
  end
end<commit_msg>Make sure indifferent survives the merge.<commit_after>require 'spec_helper'

describe Muster::Rack do
  let(:application) { lambda{|env| [200, {'Content-Type' => 'text/plain'}, '']} }
  let(:environment) { Rack::MockRequest.env_for('/?name=value&order=name') }
  let(:options)     { {} }
  let(:middleware)  { Muster::Rack.new(application, Muster::Strategies::Hash, options) }

  it 'parse query string with strategy' do
    middleware.call(environment)

    environment[Muster::Rack::QUERY].should == {'name' => 'value', 'order' => 'name'}
  end

  it 'accepts options for middlewhere' do
    options[:field] = :name

    middleware.call(environment)

    environment[Muster::Rack::QUERY].should == {'name' => 'value'}
  end

  it 'accepts a strategy instance' do
    strategy = Muster::Strategies::Hash.new(:field => :name)
    Muster::Rack.new(application, strategy).call(environment)

    environment[Muster::Rack::QUERY].should == {'name' => 'value'}
  end

  it 'merges multiple strategies into one result' do
    Muster::Rack.new(application, Muster::Strategies::Hash, :field => :name).call(environment)
    environment[Muster::Rack::QUERY].should == {'name' => 'value'}

    Muster::Rack.new(application, Muster::Strategies::Hash, :field => :order).call(environment)
    environment[Muster::Rack::QUERY].should == {'name' => 'value', 'order' => 'name'}
  end

  it 'supports indifferent access' do
    Muster::Rack.new(application, Muster::Strategies::Hash, :field => :name).call(environment)
    environment[Muster::Rack::QUERY].should == {'name' => 'value'}

    Muster::Rack.new(application, Muster::Strategies::Hash, :field => :order).call(environment)
    environment[Muster::Rack::QUERY].should == {'name' => 'value', 'order' => 'name'}

    environment[Muster::Rack::QUERY]['name'].should eq 'value'
    environment[Muster::Rack::QUERY][:name].should eq 'value'
  end
end
{'fraction_non_alphanumeric': 0.18359818388195231, 'fraction_numerical': 0.00170261066969353, 'mean_word_length': 5.261101243339254, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 31, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2610130', 'n_tokens_mistral': 1164, 'n_tokens_neox': 1131, 'n_words': 219}