Sha256: 87b47a66a51e0c03cf5dec8b8043f442332e8c0d15f8b45dc8dcc8eb3390cb8a

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

require 'helper'

class TestMemoryLeak < Test::Unit::TestCase
  def setup
    super
    WebMock.stub_request(:get, 'http://impact.brighterplanet.com/emitters.json').to_return(:status => 500)
  end
    
  def test_attack_array
    # it's possible to attack the local copy...
    local_copy = ::BrighterPlanet.metadata.emitters
    assert local_copy.include?('AutomobileTrip')
    local_copy.clear
    assert local_copy.empty?
    
    # but not me!
    assert ::BrighterPlanet.metadata.emitters.include?('AutomobileTrip')
    ::BrighterPlanet.metadata.emitters.clear
    assert ::BrighterPlanet.metadata.emitters.include?('AutomobileTrip')
  end
  
  def test_attack_strings
    # it's possible to attack the local copy, obviously...
    local_copy = ::BrighterPlanet.metadata.emitters
    assert local_copy.include?('AutomobileTrip')
    local_copy.map { |name| name.upcase! }
    assert local_copy.include?('AUTOMOBILETRIP')
    
    # but not me!
    ::BrighterPlanet.metadata.emitters.map { |name| name.upcase! }
    assert ::BrighterPlanet.metadata.emitters.include?('AutomobileTrip')
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
brighter_planet_metadata-0.2.1 test/test_memory_leak.rb
brighter_planet_metadata-0.2.0 test/test_memory_leak.rb
brighter_planet_metadata-0.1.1 test/test_memory_leak.rb