Sha256: 3eeb15a7c62207f7a23668623da75ad9d38ba19b93f5dd3fbd461c572a344be9

Contents?: true

Size: 1 KB

Versions: 10

Compression:

Stored size: 1 KB

Contents

class LeakDetector

  def initialize
    @did_dealloc = false
  end

  def did_dealloc(notification)
    @did_dealloc = true
  end

  def did_dealloc?
    @did_dealloc
  end

end

describe "Memory leaks" do
  tests MemoryLeakController

  def controller
    unless @controller
      root = UIViewController.new
      @controller = UINavigationController.alloc.initWithRootViewController(root)
    end

    @controller
  end

  it "should dealloc after being popped from UINavigationController" do
    detector = LeakDetector.new

    memory_leak = MemoryLeakController.new

    NSNotificationCenter.defaultCenter.addObserver(detector,
            selector: :'did_dealloc:',
            name: MemoryLeakController::DidDeallocNotification,
            object: memory_leak)

    self.controller.pushViewController(memory_leak, animated: false)
    memory_leak = nil

    wait 1 do
      self.controller.popViewControllerAnimated(false)

      wait 1 do
        detector.did_dealloc?.should == true
      end
    end
  end

end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
teacup-3.0.1 spec/ios/memory_leak_spec.rb
teacup-3.0.0 spec/ios/memory_leak_spec.rb
teacup-2.3.0 spec/ios/memory_leak_spec.rb
teacup-2.2.2 spec/ios/memory_leak_spec.rb
teacup-2.2.0 spec/ios/memory_leak_spec.rb
teacup-2.1.16 spec/ios/memory_leak_spec.rb
teacup-2.1.15 spec/ios/memory_leak_spec.rb
teacup-2.1.14 spec/ios/memory_leak_spec.rb
teacup-2.1.13 spec/ios/memory_leak_spec.rb
teacup-2.1.12 spec/ios/memory_leak_spec.rb