Sha256: 111f663ea13c01c9627ae2fb44c21d2a5ed78ba49b21f092be0891bd3eecbd56

Contents?: true

Size: 1.15 KB

Versions: 16

Compression:

Stored size: 1.15 KB

Contents

require 'helper'

class TestMemoryLeak < Test::Unit::TestCase
  def setup
    super
    FakeWeb.clean_registry
    FakeWeb.allow_net_connect = false
    FakeWeb.register_uri :get, 'http://carbon.brighterplanet.com/emitters.json', :status => ["500", "Urg"], :body => nil
  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

16 entries across 16 versions & 1 rubygems

Version Path
brighter_planet_metadata-0.0.16 test/test_memory_leak.rb
brighter_planet_metadata-0.0.15 test/test_memory_leak.rb
brighter_planet_metadata-0.0.14 test/test_memory_leak.rb
brighter_planet_metadata-0.0.13 test/test_memory_leak.rb
brighter_planet_metadata-0.0.12 test/test_memory_leak.rb
brighter_planet_metadata-0.0.11 test/test_memory_leak.rb
brighter_planet_metadata-0.0.10 test/test_memory_leak.rb
brighter_planet_metadata-0.0.9 test/test_memory_leak.rb
brighter_planet_metadata-0.0.8 test/test_memory_leak.rb
brighter_planet_metadata-0.0.7 test/test_memory_leak.rb
brighter_planet_metadata-0.0.6 test/test_memory_leak.rb
brighter_planet_metadata-0.0.5 test/test_memory_leak.rb
brighter_planet_metadata-0.0.4 test/test_memory_leak.rb
brighter_planet_metadata-0.0.3 test/test_memory_leak.rb
brighter_planet_metadata-0.0.2 test/test_memory_leak.rb
brighter_planet_metadata-0.0.1 test/test_memory_leak.rb