Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I run a Ruby gem's specs?

I have forked a ruby gem and made some updates. I need to run the gem tests and add my new tests and ensure all tests are succeeding.

The forked ruby gem is using rspec tests. How can I run these test?

like image 537
Mahmoud Khaled Avatar asked Nov 07 '11 23:11

Mahmoud Khaled


People also ask

How do you test a ruby gem?

The rub test includes rubbing your ruby across a smooth (but hard) surface, like glass, and seeing if the gem leaves any color behind. Glass only has a hardness of 5 on the Mohs scale, so it's much softer than actual rubies. Real rubies and some gems shouldn't leave any color behind, but cheap fakes or imitations can.

How do I check my gem version?

You can check your Ruby version by running ruby --version , and you can check your RubyGems version by running gem --version . If you need to upgrade Ruby, use your ruby version manager's instructions. If you need to upgrade RubyGems, run gem update --system .

What is a Gemspec file?

Developer file that specifies the attributes of a RubyGems . GEM package; saves information such as the author, a description, an example usage, and the usage license; saved in a simple plain text format.


1 Answers

Usually rake is sufficient to run all the tests, regardless of whether they're RSpec, Cucumber, etc. If you want to invoke RSpec directly try running rspec spec instead, or if the gem is using an unconventionally named test directory, just use rspec <directory_name>.

Note: Most new gems these days use Bundler to manage dependencies, so if you don't have the appropriate dependencies and there's a Gemfile in the root, then run "bundle install" first to get them. Then run with bundle exec ... (e.g., bundle exec rspec spec).

like image 95
John Feminella Avatar answered Nov 05 '22 19:11

John Feminella