15 Jan 2013, 14:24
Sleepingstu_pragsmall

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
Watermark copy 2_test_pragsmall

Clay Allsopp (8 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
Sleepingstu_pragsmall

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 @flick(@window, from: :left)@) and it passes again.

This might help or not but thought it was worth mentioning.

27 Nov 2013, 03:01
Generic-user-small

Paul Golds (1 post)

I’ve been working through this tutorial today and have hit the same problem despite using a fully up-to-date RubyMotion installation.

I’ve tried multiple taps, adding a flick in there, but just don’t seem to be able to get anything working.

Is this still an ongoing issue or am I doing something wrong?

16 Feb 2014, 21:06
Mangatar_db_pragsmall

David Bourguignon (2 posts)

I still have the same problem here with RM 2.22 and xcode 5.0.2

Any update on this ?

18 Feb 2014, 22:14
Melast_pragsmall

Alex Lopez (1 post)

Looks like the button is not created at the moment tap() event is fired in the tests. Adding sleep(1) is a temporary workaround.

RM 2.22, xcode 5.0.2

27 Feb 2014, 17:48
Generic-user-small

matt weppler (1 post)

I tried just running the app in the simulator using rake. It looks like the ‘Tap Me’ button cannot be clicked, since the top bar is covering it. I added the following to the button_controller.rb

button.frame = CGRect.new([10, 70], button.frame.size)

and this solved the issue for me

RM 2.22, Xcode 5.0.2

  You must be logged in to comment