RubyMotion,当我 运行 默认测试时,得到一个 window [FAILED - 2.==(1) failed]

RubyMotion, getting has one window [FAILED - 2.==(1) failed] when I run default test

想知道是否有人遇到过这个问题,我只是 运行 使用 RubyMotion 的 rake 规范

生成的默认测试
describe "Application 'UIAlert'" do                                                                                            
 before do
   @app = UIApplication.sharedApplication
 end

 it "has one window" do
   @app.windows.size.should == 1
 end
end

失败并出现此错误:

Application 'UIAlert'
 - has one window [FAILED - 2.==(1) failed]

Bacon::Error: 2.==(1) failed
  spec.rb:769:in `satisfy:': Application 'UIAlert' - has one window
  spec.rb:783:in `method_missing:'
  spec.rb:316:in `block in run_spec_block'
  spec.rb:459:in `execute_block'
  spec.rb:316:in `run_spec_block'
  spec.rb:331:in `run'

我不确定我的应用程序怎么可能有多个 window,我错过了什么? :(

您在使用 iOS8 SDK 吗? iOS8 引入了 UITextEffectsWindow - 这是在应用程序 window 之外创建的,因此 @app.windows.size == 2 而不是 1。您可以通过 运行 您的应用程序和在REPL 查看 2 window 个对象。

(main)> UIApplication.sharedApplication.windows[0]
=> #<UIWindow:0x11280d700>
(main)> UIApplication.sharedApplication.windows[1]
=> #<UITextEffectsWindow:0x10b6127a0>

我建议将默认规范修改为测试应用程序 window 具有默认 rootViewController 的规范。