![]() | Section 6.2 Testing App UI and Controllers problem |
|
15 Jan 2013, 14:24
Stuart Chinery (3 posts) |
I’ve stumbled across a problem while completing the exercise in section 6.2 but I’m not sure if it is in fact a problem with Rubymotion. The book says to put the following code in my spec file:
describe "ButtonController" do
tests ButtonController
it "changes color after tapping" do
tap("Tap Me")
controller.instance_variable_get("@tapped").should == true
end
end
But if I do then my test fails with the following Bacon::Error: false.==(true) failed. After doing some debugging (basically putting p “I’ve been tapped” in the tapped method) I can see that my method isn’t being hit. However if I change the code to:
describe "ButtonController" do
tests ButtonController
it "changes color after tapping" do
tap("Tap Me")
tap("Tap Me")
controller.instance_variable_get("@tapped").should == true
end
end
Then the test passes and I get one puts statement in my test output. This is also the case if I change the first tap to another interaction like flick. This is also the case for me when using the example code at http://pragprog.com/titles/carubym/source_code. It is almost like the first interaction is getting the focus of the app, so I’m guessing this might be a problem within Rubymotion itself? I’m running OSX 10.8.2, Rubymotion 1.30 and Ruby 1.9.3p362 (via RVM). I tried the tests in both iOS 5.1 and 6 too. |
|
16 Jan 2013, 23:00
Clay Allsopp (7 posts) |
Very weird, when I wrote this (September-ish?) it worked; now I can’t even get your 2x `tap` solution to work =\ I submitted a bug report with the RM folks, will keep you update on it… |
|
17 Jan 2013, 09:28
Stuart Chinery (3 posts) |
Many thanks for update. Just to add I also discovered something else that I found kind of weird regarding this issue. If I keep the test as it is in the book (with the single tap) and run the test with the iPhoneSimulator completely closed then it passes correctly. If I then run the test again with the iPhoneSimulator already open then it fails. Put the extra tap in (although I have since changed this to This might help or not but thought it was worth mentioning. |
| You must be logged in to comment |

