dish icon indicating copy to clipboard operation
dish copied to clipboard

Question for RubyMotion users: How to test in RubyMotion?

Open lassebunk opened this issue 12 years ago • 7 comments

Right now we don't have any tests for the project in RubyMotion. Anybody have ideas on how to automatically test the project with RubyMotion? Thanks.

lassebunk avatar Mar 01 '14 14:03 lassebunk

I'm not super familiar with RubyMotion, but I know it uses a miniature version of RSpec called Bacon to run tests. This is the RubyMotion documentation on testing.

Beyond that, I think there are a couple different ways you can go. First, you could just write a little RubyMotion app hit the endpoints that we want to test and then just write Bacon tests to test that the views render properly or something. I think this is kind of cumbersum though, because then you have two completely different test pools to maintain.

It looks like you can also set up your rakefile like:

$:.unshift("/Library/RubyMotion/lib")
require 'motion/project'

$:.unshift("./lib/")
require './lib/dish'

Motion::Project::App.setup do |app|
end

task :spec do
  App.config.spec_mode = true
  spec_files = App.config.spec_files
  App.config.instance_variable_set("@spec_files", spec_files)
  Rake::Task["simulator"].invoke
end

and then run rake spec. I have no idea how accurate this is though.

tommyschaefer avatar Mar 01 '14 14:03 tommyschaefer

Yeah. Thanks. Hmm, I'd like an automatic/continous service like Travis-CI for RubyMotion. Know if something like this exists?

lassebunk avatar Mar 01 '14 14:03 lassebunk

We would also have to switch over to RSpec, which I think would be a good move. It's up to you though. If it is something that you think is worthwhile, we should probably do it sooner rather than later... our test pool is only going to grow! I do a ton of work with RSpec, so I could probably move over all the tests pretty quickly.

I agree using Travis CI is a good idea. Here is there blog post discussing testing of RubyMotion apps/gems.

tommyschaefer avatar Mar 01 '14 14:03 tommyschaefer

That's great. RSpec is fine by me. Do you have the time for helping with this?

lassebunk avatar Mar 01 '14 14:03 lassebunk

Definitely! I'm pretty swamped right now but I'll work in it over the next few says and then open a PR

tommyschaefer avatar Mar 01 '14 14:03 tommyschaefer

Great. Thanks man :+1:

lassebunk avatar Mar 01 '14 14:03 lassebunk

@tommyschaefer did you make any progress on converting the tests to RSpec? I'd like to be able to test with Travis so we can make changes ensured it will work. :)

lassebunk avatar Oct 22 '14 18:10 lassebunk