<commit_before>require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "RackGeoip" do
  def app
    app = Rack::Builder.new {
      use Rack::Geoip, :path => '/geocode/lookup', :db => File.dirname(__FILE__)+'/../data/GeoLiteCity.dat'
      run BasicRackApp.new
    }
  end

  # This makes sure the middleware doesn't get in the way of normal requests
  it "says hello" do
    get '/'
    last_response.should be_ok
    last_response.body.should == 'Hello World'
  end
  
  # This makes sure that the middleware will return a 404 with some suggested usage
  # when the request is malformed
  it 'should return 404 when a geocode lookup request has malformed parameters' do
    get '/geocode/lookup'
    last_response.status.should == 404
    last_response.body.should == 'Example usage: http:///geocode/lookup?ip=8.8.8.8'
  end
  
  # This makes sure that the response is JSON parse-able
  it 'should return some json when a geocode lookup works' do
    get '/geocode/lookup?ip=8.8.8.8'
    last_response.should be_ok
    json = JSON.parse(last_response.body)
    json.class.should == Hash
  end
  
  # This tests the actual geocode lookup
  it 'should return the city Mountain View when the provided IP lookup is for a googleplex' do
    get '/geocode/lookup?ip=8.8.8.8'
    json = JSON.parse(last_response.body)
    json['city'].should == 'Mountain View'
  end
end
<commit_msg>Fixing failing test<commit_after>require File.expand_path(File.dirname(__FILE__) + '/spec_helper')

describe "RackGeoip" do
  def app
    app = Rack::Builder.new {
      use Rack::Geoip, :path => '/geocode/lookup', :db => File.dirname(__FILE__)+'/../data/GeoLiteCity.dat'
      run BasicRackApp.new
    }
  end

  # This makes sure the middleware doesn't get in the way of normal requests
  it "says hello" do
    get '/'
    last_response.should be_ok
    last_response.body.should == 'Hello World'
  end
  
  # This makes sure that the middleware will return a 404 with some suggested usage
  # when the request is malformed
  it 'should return 404 when a geocode lookup request has malformed parameters' do
    get '/geocode/lookup'
    last_response.status.should == 404
    last_response.body.should == 'Example usage: http://example.org/geocode/lookup?ip=8.8.8.8'
  end
  
  # This makes sure that the response is JSON parse-able
  it 'should return some json when a geocode lookup works' do
    get '/geocode/lookup?ip=8.8.8.8'
    last_response.should be_ok
    json = JSON.parse(last_response.body)
    json.class.should == Hash
  end
  
  # This tests the actual geocode lookup
  it 'should return the city Mountain View when the provided IP lookup is for a googleplex' do
    get '/geocode/lookup?ip=8.8.8.8'
    json = JSON.parse(last_response.body)
    json['city'].should == 'Mountain View'
  end
end

{'fraction_non_alphanumeric': 0.0998933522929257, 'fraction_numerical': 0.014930678990401706, 'mean_word_length': 3.276595744680851, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, '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': '5074848', 'n_tokens_mistral': 937, 'n_tokens_neox': 908, 'n_words': 292}