Skip to content

Instantly share code, notes, and snippets.

@bartolsthoorn
Created June 2, 2013 22:57
Show Gist options
  • Save bartolsthoorn/5695248 to your computer and use it in GitHub Desktop.
Save bartolsthoorn/5695248 to your computer and use it in GitHub Desktop.
To enable RSpec when you are using a C extension in a gem, just add something like this to your spec helper. It will build the C code every time you run `rspec`
# Include C extension
puts 'Building C extension'
Dir.chdir('ext/hola') do
output = `ruby extconf.rb`
raise output unless $? == 0
output = `make`
raise output unless $? == 0
end
# Enables require 'hola/hola' in Ruby
$: << File.dirname(__FILE__) + '/../ext'
# Include Ruby code
require_relative '../lib/hola'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment