我正在阅读一个教程,当代码与教程中的代码相同时,它会给我一个失败的测试。我正在测试一个按钮被轻敲,当它被执行时@was_tapped应该等于" true"并且它将会出现在" nil"
我收到此错误:
[Tests] $rake spec
================================================================================
A new version of RubyMotion is available. Run `sudo motion update' to upgrade.
================================================================================
Build ./build/iPhoneSimulator-7.0-Development
Compile ./spec/main_spec.rb
Link ./build/iPhoneSimulator-7.0-Development/Tests_spec.app/Tests
Create ./build/iPhoneSimulator-7.0-Development/Tests_spec.app/PkgInfo
Create ./build/iPhoneSimulator-7.0-Development/Tests_spec.app/Info.plist
Create ./build/iPhoneSimulator-7.0-Development/Tests_spec.dSYM
Simulate ./build/iPhoneSimulator-7.0-Development/Tests_spec.app
2013-12-30 19:43:37.188 Tests[20200:80b] Cannot find executable for CFBundle 0x900b410 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/GeoServices.axbundle> (not loaded)
2013-12-30 19:43:37.206 Tests[20200:80b] Cannot find executable for CFBundle 0x8ebce90 </Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.0.sdk/System/Library/AccessibilityBundles/CertUIFramework.axbundle> (not loaded)
Application 'Tests'
- has one window
delegate
- changes variable when button is tapped
2 specifications (2 requirements), 0 failures, 0 errors
这是我的按钮控制器:
class ButtonController < UIViewController
def viewDidLoad
super
@button = UIButton.buttonWithType(UIButtonTypeRoundedRect)
@button.setTitle("Test me title!", forState:UIControlStateNormal)
@button.accessibilityLabel = "Test me!"
@button.sizeToFit
self.view.addSubview(@button)
@button.addTarget(self, action:'tapped', forControlEvents:UIControlEventTouchUpInside)
end
def tapped
p "I'm tapped!"
@was_tapped = true
end
end
这是我的main_spec.rb:
describe "Application 'Tests'" do
before do
@app = UIApplication.sharedApplication
end
it "has one window" do
@app.windows.size.should == 1
end
describe "delegate" do
tests ButtonController
it "changes variable when button is tapped" do
tap 'Test me!'
controller.instance_variable_get("@was_tapped").should == true
end
end
end