<commit_before>require 'spec_helper'
require 'resolv'

describe Celluloid::Http::Proxy::Request do
  it 'can be initialized from reel request' do
    reel_request = FakeRequest.to_localhost

    request = Celluloid::Http::Proxy::Request.build_from_request reel_request

    request.scheme.should eq "http"
    request.host.should   eq "localhost"
    request.path.should   eq "/proxy/movies.json"
    request.query.should  eq "movie_source_id=1"
    request.port.should   eq 8080
    request.query_params.should eq({ "movie_source_id" => "1"})
    request.method.should eq :get
    request.body.should   eq ""
  end

  it 'can be initialized from url' do
    request = Factories.request_to_localhost("proxy/movies.json?movie_source_id=1")

    request.scheme.should eq"http"
    request.path.should eq"/proxy/movies.json"
    request.host.should eq "localhost"
    request.query.should eq "movie_source_id=1"
    request.port.should eq 8080
    request.query_params.should eq({ "movie_source_id" => "1"})
    request.method.should eq :get
    request.body.should eq nil
  end

  def test_remove_param
    request = Factories.request_to_localhost("movies.json?movie_source_id=1&test=2")

    request.remove_param("movie_source_id")

    request.query.should eq "test=2"
  end

  it 'can build url' do
    request = Factories.request_to_localhost("movies.json?movie_source_id=1&test=2")
    request.url.should eq "http://localhost:8080/movies.json?movie_source_id=1&test=2"
  end
end<commit_msg>Typo in test name fixed<commit_after>require 'spec_helper'
require 'resolv'

describe Celluloid::Http::Proxy::Request do
  it 'can be initialized from reel request' do
    reel_request = FakeRequest.to_localhost

    request = Celluloid::Http::Proxy::Request.build_from_request reel_request

    request.scheme.should eq "http"
    request.host.should   eq "localhost"
    request.path.should   eq "/proxy/movies.json"
    request.query.should  eq "movie_source_id=1"
    request.port.should   eq 8080
    request.query_params.should eq({ "movie_source_id" => "1"})
    request.method.should eq :get
    request.body.should   eq ""
  end

  it 'can be initialized from url' do
    request = Factories.request_to_localhost("proxy/movies.json?movie_source_id=1")

    request.scheme.should eq"http"
    request.path.should eq"/proxy/movies.json"
    request.host.should eq "localhost"
    request.query.should eq "movie_source_id=1"
    request.port.should eq 8080
    request.query_params.should eq({ "movie_source_id" => "1"})
    request.method.should eq :get
    request.body.should eq nil
  end

  it 'can remove query param' do
    request = Factories.request_to_localhost("movies.json?movie_source_id=1&test=2")

    request.remove_param("movie_source_id")

    request.query.should eq "test=2"
  end

  it 'can build url' do
    request = Factories.request_to_localhost("movies.json?movie_source_id=1&test=2")
    request.url.should eq "http://localhost:8080/movies.json?movie_source_id=1&test=2"
  end
end
{'fraction_non_alphanumeric': 0.11048252911813644, 'fraction_numerical': 0.015973377703826955, 'mean_word_length': 4.0691399662731875, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '920710', 'n_tokens_mistral': 1052, 'n_tokens_neox': 983, 'n_words': 205}