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

class GoogleMapsTest < Test::Unit::TestCase

  CONFIG_FILE = '/not/existing.yml'

  def setup
    # force loading of config at every test
    GoogleMaps.erase_config
    GoogleMaps.stubs(:config_file).returns(CONFIG_FILE)
  end

  should 'retrieve key from "web2.0" config file' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { 'key' => 'MYKEY' }})
    assert_equal 'MYKEY', GoogleMaps.key
  end

  should 'enable when key is defined' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { 'key' => 'MYKEY' }})
    assert GoogleMaps.enabled?
  end

  should 'disable if config file not present' do
    File.expects(:exists?).with(CONFIG_FILE).returns(false)
    assert !GoogleMaps.enabled?
  end

  should 'disable if key not defined' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({})
    assert !GoogleMaps.enabled?
  end
  
  should 'not crash if config not informed' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({})
    assert_nil GoogleMaps.key
  end

  should 'not crash if config file not found' do
    GoogleMaps.expects(:config_file).returns('/not/present.yml')
    assert_nil GoogleMaps.key
  end

  should 'point correctly to google maps' do
    GoogleMaps.expects(:key).returns('MY_FUCKING_KEY')
    assert_equal 'http://maps.google.com/maps?file=api&amp;v=2&amp;key=MY_FUCKING_KEY', GoogleMaps.api_url
  end

  should 'provide initial_zoom setting' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { 'initial_zoom' => 2}})
    assert_equal 2, GoogleMaps.initial_zoom
  end

  should 'use 4 as default initial_zoom' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { }})
    assert_equal 4, GoogleMaps.initial_zoom
  end

end<commit_msg>ActionItem860: fix error on unit test<commit_after>require File.dirname(__FILE__) + '/../test_helper'

class GoogleMapsTest < Test::Unit::TestCase

  CONFIG_FILE = '/not/existing.yml'

  def setup
    # force loading of config at every test
    GoogleMaps.erase_config
    GoogleMaps.stubs(:config_file).returns(CONFIG_FILE)
  end

  should 'retrieve key from "web2.0" config file' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { 'key' => 'MYKEY' }})
    assert_equal 'MYKEY', GoogleMaps.key
  end

  should 'enable when key is defined' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { 'key' => 'MYKEY' }})
    assert GoogleMaps.enabled?
  end

  should 'disable if config file not present' do
    File.expects(:exists?).with(CONFIG_FILE).returns(false)
    assert !GoogleMaps.enabled?
  end

  should 'disable if key not defined' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({})
    assert !GoogleMaps.enabled?
  end
  
  should 'not crash if config not informed' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({})
    assert_equal '', GoogleMaps.key
  end

  should 'not crash if config file not found' do
    GoogleMaps.expects(:config_file).returns('/not/present.yml')
    assert_equal '', GoogleMaps.key
  end

  should 'point correctly to google maps' do
    GoogleMaps.expects(:key).returns('MY_FUCKING_KEY')
    assert_equal 'http://maps.google.com/maps?file=api&amp;v=2&amp;key=MY_FUCKING_KEY', GoogleMaps.api_url
  end

  should 'provide initial_zoom setting' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { 'initial_zoom' => 2}})
    assert_equal 2, GoogleMaps.initial_zoom
  end

  should 'use 4 as default initial_zoom' do
    File.expects(:exists?).with(CONFIG_FILE).returns(true)
    YAML.expects(:load_file).with(CONFIG_FILE).returns({'googlemaps' => { }})
    assert_equal 4, GoogleMaps.initial_zoom
  end

end
{'fraction_non_alphanumeric': 0.1370822041553749, 'fraction_numerical': 0.0038392050587172538, 'mean_word_length': 4.57808564231738, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '2860302', 'n_tokens_mistral': 1525, 'n_tokens_neox': 1460, 'n_words': 282}