Get Integrity to play well with Rails 3 and Bundler 1.0

The latest “stable” version of Integrity (v22) doesn’t play well with Rails 3 (or any other application using bundler 1.0). Basically the Integrity’s Gemfile is used in place of the application’s Gemfile when running the tests.

With a Rails 3 application you are likely to get:

no such file to load -- rails/all

Integrity fails to run with Rails 3 and Bundler 1.0

A patched version of integrity v22 for bundler 1.0 is available on http://github.com/pcreux/integrity/tree/v22-bundler-1.0.0.rc.

You also need to force your Rails application to use its Gemfile. To do so, update the file /config/boot.rb with the following:

require 'rubygems'
# Set up gems listed in the Gemfile.
GEMFILE_PATH = File.expand_path('../../Gemfile', __FILE__)
if File.exist?(GEMFILE_PATH)
  # Force the rails 3 application to use its Gemfile
  ENV['BUNDLE_GEMFILE'] = GEMFILE_PATH
  require 'bundler'
  Bundler.setup
end

That should make the trick!
Patched Integrity and custom boot.rb makes integrity working with Rails 3

Post to Twitter

. Bookmark the permalink. Both comments and trackbacks are currently closed.
  • http://mwilden.blogspot.com/ Mark Wilden

    Thanks for the tip! I think the line needs to be


    GEMFILE_PATH = File.expand_path('../../Gemfile', File.dirname(__FILE__))

  • Amit Kulkarni

    Hi,
    I tried your solution but getting the same error.
    My app’s config/boot file is as follows:
    require ‘rubygems’

    # Set up gems listed in the Gemfile.
    #ENV['BUNDLE_GEMFILE'] ||= File.expand_path(‘../../Gemfile’, __FILE__)

    #require ‘bundler/setup’ if File.exists?(ENV['BUNDLE_GEMFILE'])

    # Set up gems listed in the Gemfile.
    GEMFILE_PATH = File.expand_path(‘../../Gemfile’, __FILE__)
    if File.exist?(GEMFILE_PATH)
    # Force the rails 3 application to use its Gemfile
    ENV['BUNDLE_GEMFILE'] = GEMFILE_PATH
    require ‘bundler’
    Bundler.setup
    end

    My app is getting checkout properly.Problem comes when running rake task.

    Now when i go into the build and run the task it is getting properly executed.

  • Hi, my name is Philippe Creux.

    This blog is about Agile project management, Ruby programming and other cool things. I haven't published anything here since 2011. Find the latest and greatest on pcreux.com!