colinta / teacup

This project has been sunset in favor of MotionKit
github.com/motion-kit/motion-kit
Other
602 stars 85 forks source link

Testing in an app that uses Teacup fails #133

Closed holgersindbaek closed 11 years ago

holgersindbaek commented 11 years ago

I would like to test my controllers and views, but I'm having problems with Teacup.

If I do as it is written in the Rubymotion's guide - http://www.rubymotion.com/developer-center/articles/testing/ - and stop the app from launching fully:

return true if RUBYMOTION_ENV == 'test'

Then I get an error when it loads the specific view. It can't calculate the width and height (100%), since it's not inside another view controller.

What can I do about that? Anyone who's been in the same situation?

holgersindbaek commented 11 years ago

It was because of the 'height: "100%-20"' that I had in my stylesheet. Now I go this instead 'Device.screen.height-20'. Might not be an optimal solution, but it's working.

colinta commented 11 years ago

Glad you got it resolved! Another way to resolve this is to define your controller inside another controller by defining a controller method in your test, and instantiating your controller in there, e.g.

describe MyController
  tests MyController

  def controller
    ctlr = MyController.new
    nav = UINavigationController.alloc.initWithRootViewController(ctlr)
    return ctlr
  end

  # ...
end