Iggy Iggy - 1 month ago 4x
Ruby Question

Testing travis-ci on ruby file returns rake aborted error

Inspired by Travis CI's guide for complete beginner, I wanted to test Travis on my preferred language: Ruby.

I created a similar repo like Travis' sample PHP repo. Here is my attempt to make my own Travis repo test.

Inside that repo, I have a

file containing:

language: ruby
- 2.2
- jruby

And a ruby file that I wish to run with invalid method in it:

def sum
return "1" + 1


However, when I push it, it returns this error:

$ rake
rake aborted!
No Rakefile found (looking for: rakefile, Rakefile, rakefile.rb, Rakefile.rb)

When I went back to read the travis doc for ruby, there is a line that says:

Travis CI runs rake by default to execute your tests. Please note that
you need to add rake to your Gemfile (adding it to the :test group
should be sufficient).

What does that mean? What else do I have to add to my repo and
to have a "successful" failing test? Ok, my last question sounds like a paradox, but essentially I want to know how I can test Travis CI with ruby by creating a failed test and creating a successful test like the said PHP test earlier?


Travis is basically just a computer like any other. What it says is that by default, it will run rake in that repo assuming that's where the tests are.

And indeed, if you were to clone your own repo and run rake yourself, you'd get the same output you're reporting.

So either you provide another command to run to Travis, or install a test that will run when rake is invoked (in your Rakefile, probably).

Also to note that your "Ruby file" doesn't really contain a test per se, just some code. Usually a test will assert things such as assert_equal(2, sum) or expect(sum).to eq(2) if you were to use Rspec. You can look up "ruby test frameworks" if you need more info about that.